URDF Format - Unified Robot Description Format for Humanoid Robots
Learning Objectives
- Understand the structure and purpose of URDF files
- Learn how to define robot kinematics using URDF
- Create URDF files for humanoid robot models
- Integrate URDF with ROS 2 simulation and visualization tools
Overview
Unified Robot Description Format (URDF) is an XML-based format used to describe robots in ROS. It contains information about the robot's physical structure, kinematics, dynamics, visual representation, and collision properties. For humanoid robots, URDF is essential for simulation, visualization, and control.
URDF Structure
A URDF file describes a robot as a collection of links connected by joints, forming a kinematic tree. Each link represents a rigid body, and each joint defines the connection between two links.
Key Elements:
- Links: Represent rigid bodies with visual, collision, and inertial properties
- Joints: Define the connection between links with specific degrees of freedom
- Materials: Define visual appearance properties
- Gazebo Plugins: Extensions for simulation-specific functionality
Link Definition
A link contains three main components:
- Visual: How the link appears in visualizations
- Collision: How the link behaves in collision detection
- Inertial: Mass, center of mass, and inertia properties for dynamics
<link name="link_name">
<visual>
<geometry>
<box size="1 2 3"/>
</geometry>
<material name="color">
<color rgba="0.8 0.2 0.2 1.0"/>
</material>
</visual>
<collision>
<geometry>
<box size="1 2 3"/>
</geometry>
</collision>
<inertial>
<mass value="1.0"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
Joint Definition
Joints define the connection between links and specify the allowed motion:
- Fixed: No relative motion between links
- Revolute: One degree of freedom rotational joint with limits
- Continuous: Revolute joint without limits
- Prismatic: One degree of freedom translational joint with limits
- Floating: Six degrees of freedom with no constraints
- Planar: Motion limited to a plane
<joint name="joint_name" type="revolute">
<parent link="parent_link"/>
<child link="child_link"/>
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<limit lower="-1.57" upper="1.57" effort="100" velocity="1"/>
</joint>
Humanoid Robot Specifics
Humanoid robots have specific kinematic structures that require careful URDF design:
Common Joint Types:
- Hip joints: Often 3-DOF (roll, pitch, yaw) for full leg movement
- Knee joints: Typically 1-DOF revolute joints
- Ankle joints: Often 2-DOF (pitch, roll) for balance
- Shoulder joints: Usually 3-DOF for arm movement
- Elbow joints: Typically 1-DOF for arm bending
- Wrist joints: Often 2-DOF for hand orientation
Kinematic Chains:
- Leg chains: hip → knee → ankle → foot
- Arm chains: shoulder → elbow → wrist → hand
- Neck chain: torso → neck → head
URDF Best Practices
- Kinematic Consistency: Ensure the kinematic tree is properly structured without loops
- Mass Properties: Accurately define inertial properties for realistic simulation
- Joint Limits: Set appropriate limits to prevent self-collision and hardware damage
- Collision Models: Use simplified geometries for efficient collision detection
- Visual Models: Use detailed geometries for visualization while keeping collision models simple
Integration with ROS 2
URDF files are typically loaded using the robot_state_publisher package, which reads the URDF and publishes the robot's joint states and transforms to the tf2 system.
Launch Configuration:
- URDF files are often loaded as parameters in launch files
- Joint state publishers provide real-time joint information
- Robot state publisher computes forward kinematics
SDF vs URDF
While URDF is used for kinematic/dynamic descriptions in ROS, SDF (Simulation Description Format) is used by Gazebo for simulation-specific properties. For complete robot simulation, both formats may be used together.
Tools for URDF
- xacro: XML macro language that extends URDF with features like variables and macros
- rviz: For visualizing URDF models
- gazebo: For simulating URDF robots
- MoveIt!: For motion planning with URDF robots
Exercises
Exercise 1: Simple Robot Arm URDF
Create a URDF file for a 2-link robot arm:
- Define two links connected by a revolute joint
- Add visual and collision properties to each link
- Include appropriate inertial properties
- Visualize the robot in RViz to verify the model
Exercise 2: Humanoid Leg Definition
Define a simplified humanoid leg in URDF:
- Create links for thigh, shank, and foot
- Define joints for hip (3-DOF), knee (1-DOF), and ankle (2-DOF)
- Set appropriate joint limits to prevent self-collision
- Validate the kinematic chain for proper range of motion
Exercise 3: Visual and Collision Properties
Enhance a URDF model with proper properties:
- Add realistic visual materials and colors
- Define collision geometries that are simpler than visual geometries
- Set accurate inertial properties for dynamic simulation
- Test the model in Gazebo to verify physics behavior
Exercise 4: Xacro Parameterization
Convert a URDF to a parameterized Xacro:
- Define parameters for link dimensions and masses
- Create macros for repeated structures (e.g., arms, legs)
- Add default values for common parameters
- Generate different robot variants from the same Xacro file
Summary
URDF is fundamental to representing robots in ROS 2, particularly for humanoid robots where complex kinematic structures are needed. Understanding URDF structure and best practices is essential for creating accurate robot models for simulation, visualization, and control. Proper URDF design enables realistic simulation and effective robot control.