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 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 ...
I would advise that you do the following and examine the sdf description
Hi, thankyou for your comment!
I tried your suggestion and updated my post.
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.
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
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.
ok, thankyou for your help. I will give a rey later.