0
$\begingroup$

Rosanswers logo

While creating a gazebo simulation of any robot, we need to have a URDF so that Gazebo can understand the description of the robot and render it accordingly. Then what exactly is a xacro file ? Also I have observed a meshes folder many a times which contains all the .dae files. What exactly is it ?

Can someone provide a guide to understand all these simulation related concepts properly ?


Originally posted by electrophod on ROS Answers with karma: 277 on 2020-11-22

Post score: 0


Original comments

Comment by gvdhoorn on 2020-11-22:
Some observations (but not answers, I'll leave that to someone else):

While creating a gazebo simulation of any robot, we need to have a URDF so that Gazebo can understand the description of the robot and render it accordingly

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 the structure of your robot to ROS (ie: tells it where the sensors are, link lengths, etc). While the two would overlap ..

Comment by gvdhoorn on 2020-11-22:
.. 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.

Also I have observed a meshes folder many a times which contains all the .dae files

I believe Wikipedia has a good description of what a "mesh" is: wikipedia/Polygon_mesh.

.dae is the file extension of Collada files.

Note: this is not ROS specific.

Comment by electrophod on 2020-11-23:
@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 the meshes folder in our ROS package?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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>

Originally posted by tryan with karma: 1421 on 2020-11-23

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.