Simulating a robot in Gazebo requires a description of the robot model. One way to represent such a model, is to use the URDF format (standing for Unified Robot Description Format). The URDF format is simply an XML format that describes a robot, its parts, its joints, dimensions, and so on. Whenever you see a 3D robot on ROS, e.g. the PR2 (Willow Garage) or the Robonaut (NASA), a URDF file is associated with it.
In this post, we will develop a simple model for a differential drive robot. You can find the related files at Odisseus GitHub repository.
In general, when building a simulation with ROS, we should decide upon the following
- The messaging interface that we will use
- The drivers of the robot’s motors
- The model of the robot
- The physical properties to use in the simulation with Gazebo (or any other simulator whatsoever)
- How to transform between different coordinate frames (see the tf library)
- The sensors to use
- The algorithms for navigation
As we already mentioned, in this post, we will develop a URDF description of a differential drive robot. Such a robot is characterized by :
- forward/backward movement
- rotation (i.e. yaw ) around the z axis
- cannot translate side-to-side (y axis)
- cannot move along the z axis (i.e. up and down)
- cannot roll or pitch (i.e. rotate ) along its x and y axis
Furthermore, our robot has the following essential components
- One chassis
- Two rear wheels attached to the chassis
- One front caster attached to the chassis
- One front wheel attached to the front caster
The URDF format is only capable of representing robots whose kinematics can be described by a tree. Thus, looping structures are not allowed. Of course, we can easily come up a tree-like description of our robot and hence use the format. The URDF format includes primarily two essential items:
- links: i.e a rigid body, such as a chassis or a wheel
- joints: i.e. how two links are connected and move with respect to each other.
Let’s now open the
odisseus.urdf file you can find in Odisseus GitHub repository.
The file contains some entries related to Gazebo which we will not discuss here.
At first, you can notice that the file follows an XML format with the root node called
robot which has a
name property that simply indicates the name of our robot.
Scrolling the file further down, you will see that it contains
joint nodes. Each of these must specify their
name property which should be unique.
Furthermore, you can see that nodes of type
joint can have a visual description designated by the
visual node. If we want the link to be visible in
rviz or Gazebo, we need to provide this node. We can specify the geometry of the link using the
geometry node and the visual effect using the
material node. Try to change the RGB values to see what happens.
A handy tool for visualizing URDF model structures is
urdf_to_graphiz. This tool, parses a URDF file to produce a topological graph representation of the model, showing how links and joints are connected. Try it on
odisseus model by running
urdf_to_graphiz odisseus.urdf. This will produce an
odisseus.pdf file which you can view with a PDF viewer.
The other type of node we have are
joint nodes. These, as their name suggests, joint together two links. Again
joint nodes should have a name and also a type which specifies the kind of the joint. Here is a list of joints supported by the URDF format:
- Continuous: a joint that can rotate indefinitely about a single axis
- Revolute: like a continuous joint, but with upper and lower angle limits
- Prismatic: a joint that slides linearly along a single axis, with upper and lower position limits
- Planar: a joint that allows translation and rotation perpendicular to a plane
- Floating: a joint that allows full six-dimensional translation and rotation
- Fixed: a joint type that allows no motion
joint_state_publisher can be used to control/check the joint(s) defined in URDF. You can launch it when starting
rviz. For our case this can be done by typing
roslaunch odisseus odisseus.launch gui:=True
You will see that in addition to
rviz you get a small window named, well,
To check whether the syntax used in the file, is correct, we can use the
Arguably, the URDF can be quite verbose for robots that contain many links and joints. xacro helps in reducing the overall size of the URDF file and makes it easier to read and maintain but we will touch upon this in another post.