URDF: different colors in gazebo for one link with multiple visual meshes

asked 2020-01-27 04:04:46 -0600

nordischdiesel gravatar image

updated 2020-02-03 17:07:21 -0600

Hi, I have a URDF with a few links. One of the links with multiple visual meshes. The meshes dont have the right origin at the moment, but thats not the point.

Is it possible to give each visual mesh a different color in gazebo or is gazebo only possible to reference one color to the link_name and not to a specific visual tag?

Gazebo reference:

  <gazebo reference="assembly_table">
<material>Gazebo/White</material>
 </gazebo>

Example link:

<link name= "assembly_table">
<visual>
  <geometry>
    <mesh filename="package://path/to/mesh/table_top.dae"/>
  </geometry>
  <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
</visual>

<visual>
  <geometry>
    <mesh filename="package://path/to/mesh/item_table.dae"/>
  </geometry>
  <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
</visual>

<visual>
  <geometry>
    <mesh filename="package://path/to/mesh/UTS100cc.dae"/>
  </geometry>
  <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
</visual>

<visual>
  <geometry>
    <mesh filename="package://path/to/mesh/ims300pp.dae"/>
  </geometry>
  <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
</visual> 
</link>

Update:

I would advise that you do the following and examine the sdf description

gz sdf -p <robot>.urdf

rosrun xacro xacro -o model.urdf model.xacro

and

gz sdf -p model.urdf

So this is what I get (without the collision part):

<link name='assembly_table'>
  <visual name='assembly_table_visual'>
    <pose frame=''>0 0 0 0 -0 0</pose>
    <geometry>
      <mesh>
        <scale>1 1 1</scale>
        <uri>model://path/to/mesh/table_top.dae</uri>
      </mesh>
    </geometry>
    <material>
      <script>
        <name>alu3</name>
        <uri>file://media/materials/scripts/gazebo.material</uri>
      </script>
    </material>
  </visual>
  <visual name='assembly_table_visual_1'>
    <pose frame=''>0 0 0 0 -0 0</pose>
    <geometry>
      <mesh>
        <scale>1 1 1</scale>
        <uri>model://path/to/mesh/item_table.dae</uri>
      </mesh>
    </geometry>
    <material>
      <script>
        <name>alu3</name>
        <uri>file://media/materials/scripts/gazebo.material</uri>
      </script>
    </material>
  </visual>
  <visual name='assembly_table_visual_2'>
    <pose frame=''>0 0 0 0 -0 0</pose>
    <geometry>
      <mesh>
        <scale>1 1 1</scale>
        <uri>model://path/to/mesh/UTS100cc.dae</uri>
      </mesh>
    </geometry>
    <material>
      <script>
        <name>alu3</name>
        <uri>file://media/materials/scripts/gazebo.material</uri>
      </script>
    </material>
  </visual>
  <visual name='assembly_table_visual_3'>
    <pose frame=''>0 0 0 0 -0 0</pose>
    <geometry>
      <mesh>
        <scale>1 1 1</scale>
        <uri>model://path/to/mesh/ims300pp.dae</uri>
      </mesh>
    </geometry>
    <material>
      <script>
        <name>alu3</name>
        <uri>file://media/materials/scripts/gazebo.material</uri>
      </script>
    </material>
  </visual>
  <gravity>0</gravity>
  <velocity_decay/>
</link>

Am I reading this right, that there is no reference to the visual tag in urdf. The sdf uses the uri material path for each visual element, refering to each visual tag assembly_table_visual_1 to assembly_table_visual_3.

Just found this:

<visual> (optional)

The visual properties of the link. This element specifies the shape of the object (box, cylinder, etc.) for visualization purposes. Note: multiple instances of <visual> tags can exist for the same link. The union of the geometry they define forms the ...
(more)
edit retag flag offensive close merge delete

Comments

1

I would advise that you do the following and examine the sdf description

gz sdf -p <robot>.urdf
nlamprian gravatar imagenlamprian ( 2020-02-02 11:02:49 -0600 )edit

Hi, thankyou for your comment!

I tried your suggestion and updated my post.

nordischdiesel gravatar imagenordischdiesel ( 2020-02-03 17:05:31 -0600 )edit

As far as I can see, the material is set the same for all visuals. So, the simplest solution would be to just move the extra visuals into their own links, and set the different materials for the links.

nlamprian gravatar imagenlamprian ( 2020-02-04 02:36:03 -0600 )edit

for better performence I reduced fixed joints in my urdf, by make one big part. When I use 4 links fixed together, my gazebo model collapses. So I probably have to live with a bad visualisation in the gazebo world.

If you have another suggestion I am happy to hear about that.

Thankyou

nordischdiesel gravatar imagenordischdiesel ( 2020-02-04 09:29:41 -0600 )edit

It collapsed due to a problem with your final model, not because it's not possible. You just need to track down the issue. One thing to look for, for example, is inertias.

nlamprian gravatar imagenlamprian ( 2020-02-04 11:24:20 -0600 )edit

ok, thankyou for your help. I will give a rey later.

nordischdiesel gravatar imagenordischdiesel ( 2020-02-08 11:48:49 -0600 )edit