2.2.3 Checking for Correctness

Course subject(s) Module 2. Build your own robot environment

In this lecture, we will learn how to check for errors and getting a working URDF file.

Summary:

It is easy to make mistakes in URDFs, as they can become many hundreds if not thousands of lines long in real ROS applications.

Luckily ROS provides us with a tool that we can use to verify the correctness of our URDFs: check_urdf. We can run it like so:

  check_urdf robot.urdf

This tool only checks the syntax though, so it checks whether we’ve only used legal combinations of recognized URDF keywords in our files. It cannot check whether you’ve correctly specified the mass of your robot links, whether the model that we’ve created makes sense or whether the colors that you’ve used correspond to what the manufacturer has used.

One other thing that check_urdf cannot do directly is checking XACRO files.

We can however verify the URDF that they will generate, so we can first convert them and then run check_urdf on the resulting file.

So we first convert the XACRO file to URDF (this will generate the URDF file in the current working directory):

  rosrun xacro xacro /path/to/robot.xacro > robot.urdf

And then run check_urdf on that file:

  check_urdf robot.urdf

This will check our URDF, but we must then map any mistakes it finds back to our XACRO files ourselves.

 

Example

To illustrate the usage of check_urdf, we can take a look at our small example robot again:

This URDF snippet has an obvious mistake: the child link of joint_1 is specified as link_3, but there is no link_3 in the URDF. This makes this joint specification incorrect, and we expect that check_urdf will detect and confirm this for us.

So we’ll run check_urdf as follows:

  check_urdf tiny_robot.urdf

and sure enough, check_urdf complains:

Error: Failed to build tree:
   child link [link_3] of joint [joint_1] not found
Error: Model Parsing the xml failed

So let’s fix this.

Let’s change the child link of joint_1 back to link_2:

With the mistake fixed, let’s run check_urdf again to verify that we made no further mistakes:

  check_urdf tiny_robot.urdf

and now everything is fine and the output is:

robot name is: tiny_robot
-------------Successfully Parsed XML-------------
root Link: link_1 has 1 child(ren)
child(1): link_2

Creative Commons License
Hello (Real) World with ROS - Robot Operating System by TU Delft OpenCourseWare is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at https://online-learning.tudelft.nl/courses/hello-real-world-with-ros-robot-operating-systems//.
Back to top