Gazebo | Ignition | Community
Ask Your Question
3

How to build a world with real image as ground plane

asked 2013-10-17 01:14:55 -0600

Paul gravatar image

I want to simulate a world where its ground has special pattern. I decided to make a image file use Photoshop, and put this image into gazebo world as ground plane.

Can anyone tell me how to do this?

Thanks a lot!

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
4

answered 2013-10-17 10:40:41 -0600

nkoenig gravatar image

updated 2018-04-03 14:56:19 -0600

Update: Also check out this tutorial.

You can create a material script, and then use that material script on a ground plane.

  1. Create a new model directory:

    mkdir ~/.gazebo/models/my_ground_plane

  2. Create the materials directories:

    mdkir -p ~/.gazebo/models/my_ground_plane/materials/textures mdkir -p ~/.gazebo/models/my_ground_plane/materials/scripts

  3. Create your material script file ~/.gazebo/models/my_ground_plane/materials/scripts/my_ground_plane.material with the following contents:

    material MyGroundPlane/Image
    {
      technique
      {
        pass
        {
          ambient 0.5 0.5 0.5 1.0
          diffuse 1.0 1.0 1.0 1.0
          specular 0.0 0.0 0.0 1.0 0.5

          texture_unit
          {
            texture MyImage.png
            filtering trilinear
          }
        }
      }
    }
  1. Copy your image to ~/.gazebo/models/my_ground_plane/materials/textures/MyImage.png

  2. Create a ~/.gazebo/models/my_ground_plane/model.sdf file with the following contents

    <?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>100 100</size>
              </plane>
            </geometry>
            <material>
              <script>
                <uri>model://my_ground_plane/materials/scripts/my_ground_plane.material</uri>
                <name>MyGroundPlane/Image</name>
              </script>
            </material>
          </visual>
        </link>
      </model>
    </sdf>
    
  3. Create a ~/.gazebo/models/my_ground_plane/model.config file with the following contents


    <model> <name>My Ground Plane</name> <version>1.0</version> <sdf version="1.4">model.sdf</sdf>

    <description>
      My textured ground plane.
    </description>
    

    </model>

  4. In your world SDF file, use your ground plane like so:

    <include>
      <uri>model://my_ground_plane</uri>
    </include>
    
edit flag offensive delete link more

Comments

Thank you so much for this detailed and concise reply!

Paul gravatar imagePaul ( 2013-10-17 21:43:33 -0600 )edit

Hi nkoenig, can you tell me how to find the documentation of material. I don't know the meaning of ambient, diffuse and specular

Paul gravatar imagePaul ( 2013-10-18 04:46:13 -0600 )edit

I found a bug in your post

Paul gravatar imagePaul ( 2013-10-18 06:58:34 -0600 )edit

I found a bug in your post

Paul gravatar imagePaul ( 2013-10-18 06:58:34 -0600 )edit

Does this apply to Ign Citadel as well too? I'm having no luck on that one and I'm hoping it's not a bug

kakcalu13 gravatar imagekakcalu13 ( 2021-09-17 13:52:57 -0600 )edit
0

answered 2018-05-01 16:47:06 -0600

spacewandererer gravatar image

updated 2018-05-15 18:17:21 -0600

nkoenig's answer worked for me. But there wasn't any need for step 4 - Use ground plane using include tag

I also referred to another question for values of ambient, diffuse, specular ,emissive to ensure no squishing of image. Also used the fix mentioned in the answer.

Steps that worked for me:

  1. Create a new model directory:

    mkdir ~/.gazebo/models/my_ground_plane

  2. Create the materials directories:

    mdkir -p ~/.gazebo/models/my_ground_plane/materials/textures
    mdkir -p ~/.gazebo/models/my_ground_plane/materials/scripts

  3. Create your material script file ~/.gazebo/models/my_ground_plane/materials/scripts/my_ground_plane.material
    with the following contents:

material MyGroundPlane/Image
        {
          technique
          {
            pass
            {
              ambient 1 1 1 1.000000
              diffuse 1 1 1 1.000000
              specular 0.03 0.03 0.03 1.000000 

              texture_unit
              {
                texture MyImage.png
              }
            }
          }
        }

4.Copy your image to
~/.gazebo/models/my_ground_plane/materials/textures/MyImage.png

5.Create a
~/.gazebo/models/my_ground_plane/model.sdf

file with the following contents

<?xml version="1.0" encoding="UTF-8"?>
<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>100 100</size>
               </plane>
            </geometry>
            <material>
               <script>
                  <uri>model://my_ground_plane/materials/scripts</uri>
                  <uri>model://my_ground_plane/materials/textures/</uri>
                  <name>MyGroundPlane/Image</name>
               </script>
            </material>
         </visual>
      </link>
   </model>
</sdf>

6.Create a
~/.gazebo/models/my_ground_plane/model.config
file with the following contents

<?xml version="1.0" encoding="UTF-8"?>
<model>
   <name>My Ground Plane</name>
   <version>1.0</version>
   <sdf version="1.4">model.sdf</sdf>
   <description>My textured ground plane.</description>
</model>

7.Files I have created till now:

~/.gazebo/models/my_ground_plane/materials/scripts/my_ground_plane.material
~/.gazebo/models/my_ground_plane/materials/textures/MyImage.png
~/.gazebo/models/my_ground_plane/model.config
~/.gazebo/models/my_ground_plane/model.sdf

8.Open Gazebo and add my_ground_plane to add the new texture you defined to the Gazebo ground plane

9.If your floor comes up blinking grey when you insert it, it's because it's z-fighting with the default ground_plane, just delete the ground plane and that should be fine.

edit flag offensive delete link more
0

answered 2016-10-17 08:53:21 -0600

<material> <script> <uri>model://mygroundplane/materials/scripts/my_ground_plane.material</uri> <name>MyGroundPlane/Image</name> </script> </material>

There is a small bug.

edit flag offensive delete link more

Comments

excuse me , what do you mean by '4- In your world SDF file, use your ground plane like so:' . do you mean the file model.sdf? if so is there any specific location to put that : <include> <uri>model://my_ground_plane</uri> </include> every time i try to load the resulted model gazebo freezes and exit .

Caesar84 gravatar imageCaesar84 ( 2018-04-04 19:42:35 -0600 )edit

@Caesar84 I was able to place the image on the ground plane without the step 4 - including include

spacewandererer gravatar imagespacewandererer ( 2018-04-30 19:41:26 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2013-10-17 01:14:55 -0600

Seen: 44,414 times

Last updated: Nov 24 '21