Note: This tutorial assumes that you have completed the previous tutorials: Building a Visual Robot Model with URDF.
(!) Please ask about problems and questions regarding this tutorial on Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Building a Movable Robot Model with URDF

Description: Learn how to define movable joints in URDF

Keywords: URDF, Joints

Tutorial Level: BEGINNER

Next Tutorial: Adding Physical and Collision Properties to the Model

In this tutorial, we’re going to revise the R2D2 model we made in the previous tutorial so that it has movable joints. In the previous model, all of the joints were fixed. Now we’ll explore three other important types of joints: continuous, revolute and prismatic.

Make sure you have installed all prerequisites before continuing. See the previous tutorial for information on what is required.

Again, all of the robot models mentioned in this tutorial can be found in the urdf_tutorial package.

Here is the new urdf with flexible joints. You can compare it to the previous version to see everything that has changed, but we’re just going to focus on three example joints.

To visualize and control this model, run the same command as the last tutorial: roslaunch urdf_tutorial display.launch model:=urdf/06-flexible.urdf However now this will also pop up a GUI that allows you to control the values of all the non-fixed joints. Play with the model some and see how it moves. Then, we can take a look at how we accomplished this.

Screenshot of Flexible Model

The Head

   1   <joint name="head_swivel" type="continuous">
   2     <parent link="base_link"/>
   3     <child link="head"/>
   4     <axis xyz="0 0 1"/>
   5     <origin xyz="0 0 0.3"/>
   6   </joint>

The connection between the body and the head is a continuous joint, meaning that it can take on any angle from negative infinity to positive infinity. The wheels are also modeled like this, so that they can roll in both directions forever.

The only additional information we have to add is the axis of rotation, here specified by an xyz triplet, which specifies a vector around which the head will rotate. Since we want it to go around the z axis, we specify the vector "0 0 1".

The Gripper

   1   <joint name="left_gripper_joint" type="revolute">
   2     <axis xyz="0 0 1"/>
   3     <limit effort="1000.0" lower="0.0" upper="0.548" velocity="0.5"/>
   4     <origin rpy="0 0 0" xyz="0.2 0.01 0"/>
   5     <parent link="gripper_pole"/>
   6     <child link="left_gripper"/>
   7   </joint>

Both the right and the left gripper joints are modeled as revolute joints. This means that they rotate in the same way that the continuous joints do, but they have strict limits. Hence, we must include the limit tag specifying the upper and lower limits of the joint (in radians). We also must specify a maximum velocity and effort for this joint but the actual values don't matter for our purposes here.

The Gripper Arm

   1   <joint name="gripper_extension" type="prismatic">
   2     <parent link="base_link"/>
   3     <child link="gripper_pole"/>
   4     <limit effort="1000.0" lower="-0.38" upper="0" velocity="0.5"/>
   5     <origin rpy="0 0 0" xyz="0.19 0 0.2"/>
   6   </joint>

The gripper arm is a different kind of joint, namely a prismatic joint. This means that it moves along an axis, not around it. This translational movement is what allows our robot model to extend and retract its gripper arm.

The limits of the prismatic arm are specified in the same way as a revolute joint, except that the units are meters, not radians.

Other Types of Joints

There are two other kinds of joints that move around in space. Whereas the prismatic joint can only move along one dimension, a planar joint can move around in a plane, or two dimensions. Furthermore, a floating joint is unconstrained, and can move around in any of the three dimensions. These joints cannot be specified by just one number, and therefore aren’t included in this tutorial.

Specifying the Pose

As you move the sliders around in the GUI, the model moves in Rviz. How is this done? First the GUI parses the URDF and finds all the non-fixed joints and their limits. Then, it uses the values of the sliders to publish sensor_msgs/JointState messages. Those are then used by robot_state_publisher to calculate all of transforms between the different parts. The resulting transform tree is then used to display all of the shapes in Rviz.

Next steps

Now that you have a visibly functional model, you can add in some physical properties, or start using xacro to simplify your code.

Wiki: urdf/Tutorials/Building a Movable Robot Model with URDF (last edited 2021-10-07 18:40:58 by DavidLu)