In this chapter, you will begin to understand the control of robot arms with ROS. We will show a simple three-link, two-joint, articulated robotic arm in simulation. The simulated robot arm, rrbot
, has two revolute joints that will help you to understand the operations of a physical robot arm, without the complexities that more joints would create. We will use the URDF elements described in Chapter 2, Creating Your First Two-Wheeled ROS Robot (in Simulation) and incorporate the advantages of Xacro to make our code more modular and efficient. We will also include a mesh design for our gripper, and add control elements for the arm and gripper to our URDF. Next, we will show various ways to control the robot arm in Gazebo.
In this chapter, you will learn the following:
We will begin by expanding your 3D modeling skills in order to create a robot arm URDF using Xacro. First, the advantages of Xacro are described.
Xacro is the XML macro language for ROS. Xacro provides a set of macro operations to replace some repetitive statements with shorter, concise macros that will expand into full XML statements when processed. Xacro can be used with any XML document, but is most useful with long, complex URDF files. Xacro allows you to create shorter and more readable XML files for the robot URDF. Xacro provides advantages in many different areas:
<property>
tag can be used to specify these constant values in a central location. Property blocks are snippets that can contain one or more XML definitions. These are typically parameters that can be changed later. Properties and property blocks are usually declared at the beginning of the file, although this is not required. They can be found anywhere in the XML file at any level. It does not matter whether the property declaration is before or after its use.Here is an example of how to implement a property:
<xacro:property name="my_name" value ="Robby" />
This is a property declaration for my_name
.
"${my_name}"
, which is evaluated as the value of my_name
, and can be used to substitute the text "Robby"
into an attribute.+
, -
, /
, and *
. The unary minus and parentheses can also be used. The expression must be enclosed in the ${}
construct. Numeric values are floating point numbers.<xacro>
tag can expand into a statement or sequence of statements in the URDF/SDF file. Macros are extremely useful when statements are repeated or reused with modifications defined by parameters.rospack
commands, just as roslaunch
does for substitution arguments (args
) (http://wiki.ros.org/roslaunch/XML). The rospack
commands enclosed within $()
will be resolved during Xacro processing. For example, $(find ros_robotics)
will find the relative pathname for the ros_robotics
package. The $(arg var1)
argument will be resolved to a value passed by an Xacro statement or the command line. Arguments passed via the command line must use the myvar:=true
flag.<xacro:include filename="path to filename/filename" />
These features will be used in the URDF file for rrbot
throughout this chapter. The order in which Xacro processes all these features is as follows: