URDF: different colors in gazebo for one link with multiple visual meshes
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 assemblytablevisual_1 to assemblytablevisual_3.
Just found this:
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 visual representation of the link.
name (optional)
Specifies a name for a part of a link's geometry. This is useful to be able to refer to specific bits of the geometry of a link.
from http://wiki.ros.org/urdf/XML/link
I would be very happy if someone has more information about this concern.
Thankyou
Asked by nordischdiesel on 2020-01-27 05:04:46 UTC
Comments
I would advise that you do the following and examine the sdf description
Asked by nlamprian on 2020-02-02 12:02:49 UTC
Hi, thankyou for your comment!
I tried your suggestion and updated my post.
Asked by nordischdiesel on 2020-02-03 18:05:31 UTC
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.
Asked by nlamprian on 2020-02-04 03:36:03 UTC
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
Asked by nordischdiesel on 2020-02-04 10:29:41 UTC
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.
Asked by nlamprian on 2020-02-04 12:24:20 UTC
ok, thankyou for your help. I will give a rey later.
Asked by nordischdiesel on 2020-02-08 12:48:49 UTC