URDF: Building a Humanoid Robot Description
Unified Robot Description Format (URDF) is an XML-based format used to describe robot models in ROS 2. For Physical AI systems, especially humanoid robots, URDF provides the foundation for simulation, visualization, planning, and control. This section covers how to create accurate robot descriptions that enable embodied intelligence.
Introduction to URDF
URDF (Unified Robot Description Format) is an XML format that describes a robot's physical and kinematic properties. It defines the robot's structure, including links (rigid parts), joints (connections between links), and their relationships.
Why URDF Matters for Physical AI
URDF is crucial for Physical AI systems because it enables:
- Simulation: Creates digital twins for testing and development
- Visualization: Provides 3D models for tools like RViz
- Kinematics: Allows calculation of forward and inverse kinematics
- Planning: Provides collision models for motion planning
- Control: Defines joint limits and dynamics for controllers
URDF Structure Overview
A URDF file has this basic structure:
<?xml version="1.0"?>
<robot name="my_robot">
<!-- Define materials -->
<material name="blue">
<color rgba="0.0 0.0 0.8 1.0"/>
</material>
<!-- Define links -->
<link name="base_link">
<visual>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
<material name="blue"/>
</visual>
<collision>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
</collision>
<inertial>
<mass value="10"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<!-- Define joints -->
<joint name="base_to_wheel" type="continuous">
<parent link="base_link"/>
<child link="wheel_link"/>
<origin xyz="0 0 -0.3" rpy="0 0 0"/>
</joint>
<link name="wheel_link">
<visual>
<geometry>
<cylinder length="0.1" radius="0.2"/>
</geometry>
</visual>
</link>
</robot>
Core URDF Concepts
Links
Links represent rigid bodies in the robot. Each link has:
- A unique name
- Visual properties (shape, color, material)
- Collision properties (shape for collision detection)
- Inertial properties (mass, center of mass, inertia)
<link name="torso">
<visual>
<geometry>
<box size="0.3 0.2 0.5"/>
</geometry>
<material name="white">
<color rgba="1.0 1.0 1.0 1.0"/>
</material>
</visual>
<collision>
<geometry>
<box size="0.3 0.2 0.5"/>
</geometry>
</collision>
<inertial>
<mass value="5.0"/>
<origin xyz="0 0 0"/>
<inertia ixx="0.1" ixy="0.0" ixz="0.0" iyy="0.1" iyz="0.0" izz="0.1"/>
</inertial>
</link>
Joints
Joints connect links and define how they can move relative to each other. Joint types include:
revolute: Rotational joint with limitscontinuous: Rotational joint without limitsprismatic: Linear joint with limitsfixed: No movement between linksfloating: 6 DOF movement (for base of floating robots)planar: Movement on a plane
<joint name="neck_joint" type="revolute">
<parent link="torso"/>
<child link="head"/>
<origin xyz="0.0 0.0 0.25" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="-0.5" upper="0.5" effort="10.0" velocity="1.0"/>
</joint>
Materials
Materials define visual appearance:
<material name="red">
<color rgba="1.0 0.0 0.0 1.0"/>
</material>
<material name="blue">
<color rgba="0.0 0.0 1.0 1.0"/>
</material>
Humanoid Robot URDF
Designing a Humanoid Skeleton
Humanoid robots require specific joint configurations to mimic human movement:
<?xml version="1.0"?>
<robot name="simple_humanoid">
<!-- Base link - pelvis -->
<link name="pelvis">
<visual>
<geometry>
<box size="0.25 0.15 0.15"/>
</geometry>
</visual>
<collision>
<geometry>
<box size="0.25 0.15 0.15"/>
</geometry>
</collision>
<inertial>
<mass value="5.0"/>
<inertia ixx="0.1" ixy="0.0" ixz="0.0" iyy="0.1" iyz="0.0" izz="0.1"/>
</inertial>
</link>
<!-- Spine -->
<joint name="torso_joint" type="revolute">
<parent link="pelvis"/>
<child link="torso"/>
<origin xyz="0.0 0.0 0.1" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="-0.78" upper="0.78" effort="100" velocity="1.0"/>
</joint>
<link name="torso">
<visual>
<geometry>
<box size="0.25 0.3 0.15"/>
</geometry>
</visual>
<collision>
<geometry>
<box size="0.25 0.3 0.15"/>
</geometry>
</collision>
<inertial>
<mass value="10.0"/>
<inertia ixx="0.2" ixy="0.0" ixz="0.0" iyy="0.2" iyz="0.0" izz="0.2"/>
</inertial>
</link>
<!-- Head -->
<joint name="neck_joint" type="revolute">
<parent link="torso"/>
<child link="head"/>
<origin xyz="0.0 0.0 0.25" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="-0.5" upper="0.5" effort="5" velocity="1.0"/>
</joint>
<link name="head">
<visual>
<geometry>
<sphere radius="0.1"/>
</geometry>
</visual>
<collision>
<geometry>
<sphere radius="0.1"/>
</geometry>
</collision>
<inertial>
<mass value="1.0"/>
<inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01"/>
</inertial>
</link>
<!-- Left arm -->
<joint name="left_shoulder_joint" type="revolute">
<parent link="torso"/>
<child link="left_upper_arm"/>
<origin xyz="0.125 0.0 0.15" rpy="0 0 0"/>
<axis xyz="1 0 0"/>
<limit lower="-1.57" upper="1.57" effort="30" velocity="1.0"/>
</joint>
<link name="left_upper_arm">
<visual>
<geometry>
<cylinder length="0.3" radius="0.05"/>
</geometry>
<origin xyz="0 0 -0.15" rpy="1.57 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="0.3" radius="0.05"/>
</geometry>
<origin xyz="0 0 -0.15" rpy="1.57 0 0"/>
</collision>
<inertial>
<mass value="1.0"/>
<inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01"/>
</inertial>
</link>
<joint name="left_elbow_joint" type="revolute">
<parent link="left_upper_arm"/>
<child link="left_lower_arm"/>
<origin xyz="0 0 -0.3" rpy="0 0 0"/>
<axis xyz="1 0 0"/>
<limit lower="0" upper="1.57" effort="20" velocity="1.0"/>
</joint>
<link name="left_lower_arm">
<visual>
<geometry>
<cylinder length="0.3" radius="0.04"/>
</geometry>
<origin xyz="0 0 -0.15" rpy="1.57 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="0.3" radius="0.04"/>
</geometry>
<origin xyz="0 0 -0.15" rpy="1.57 0 0"/>
</collision>
<inertial>
<mass value="0.8"/>
<inertia ixx="0.008" ixy="0.0" ixz="0.0" iyy="0.008" iyz="0.0" izz="0.008"/>
</inertial>
</link>
<!-- Left hand -->
<joint name="left_wrist_joint" type="revolute">
<parent link="left_lower_arm"/>
<child link="left_hand"/>
<origin xyz="0 0 -0.3" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="-0.78" upper="0.78" effort="10" velocity="1.0"/>
</joint>
<link name="left_hand">
<visual>
<geometry>
<box size="0.15 0.08 0.08"/>
</geometry>
</visual>
<collision>
<geometry>
<box size="0.15 0.08 0.08"/>
</geometry>
</collision>
<inertial>
<mass value="0.3"/>
<inertia ixx="0.001" ixy="0.0" ixz="0.0" iyy="0.001" iyz="0.0" izz="0.001"/>
</inertial>
</link>
<!-- Right arm (similar to left, mirrored) -->
<joint name="right_shoulder_joint" type="revolute">
<parent link="torso"/>
<child link="right_upper_arm"/>
<origin xyz="-0.125 0.0 0.15" rpy="0 0 0"/>
<axis xyz="1 0 0"/>
<limit lower="-1.57" upper="1.57" effort="30" velocity="1.0"/>
</joint>
<link name="right_upper_arm">
<visual>
<geometry>
<cylinder length="0.3" radius="0.05"/>
</geometry>
<origin xyz="0 0 -0.15" rpy="1.57 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="0.3" radius="0.05"/>
</geometry>
<origin xyz="0 0 -0.15" rpy="1.57 0 0"/>
</collision>
<inertial>
<mass value="1.0"/>
<inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01"/>
</inertial>
</link>
<joint name="right_elbow_joint" type="revolute">
<parent link="right_upper_arm"/>
<child link="right_lower_arm"/>
<origin xyz="0 0 -0.3" rpy="0 0 0"/>
<axis xyz="1 0 0"/>
<limit lower="0" upper="1.57" effort="20" velocity="1.0"/>
</joint>
<link name="right_lower_arm">
<visual>
<geometry>
<cylinder length="0.3" radius="0.04"/>
</geometry>
<origin xyz="0 0 -0.15" rpy="1.57 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="0.3" radius="0.04"/>
</geometry>
<origin xyz="0 0 -0.15" rpy="1.57 0 0"/>
</collision>
<inertial>
<mass value="0.8"/>
<inertia ixx="0.008" ixy="0.0" ixz="0.0" iyy="0.008" iyz="0.0" izz="0.008"/>
</inertial>
</link>
<joint name="right_wrist_joint" type="revolute">
<parent link="right_lower_arm"/>
<child link="right_hand"/>
<origin xyz="0 0 -0.3" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="-0.78" upper="0.78" effort="10" velocity="1.0"/>
</joint>
<link name="right_hand">
<visual>
<geometry>
<box size="0.15 0.08 0.08"/>
</geometry>
</visual>
<collision>
<geometry>
<box size="0.15 0.08 0.08"/>
</geometry>
</collision>
<inertial>
<mass value="0.3"/>
<inertia ixx="0.001" ixy="0.0" ixz="0.0" iyy="0.001" iyz="0.0" izz="0.001"/>
</inertial>
</link>
<!-- Left leg -->
<joint name="left_hip_joint" type="revolute">
<parent link="pelvis"/>
<child link="left_thigh"/>
<origin xyz="0.075 0.0 -0.075" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="-0.78" upper="0.78" effort="50" velocity="1.0"/>
</joint>
<link name="left_thigh">
<visual>
<geometry>
<cylinder length="0.4" radius="0.06"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="1.57 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="0.4" radius="0.06"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="1.57 0 0"/>
</collision>
<inertial>
<mass value="2.0"/>
<inertia ixx="0.02" ixy="0.0" ixz="0.0" iyy="0.02" iyz="0.0" izz="0.02"/>
</inertial>
</link>
<joint name="left_knee_joint" type="revolute">
<parent link="left_thigh"/>
<child link="left_shin"/>
<origin xyz="0 0 -0.4" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="0" upper="1.57" effort="40" velocity="1.0"/>
</joint>
<link name="left_shin">
<visual>
<geometry>
<cylinder length="0.4" radius="0.05"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="1.57 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="0.4" radius="0.05"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="1.57 0 0"/>
</collision>
<inertial>
<mass value="1.5"/>
<inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.015" iyz="0.0" izz="0.015"/>
</inertial>
</link>
<joint name="left_ankle_joint" type="revolute">
<parent link="left_shin"/>
<child link="left_foot"/>
<origin xyz="0 0 -0.4" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="-0.5" upper="0.5" effort="30" velocity="1.0"/>
</joint>
<link name="left_foot">
<visual>
<geometry>
<box size="0.2 0.1 0.05"/>
</geometry>
</visual>
<collision>
<geometry>
<box size="0.2 0.1 0.05"/>
</geometry>
</collision>
<inertial>
<mass value="0.5"/>
<inertia ixx="0.002" ixy="0.0" ixz="0.0" iyy="0.002" iyz="0.0" izz="0.002"/>
</inertial>
</link>
<!-- Right leg (similar to left, mirrored) -->
<joint name="right_hip_joint" type="revolute">
<parent link="pelvis"/>
<child link="right_thigh"/>
<origin xyz="-0.075 0.0 -0.075" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="-0.78" upper="0.78" effort="50" velocity="1.0"/>
</joint>
<link name="right_thigh">
<visual>
<geometry>
<cylinder length="0.4" radius="0.06"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="1.57 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="0.4" radius="0.06"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="1.57 0 0"/>
</collision>
<inertial>
<mass value="2.0"/>
<inertia ixx="0.02" ixy="0.0" ixz="0.0" iyy="0.02" iyz="0.0" izz="0.02"/>
</inertial>
</link>
<joint name="right_knee_joint" type="revolute">
<parent link="right_thigh"/>
<child link="right_shin"/>
<origin xyz="0 0 -0.4" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="0" upper="1.57" effort="40" velocity="1.0"/>
</joint>
<link name="right_shin">
<visual>
<geometry>
<cylinder length="0.4" radius="0.05"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="1.57 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="0.4" radius="0.05"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="1.57 0 0"/>
</collision>
<inertial>
<mass value="1.5"/>
<inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.015" iyz="0.0" izz="0.015"/>
</inertial>
</link>
<joint name="right_ankle_joint" type="revolute">
<parent link="right_shin"/>
<child link="right_foot"/>
<origin xyz="0 0 -0.4" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="-0.5" upper="0.5" effort="30" velocity="1.0"/>
</joint>
<link name="right_foot">
<visual>
<geometry>
<box size="0.2 0.1 0.05"/>
</geometry>
</visual>
<collision>
<geometry>
<box size="0.2 0.1 0.05"/>
</geometry>
</collision>
<inertial>
<mass value="0.5"/>
<inertia ixx="0.002" ixy="0.0" ixz="0.0" iyy="0.002" iyz="0.0" izz="0.002"/>
</inertial>
</link>
</robot>
Advanced URDF Features
Transmissions
Transmissions connect actuators to joints, defining how control commands are converted:
<transmission name="left_hip_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="left_hip_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="left_hip_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
Gazebo Integration
For simulation in Gazebo, include Gazebo-specific tags:
<gazebo reference="torso">
<material>Gazebo/White</material>
<mu1>0.2</mu1>
<mu2>0.2</mu2>
</gazebo>
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/simple_humanoid</robotNamespace>
</plugin>
</gazebo>
Xacro for Complex Robots
For complex robots, use Xacro (XML Macros) to avoid repetition:
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="simple_humanoid_xacro">
<xacro:property name="M_PI" value="3.1415926535897931" />
<xacro:macro name="simple_leg" params="side prefix *origin">
<joint name="${prefix}_${side}_hip_joint" type="revolute">
<xacro:insert_block name="origin" />
<axis xyz="0 1 0"/>
<limit lower="-0.78" upper="0.78" effort="50" velocity="1.0"/>
<parent link="pelvis"/>
<child link="${prefix}_${side}_thigh"/>
</joint>
<link name="${prefix}_${side}_thigh">
<visual>
<geometry>
<cylinder length="0.4" radius="0.06"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="${M_PI/2} 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="0.4" radius="0.06"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="${M_PI/2} 0 0"/>
</collision>
<inertial>
<mass value="2.0"/>
<inertia ixx="0.02" ixy="0.0" ixz="0.0" iyy="0.02" iyz="0.0" izz="0.02"/>
</inertial>
</link>
<joint name="${prefix}_${side}_knee_joint" type="revolute">
<parent link="${prefix}_${side}_thigh"/>
<child link="${prefix}_${side}_shin"/>
<origin xyz="0 0 -0.4" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="0" upper="1.57" effort="40" velocity="1.0"/>
</joint>
<link name="${prefix}_${side}_shin">
<visual>
<geometry>
<cylinder length="0.4" radius="0.05"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="${M_PI/2} 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="0.4" radius="0.05"/>
</geometry>
<origin xyz="0 0 -0.2" rpy="${M_PI/2} 0 0"/>
</collision>
<inertial>
<mass value="1.5"/>
<inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.015" iyz="0.0" izz="0.015"/>
</inertial>
</link>
</xacro:macro>
<!-- Use the macro to create both legs -->
<xacro:simple_leg side="left" prefix="leg">
<origin xyz="0.075 0.0 -0.075" rpy="0 0 0"/>
</xacro:simple_leg>
<xacro:simple_leg side="right" prefix="leg">
<origin xyz="-0.075 0.0 -0.075" rpy="0 0 0"/>
</xacro:simple_leg>
</robot>
Physical AI Considerations in URDF
Accurate Inertial Properties
For Physical AI systems, accurate inertial properties are crucial for:
- Stable control algorithms
- Accurate simulation
- Proper balance calculations
Collision Detection
Collision properties affect:
- Motion planning
- Safety constraints
- Simulation physics
Visual Properties
For visualization and perception tasks:
- Realistic appearance for simulation
- Texture mapping for computer vision
- Proper colors for object recognition
Tools and Validation
URDF Validation
Always validate your URDF files:
# Check for XML syntax errors
xmllint --noout your_robot.urdf
# Use check_urdf tool (requires ROS 2 installation)
check_urdf your_robot.urdf
Visualization
Visualize your robot using RViz2:
<!-- In your launch file -->
<node pkg="rviz2" exec="rviz2" name="rviz2" args="-d $(find-pkg-share your_robot_description)/rviz/robot_description.rviz"/>
Learning Objectives
After completing this module, you will be able to:
- Create URDF models for humanoid robots
- Define links, joints, and their properties correctly
- Use Xacro to simplify complex robot descriptions
- Understand the impact of URDF on Physical AI systems
- Validate and visualize URDF models
Hands-On Exercise
Create a URDF model for a simple humanoid robot with:
- 18+ degrees of freedom (head, arms, legs)
- Proper inertial properties for each link
- Xacro macros to reduce code duplication
- Gazebo integration tags
- A launch file to visualize the robot in RViz
Next Steps
In the next section, we'll explore launch files, parameters, and robot communication in ROS 2, which are essential for bringing your URDF model to life in simulation and on real robots.