0
$\begingroup$

Gazebo Answers logo

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/4761/how-to-build-a-world-with-real-image-as-ground-plane/ and then a second to correct a possible error: http://answers.gazebosim.org/question/7922/ground-plane-texture-image/

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


Originally posted by savaresef on Gazebo Answers with karma: 5 on 2016-06-09

Post score: 0


Original comments

Comment by chapulina on 2016-06-09:
It looks like you copied model.config where the material should go

Comment by savaresef on 2016-06-09:
I don't know if the code that I copied is wrong itself or there are other aspects that I am not catching.

Comment by chapulina on 2016-06-09:
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?

Comment by savaresef on 2016-06-09:
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.

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

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.


Originally posted by chapulina with karma: 7504 on 2016-06-09

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by savaresef on 2016-06-09:
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.

Comment by savaresef on 2016-06-09:
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)?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.