ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Questions to SDF, urdf, xacro, material, textures using Gazebo

asked 2017-03-23 06:43:56 -0500

updated 2017-03-24 08:29:55 -0500

Hi Guys,

Currently I am a little stuck with my xacro model.

I have a texture file which should be attached to a surface in the xacro. How to add materials to your package, what do I need to export (what could I export) in the package.xml

Where do I really find the stuff documenting this features.

Examples:

            <material>
                <script>
                    <name>a/mat</name>
                    <uri>model://some_model/materials/scripts/mat.material</uri>
                </script>
            </material>

I have seen that for url there can be file and model. Does package also work here? What are those replaced with in the end and which of these exist?

Next: in the material file:

 material a/mat
{
  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 file.png
        filtering trilinear
      }
    }
  }
}

From where and how does it know where file.png is?

Does it just go standard for "../textures" ?

Folder structure is mostly like

  • package
    • models
      • myModel
        • textures
        • scripts

It works for me in a sdf file, but it seems to work never in my xacro.

Somehow this is related to the package.xml as well where you export model or media path I found as well:

<export>    
  <gazebo_ros gazebo_media_path="${prefix}"/> 
</export>

or:

<export>    
  <gazebo_ros gazebo_model_path="${prefix}/models"/> 
</export>

Are there any others and what exactly do they do?

Which variable does that set? Can I see them in my environment?

How are they supposed to be set up correctly - any standard way?

What if for example I want to do a package with materials for gazebo, which should can be used for any package, how do I set that up?

So that I can use them, as you normally can do with "Gazebo/Grey ", "Gazebo/White"

Example*1 (xacro):

  <gazebo reference="link">
    <material>Gazebo/Grey</material>
  </gazebo>

Can somebody just enlighten me how to do it or where I find the documentation for all these things to make it "just right"?

UPDATE ---

I have now checked out multiple locations and found different places to get information about this thing, also found how to debug it.

http://gazebosim.org/tutorials?tut=ros_roslaunch

there it says:

rospack plugins --attrib="gazebo_media_path" gazebo_ros

And I saw that I actually had a problem. It only takes these if you have a <run _depend> on gazebo_ros.

  <run_depend>gazebo_ros</run_depend>


    <export>    
      <gazebo_ros gazebo_media_path="${prefix}/media"/> 
    </export>

But I still do not get my material like that*1.

Update 2:

Just when looking at my own old xacros I found out, you can instead of *1 also do:

  <gazebo reference="link">
        <material value="Gazebo/Grey" />
  </gazebo>

So another Question raised up: Which is now the "prefered" way of doing that?

Which one is deprecated?


Thanks a lot,

Regards,

Christian

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2017-03-24 10:45:04 -0500

updated 2017-03-24 10:50:32 -0500

What?

just now it started working like the way I thought it to..

Well in the package.xml you need:

<run_depend>gazebo_ros</run_depend>

<export>    
  <gazebo_ros gazebo_media_path="${prefix}"/>                             
</export>

and the folder structure is like this:

  • media
    • materials
      • scripts
      • texture

in the xacro file:

<gazebo reference="link">                           
<material>YourMaterial</material>
</gazebo>

I guess in the process I changed the folder structure multiple times, maybe I first missed the media folder.

edit flag offensive delete link more

Comments

where should the media folder be located?

praskot gravatar image praskot  ( 2020-11-12 18:51:06 -0500 )edit
4

answered 2018-10-03 11:13:35 -0500

hbaqueiro gravatar image

updated 2018-10-03 11:18:37 -0500

Actually there is a way to change the texture from within URDF. Put your ".material" file inside /media/materials/scripts/ and your texture images inside /media/materials/textures/. Use this simple snippet for the .material (just to make it simple, your code is right):

material YourMaterialName
{
   technique
   {
      pass
      {
         texture_unit
         {
          texture your_material_image.png
          scale 1 1
         }
      }   
   }
}

In your URDF, add the material to the link outside of the <link> tag, but referencing it. Example:

<link name="link_name">
    <inertial>
        <mass value="1.0" />
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <inertia ixx="1e-6" ixy="1e-6" ixz="1e-6"
                 iyy="1e-6" iyz="1e-6"
                 izz="1e-6" />
    </inertial>

    <visual>
        <geometry>
            <mesh filename="full_path_to_your_mesh/mesh.dae"/>
        </geometry>
    </visual>

    <collision>
        <geometry>
            <box size="1 1 1" /> <!-- anything you want... -->
        </geometry>
    </collision>
</link>

<gazebo reference="link_name">
    <material>YourMaterialName</material>
</gazebo>

That's it. If it still doesn't work, then you'll need to prepare your mesh. Open your mesh using Blender, then first imagine how would you cut your solid with a scissor in order to put all surfaces in a plane. Then, select those edges, press Ctrl+E and select Mark Seam. The edges will become red. Split the window into 2 and in the new window choose UV/Image Editor as the Editor Type (bottom left corner). Then, press A to select everything, press U and choose Unwrap. At the UV/Image Editor will appear a geometry showing all your object faces in a plane. Now you can export to COLLADA (.dae) and put in your visual geometry mesh.

If you could not follow up the Blender steps, take a look at this tutorial: https://youtu.be/f2-FfB9kRmE

edit flag offensive delete link more

Comments

is /media/materials/scripts/ absolute path?

praskot gravatar image praskot  ( 2020-11-12 18:50:28 -0500 )edit
1

answered 2017-03-23 07:11:13 -0500

Airuno2L gravatar image

This doesn't answer any of your questions, but I avoid all that stuff by just using .DAE files with the material properties embedded in the .dae. I use Blender to create/edit the .dae files and add materials.

edit flag offensive delete link more

Comments

hmm, that can be an option as well, I agree

cyborg-x1 gravatar image cyborg-x1  ( 2017-03-23 07:23:14 -0500 )edit

But you can not change a texture by argument with xacro then.

cyborg-x1 gravatar image cyborg-x1  ( 2017-03-23 07:24:48 -0500 )edit

Oh I see. I didn't realize that's what you were trying to do. I guess you could just make multiple .dae files of the same object, each with a different material applied.

Airuno2L gravatar image Airuno2L  ( 2017-03-23 07:59:19 -0500 )edit

Well, with meshes in git, that would be a bit of overload, don't you think? ;-) Even there is the fact, that I do not always use meshes. Like for example you can make neat configurable robots like my gantry_bot in my xacro repo

cyborg-x1 gravatar image cyborg-x1  ( 2017-03-23 08:15:55 -0500 )edit

Yeah if you're doing configurable robots using macros I can see why you want to do it this way.

Airuno2L gravatar image Airuno2L  ( 2017-03-23 08:33:58 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2017-03-23 06:43:56 -0500

Seen: 5,642 times

Last updated: Oct 03 '18