In this class, it is presented how to built a simple robot description (visual, kinematics and dynamic properties) used to control a robot using ROS with Gazebo (for simulation) or even in a real robot.
This class is based in the urdf tutorials and uses the R2-D2 robot as a model.
Three different XML based languages are used in a complementary way:
- SDF: Simulation Description Format
- URDF: Unified Robot Description Format
- XACRO: XML Macros
In this part it is initiated the construction of the robot visual model and how to move some robot parts. For this, is used the robot tag form URDF language and the link and joint tags from SDF language.
- robot: The root element in a robot description.
- link: The link element describes a rigid body with an inertia, visual features, and collision properties.
- joint: The joint element describes the kinematics and dynamics of the joint and also specifies the safety limits of the joint.
Test your robot:
roslaunch myfirstrobot_description load_description.launch model:=myfirstrobot.urdf enable_rviz:=true enable_jspublisher:=true
In this part it is presented how to organize and clean up the urdf code using the XACRO language.
There are a lot of features in the Xacro language. In this class is presented only the follows ones:
- Property: Values that can be inserted anywhere into the XML document. E.g.:
- Definition:
<xacro:property name="the_radius" value="2.1" /> <xacro:property name="the_length" value="4.5" />
- Use:
<geometry type="cylinder" radius="${the_radius}" length="${the_length}" />
- Property Blocks: Property blocks are named snippets of XML that can be inserted anywhere that XML is allowed. E.g.:
- Definition:
<xacro:property name="front_left_origin"> <origin xyz="0.3 0 0" rpy="0 0 0" /> </xacro:property>
- Use:
<wheel name="front_left_wheel"> <xacro:insert_block name="front_left_origin" /> </wheel>
- Math expressions: You can also write simple math expressions. E.g.:
- Definition:
<xacro:property name="radius" value="4.3" />
- Use:
<circle diameter="${2 * radius}" />
- Macros: The main feature of xacro is its support for macros. E.g.:
- Definition:
<xacro:macro name="caster" params="suffix *origin"> <link name="caster_${suffix}"> <xacro:insert_block name="origin" /> </link> <joint name="caster_${suffix}_joint"> <axis xyz="0 0 1" /> </joint> </xacro:macro>
- Use:
<xacro:caster suffix="front_left"> <pose xyz="0 1 0" rpy="0 0 0" /> </xacro:caster>
- Includes: You can include other xacro files. E.g.:
- Use:
<xacro:include filename="$(find package)/other_file.xacro" />
Test your robot:
roslaunch myfirstrobot_description load_description.launch model:=myfirstrobot.urdf.xacro enable_gazebo:=true enable_rviz:=true
In this part it is presented the increment of the robot description links with collision and inertial properties.
- collision: The collision properties of a link.
- origin: The reference frame of the collision element.
- geometry: The shape of the visual object.
- box
- cylinder
- sphere
- inertial: The inertial properties of the link.
-
mass: The mass of the link
-
inertia: A 3x3 rotational inertia matrix:
ixx ixy ixz --- iyy iyz --- --- izz
-
To determine the values of the rotational inertia matrix, it is used the formulas available in List of moments of inertia:
Test your robot:
roslaunch myfirstrobot_description load_description.launch model:=myfirstrobot.urdf.xacro enable_gazebo:=true enable_rviz:=true
The gazebo simulator provide a set of actuators and sensors plugins. In this part of the class it is presented the increment of the robot description with two of these plugins to base actuator and camera sensor and finally simulate the robot with gazebo simulator.
- Plugins
- Base actuator
- Camera sensor
Test your robot:
roslaunch myfirstrobot_description load_description.launch model:=myfirstrobot.urdf.xacro enable_gazebo:=true enable_rviz:=true enable_teleop:=true