To add to @gvdhoorn's good information, xacro
is a XML-based macro language to help with writing larger/more complicated URDFs as described xacro
wiki. One example provided there is
<xacro:macro name="pr2_arm" params="suffix parent reflect">
<pr2_upperarm suffix="${suffix}" reflect="${reflect}" parent="${parent}" />
<pr2_forearm suffix="${suffix}" reflect="${reflect}" parent="elbow_flex_${suffix}" />
</xacro:macro>
<xacro:pr2_arm suffix="left" reflect="1" parent="torso" />
<xacro:pr2_arm suffix="right" reflect="-1" parent="torso" />
which expands to
<pr2_upperarm suffix="left" reflect="1" parent="torso" />
<pr2_forearm suffix="left" reflect="1" parent="elbow_flex_left" />
<pr2_upperarm suffix="right" reflect="-1" parent="torso" />
<pr2_forearm suffix="right" reflect="-1" parent="elbow_flex_right" />
Basically, if you have multiple arms, you can define it as a macro once, then use that macro to produce extra arms more efficiently/clearly. The two arms in the example aren't so bad, but imagine defining 6 legs for a hexapod, with several links and motors each!
As for the meshes, the URDF documentation provides an explanation of where URDF files use meshes. Similarly, Gazebo uses meshes to define geometry. They're often used to define more complex visual and collision elements, like in this brief Gazebo tutorial for attaching meshes. The robot's model file (.sdf
in this case) refers to the mesh from the chassis link's visual element like this:
<visual name='visual'>
<geometry>
<mesh>
<uri>model://pioneer2dx/meshes/chassis.dae</uri>
</mesh>
</geometry>
</visual>
Some observations (but not answers, I'll leave that to someone else):
actually, Gazebo doesn't use / understand URDF. It only uses SDF. The reason you still see lots of
.urdf
and.xacro
in Gazebo related packages is because Gazebo comes with a tool which -- on-the-fly -- converts your URDF into an SDF (as best it can, the process is not lossless).Most pkg maintainers (including me) are just lazy, and prefer to only write and maintain a single model of a robot, so they use
.urdf
or.xacro
, as they know that can also be used with Gazebo.If you want to be really proper, you'd write a separate
.sdf
for the simulation model of your robot. The.urdf
then describes ...(more).. they are not the same. The latter is used by your control software (ie: ROS), the former is used by your simulator (ie: Gazebo), and they have different purposes and requirements.
Compare this to the situation where you have actual hw: no one expects to be able to use their URDF to produce or manufacture their real robot. Nor do they expect to be able to "spawn" their real robot using the URDF in the real world.
If you consider Gazebo as "a stand-in for reality", having to create a proper simulation model as an analog of your real hw, and additionally having a separate URDF (so not the same file) doesn't seem to strange any more.
I believe Wikipedia has a good description of what a "mesh" is: wikipedia/Polygon_mesh.
.dae
is ...(more)@gvdhoom Thanks for such a detailed answer. I would also like to ask how do we use the
.dae
placed in meshes in the Gazebo simulation ? Like does Gazebo 'refer' to them while creating the robot model or does it stand to be an alternative to be replaced by the robot SDF/URDF or what ? Basically what is the purpose of having themeshes
folder in our ROS package?