2.2.2 Limitations and XACRO

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

In this lecture, we will take a look at some of the shortcomings of URDF and how to use XACRO to deal with one of them.

Outline:

Limitations:

  1. Robot description cannot be changed (immutability)
  2. Only tree structures (no loops)
  3. No <sensor></sensor> (no sensor models)
  4. Low reusability of URDFs (composability)

Limitation 1 – Immutability:

  • Result of typical control flow
  • Robot description read once from parameter server
  • No standardized way to notify
  • Risk of desynchronization

Limitation 2 – No cycles:

  • Joint only have single parent and child
  • Only acyclic, directed graphs (or: trees)
  • Real-world impact

Limitation 3 – No sensor element:

  • Sensor meta-data can’t be incorporated directly
  • Alternatives exist, but then the data is distributed
  • Diminishes value of URDF

Limitation 4 – Low reusability:

  • Only a single <robot> tag in URDF
  • No support for import of remote files
  • Composite scenes have to be merged manually
  • No way to compose multiple URDFs

The solution to some of these problems can be XACRO (short for XML Macros)

  • Programmatic URDF generation
  • Templates
  • Parameters

XACRO and Composability:

  • Import macros from other files
  • Parameterize templates
  • Composite robots & scenes easier:
      • import macro from file
      • Invoke macro

XACRO – Needs conversion:

  • XACRO not directly compatible with URDF
  • Transformation needed with this command:
    $ rosrun xacro xacro /path/to/robot.xacro > robot.urdf
  • Checks for valid XACRO file (but is not identical to check_urdf)

XACRO example

We take a quick look at a simple example of a XACRO macro definition and a snippet of XACRO that shows us how that macro is invoked.

Notice how this macro specifies it requires two parameters: parent and arm_name. The value of the arm_name parameter is used in the link and joint definition to ensure that names are unique, while the parent parameter is used to specify the name of the link this arm should be connected to in the URDF.

To now create a robot with two arms, we can use the following structure:

And as always, to convert the entire XACRO file to URDF, we use the following command:

rosrun xacro xacro tiny_robot.xacro > tiny_robot.urdf

This will cause the lines between <xacro:macro> and </xacro:macro> in the macro definition above to be automatically inserted (ie: copy-pasted) into the URDF file that will be generated by the conversion process.

All of this makes XACRO a really powerful system: XACRO files can import other XACRO files, macros can call other macros and parameters can be used to add flexibility to macros.

Tutorial

In this week, you’ll follow and complete three of the five tutorials about URDF and XACRO that are available on the ROS wiki.

With the first two completed (see 2.2.1,) we can continue with the third tutorial now that we’ve discussed XACRO:

Follow along with the instructions in the tutorial and see whether you understand what is being shown.

The tutorial refers to URDF snippets you’ve seen in the previous two tutorials (“Building a Visual Robot Model with URDF from Scratch” and “Building a Movable Robot Model with URDF“), so be sure to have those pages open for reference.

Remember: the urdf_tutorial package has already been provided to you as part of the Week 2 download zip file and should be part of your workspace. You do not need to install anything using apt-get or use rosdep.

The files that are referred to in the tutorials are also available in the urdf_tutorial/urdf directory.

Remember also that editing files should be done outside the Course Command Shell (CCS), while running ROS commands should be done inside the CCS.

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