Gazebo | Ignition | Community
Ask Your Question
0

Ground Texture Doesn't work

asked 2016-06-09 09:15:25 -0500

savaresef gravatar image

updated 2016-06-09 11:43:41 -0500

Hi all, I am trying to build a ground plan with a road texture. I would like also update this texture at runtime during the simulation (I don't know if it is possible and is actually an other problem). I followed 1 "tutorial": http://answers.gazebosim.org/question... and then a second to correct a possible error: http://answers.gazebosim.org/question...

But for me doesn't work anymore. I have no error but I see a yellow and gray plane that is not what i want. I organized the files as described in the tutorials. The files that I have are: model.sdf

<?xml version="1.0"?>
<sdf version="1.4">
<model name="my_ground_plane">
  <static>true</static>
    <link name="link">
      <collision name="collision">
        <geometry>
          <plane>
            <normal>0 0 1</normal>
            <size>100 100</size>
          </plane>
        </geometry>
        <surface>
          <friction>
            <ode>
              <mu>100</mu>
              <mu2>50</mu2>
            </ode>
          </friction>
        </surface>
      </collision>
      <visual name="visual">
        <cast_shadows>false</cast_shadows>
        <geometry>
          <plane>
            <normal>0 0 1</normal>
            <size>10 10</size>
          </plane>
        </geometry>
        <material>
          <script>
            <uri>model://my_ground_plane/materials/scripts</uri>
        <uri>model://my_ground_plane/materials/textures/MyImage.png</uri>
            <name>my_ground_plane/Image</name>
          </script>
        </material>
      </visual>
    </link>
  </model>
</sdf>

model.config:

<model> 
<name> My Ground Plane </name>
<version> 1.0 </version> 
<sdf version="1.5">model.sdf </sdf>
<description>
  My textured ground plane.
</description>
</model>

my_ground_plane.material

material my_ground_plane/Image
{
  technique
  {
    pass
    {
      ambient 1 1 1 1.000000
      diffuse 1 1 1 1.000000
      specular 0.03 0.03 0.03 1.000000 
      emissive 0.900000 0.900000 0.900000 1.000000

  texture_unit
  {
    texture floor.png
  }
    }
  }
}

Can someone help me. I am really new in Gazebo and I don't know how to approach the problem. Thanks in advance

edit retag flag offensive close merge delete

Comments

It looks like you copied model.config where the material should go

chapulina gravatar imagechapulina ( 2016-06-09 10:38:15 -0500 )edit

I don't know if the code that I copied is wrong itself or there are other aspects that I am not catching.

savaresef gravatar imagesavaresef ( 2016-06-09 11:14:54 -0500 )edit

Under my_ground_plane.material you pasted the same code as under model.config, is this really the files you're using or did you make a mistake writing the question?

chapulina gravatar imagechapulina ( 2016-06-09 11:19:22 -0500 )edit

Was just a mistake. Now it is right, thanks. I have also tried deleting ambient, diffuse, specular and emissive. As the other code it is a copy from the "tutorial" that I posted in the link.

savaresef gravatar imagesavaresef ( 2016-06-09 11:45:29 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-06-09 12:04:55 -0500

chapulina gravatar image

In your files, you refer to two different image files: MyImage.png and floor.png, they should probably be the same, right?

Also, there's no need to have the image filename in the <uri> tag, just the path to textures is enough:

    <material>
      <script>
        <uri>model://my_ground_plane/materials/scripts</uri>
        <uri>model://my_ground_plane/materials/textures</uri>
        <name>my_ground_plane/Image</name>
      </script>
    </material>

So just referencing the correct png file inside the material script should do the trick.

edit flag offensive delete link more

Comments

Yes, floor and MyIMage are the same images but was just a copy and paste mistake and the code was correct, I changed the uri but I see just a yellow image instead of the texture that I would like to see.

savaresef gravatar imagesavaresef ( 2016-06-09 12:24:55 -0500 )edit

I solved the problem. Thanks a lot for your help. I guess was just an error related the image format. I downloaded an other png image and it works. The previous image was an image that I have created and probably I have done some mistake. Just to not open anther topic, do you have some idea on how change the texture at runtime? I guess using gazebo messages? Can you also suggest me other resources to better understand these kind of problems (about textures and so on)?

savaresef gravatar imagesavaresef ( 2016-06-09 12:31:09 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-09 09:15:25 -0500

Seen: 3,563 times

Last updated: Jun 09 '16