ROS2 Tutorials

URDF

The Unified Robot Description Format (URDF) is an XML-based file format used in robotics to describe the physical and kinematic structure of a robot. URDF is primarily used in the Robot Operating System (ROS) to model robots for simulation, visualization, and control. It allows users to define the various elements that make up a robot, such as its links (rigid bodies), joints (connections between links), sensors, actuators, and physical properties.

Understanding URDF

What is URDF?

The Unified Robot Description Format (URDF) is an XML-based file format used in robotics to describe the physical and kinematic structure of a robot. URDF is primarily used in the Robot Operating System (ROS) to model robots for simulation, visualization, and control. It allows users to define the various elements that make up a robot, such as its links (rigid bodies), joints (connections between links), sensors, actuators, and physical properties.

Why is URDF important?

URDF provides a standardized way to describe robot models, making it easier to:

  1. Simulate robots in environments like Gazebo, helping test functionality before actual deployment.
  2. Visualize robots in tools such as RViz, providing an intuitive representation of their physical structure.
  3. Facilitate motion planning with packages like MoveIt, ensuring accurate path planning based on kinematic constraints.
  4. Enable compatibility across various ROS tools and frameworks, ensuring seamless integration.

Key Components of a URDF File

A URDF file consists of several key elements that describe the robot’s structure and behavior:

  1. Robot Element
    • The root tag of the URDF file, encapsulating the entire robot model.
    • Example:
1
2
3
4
       <robot name="my_robot">
         <!-- Robot definition goes here -->
       </robot>
       
  1. Links
    • Represent the rigid parts (bodies) of the robot.
    • Links contain visual, collision, and inertial properties.
    • Example:
1
2
3
4
5
6
7
8
9
       <link name="base_link">
         <visual>
           <geometry>
             <box size="1 1 0.2"/>
           </geometry>
           <material name="blue"/>
         </visual>
       </link>
       
  1. Joints
    • Define connections between two links and specify how they move relative to each other.
    • Types of joints:
      • Fixed: No movement.
      • Revolute: Rotational motion around an axis.
      • Prismatic: Linear motion along an axis.
      • Floating: 6 degrees of freedom (rarely used).
      • Continuous: Unlimited rotational motion.
    • Example:
1
2
3
4
5
6
7
     <joint name="arm_joint" type="revolute">
       <parent link="base_link"/>
       <child link="arm_link"/>
       <origin xyz="0 0 0.5" rpy="0 0 0"/>
       <axis xyz="0 0 1"/>
     </joint>
     
  1. Inertial Properties
    • Represent the mass and moment of inertia, crucial for realistic physics simulations.
    • Example:
1
2
3
4
5
6
       <inertial>
         <mass value="2.0"/>
         <origin xyz="0 0 0"/>
         <inertia ixx="0.1" ixy="0" ixz="0" iyy="0.1" iyz="0" izz="0.1"/>
       </inertial>
       
  1. Visual Representation
    • Defines how the robot looks in visualization tools.
    • Can include meshes or basic geometric shapes (boxes, spheres, cylinders).
    • Example
1
2
3
4
5
6
7
       <visual>
         <geometry>
           <cylinder radius="0.1" length="1.0"/>
         </geometry>
         <material name="green"/>
       </visual>
       
  1. Collision Properties
    • Define the robot’s collision boundaries for physics engines in simulations.
    • Example:
1
2
3
4
5
6
       <collision>
         <geometry>
           <sphere radius="0.2"/>
         </geometry>
       </collision>
       

Advantages of Using URDF

  1. Modularity:
    • Easily extendable with additional features like sensors, actuators, and plugins.
  2. Cross-Platform Compatibility:
    • Works with ROS1, ROS2, and other simulation environments.
  3. Ease of Visualization and Debugging:
    • Can visualize the robot in RViz to check the structure and configuration.
  4. Parameterization with Xacro:
    • Using Xacro (XML Macros), URDFs can be modularized and parameterized to avoid code repetition.

Common Use Cases of URDF

  1. Robot Simulation:
    • URDF files are used in Gazebo to simulate robot behavior before deployment.
  2. Kinematic Analysis:
    • URDF helps in kinematic studies to understand the movement and constraints of a robot.
  3. Motion Planning:
    • MoveIt (and other motion planning frameworks) utilizes URDF to plan and execute robot motions effectively.
  4. Real-World Deployment:
    • The same URDF can be used for both simulation and real-world robot control.