Chapter 5. Creating Your First Robot Arm (in Simulation)

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:

  • The advantages of using Xacro in a URDF
  • Designing a three-link, two-joint robotic arm using Xacro and mesh files
  • Controlling the arm in Gazebo using ROS commands and rqt

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.

Features of Xacro

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:

  • Properties and property blocks: If repeated information is used in a URDF/SDF file, the <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.

    • This property is used in the expression "${my_name}", which is evaluated as the value of my_name, and can be used to substitute the text "Robby" into an attribute.
  • Simple math: Math expressions can be constructed using the four basic operations: +, -, /, and *. The unary minus and parentheses can also be used. The expression must be enclosed in the ${} construct. Numeric values are floating point numbers.
  • Macros: This is the main feature of Xacro. When creating a macro, a simple <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.
  • Use of rospack commands: Xacro supports the use of 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.
  • Combining multiple Xacro files: Other Xacro files can be included in the main URDF file to allow you to modularize the URDF file into component files. The tag is as follows:
    <xacro:include filename="path to filename/filename" />
  • Other features of Xacro can be found at http://wiki.ros.org/xacro.

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:

  1. Includes
  2. Properties and property blocks
  3. Macro definitions
  4. Instantiation of macros
  5. Expression evaluation
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset