A URDF (Unified Robot Description Format) file describes a robot's parts and how they connect. It helps robots understand their shape and move correctly.
Building a mobile robot URDF in ROS
Start learning this pattern below
Jump into concepts and practice - no test required
or
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Syntax
ROS
<robot name="robot_name"> <link name="link_name"> <visual> <geometry> <box size="x y z"/> </geometry> <material name="color_name"> <color rgba="r g b a"/> </material> </visual> </link> <joint name="joint_name" type="joint_type"> <parent link="parent_link"/> <child link="child_link"/> <origin xyz="x y z" rpy="roll pitch yaw"/> <axis xyz="x y z"/> </joint> </robot>
The <robot> tag wraps the whole description.
Links are robot parts; joints connect links and define movement.
Examples
base_link.ROS
<robot name="simple_bot"> <link name="base_link"/> </robot>
ROS
<robot name="mobile_bot"> <link name="base_link"> <visual> <geometry> <box size="0.5 0.3 0.1"/> </geometry> <material name="blue"> <color rgba="0 0 1 1"/> </material> </visual> </link> <joint name="wheel_joint" type="continuous"> <parent link="base_link"/> <child link="wheel_link"/> <origin xyz="0 0 -0.05" rpy="0 0 0"/> <axis xyz="0 1 0"/> </joint> <link name="wheel_link"/> </robot>
Sample Program
This URDF defines a simple mobile robot with a rectangular base and two wheels that can spin. The wheels are connected by continuous joints allowing rotation.
ROS
<?xml version="1.0"?> <robot name="my_mobile_robot"> <link name="base_link"> <visual> <geometry> <box size="0.6 0.4 0.2"/> </geometry> <material name="gray"> <color rgba="0.5 0.5 0.5 1"/> </material> </visual> </link> <link name="left_wheel_link"> <visual> <geometry> <cylinder length="0.05" radius="0.1"/> </geometry> <material name="black"> <color rgba="0 0 0 1"/> </material> </visual> </link> <link name="right_wheel_link"> <visual> <geometry> <cylinder length="0.05" radius="0.1"/> </geometry> <material name="black"> <color rgba="0 0 0 1"/> </material> </visual> </link> <joint name="left_wheel_joint" type="continuous"> <parent link="base_link"/> <child link="left_wheel_link"/> <origin xyz="0 0.2 -0.1" rpy="0 0 0"/> <axis xyz="0 1 0"/> </joint> <joint name="right_wheel_joint" type="continuous"> <parent link="base_link"/> <child link="right_wheel_link"/> <origin xyz="0 -0.2 -0.1" rpy="0 0 0"/> <axis xyz="0 1 0"/> </joint> </robot>
Important Notes
Always check your URDF in visualization tools like RViz to see if it looks right.
Use origin to position parts correctly relative to each other.
Continuous joints are good for wheels because they spin freely.
Summary
A URDF describes robot parts (links) and how they connect (joints).
Mobile robots usually have a base and wheels connected by continuous joints.
Visualizing your URDF helps catch mistakes early.
Practice
1. What does a URDF file primarily describe in ROS for a mobile robot?
easy
Solution
Step 1: Understand URDF purpose
A URDF (Unified Robot Description Format) file describes the physical structure of a robot, including its parts and connections.Step 2: Identify mobile robot components
Mobile robots have links (like base and wheels) connected by joints, which URDF models.Final Answer:
The robot's parts (links) and how they connect (joints) -> Option AQuick Check:
URDF = robot parts and joints [OK]
Hint: URDF = robot structure, not software or data [OK]
Common Mistakes:
- Confusing URDF with software algorithms
- Thinking URDF handles communication
- Assuming URDF manages battery or sensors
2. Which of the following is the correct syntax to define a link named
base_link in a URDF file?easy
Solution
Step 1: Recognize URDF link syntax
In URDF, links are defined with the <link> tag and a name attribute.Step 2: Check option correctness
<link name="base_link"/> uses <link name="base_link"/>, which is correct syntax. Other options use wrong tags or attributes.Final Answer:
<link name="base_link"/> -> Option AQuick Check:
Link tag uses name attribute [OK]
Hint: Links use syntax in URDF [OK]
Common Mistakes:
- Using <joint> instead of <link> for links
- Using id instead of name attribute
- Using non-existent tags like <base>
3. Given this URDF snippet for a wheel joint:
What does the
<joint name="wheel_joint" type="continuous"> <parent link="base_link"/> <child link="wheel_link"/> </joint>
What does the
type="continuous" mean for this joint?medium
Solution
Step 1: Understand joint types in URDF
URDF joint types include fixed, revolute, continuous, prismatic, etc. Continuous means unlimited rotation.Step 2: Interpret continuous joint meaning
Continuous joints rotate endlessly, suitable for wheels that spin freely.Final Answer:
The joint can rotate infinitely without limits -> Option DQuick Check:
continuous joint = infinite rotation [OK]
Hint: Continuous joint means unlimited rotation [OK]
Common Mistakes:
- Confusing continuous with fixed joint
- Thinking continuous means linear movement
- Assuming rotation limits apply
4. You wrote this URDF joint definition but your robot's wheel does not move:
What is the likely problem?
<joint name="wheel_joint" type="revolute"> <parent link="base_link"/> <child link="wheel_link"/> </joint>
What is the likely problem?
medium
Solution
Step 1: Check joint type and limits
Revolute joints require <limit> tags to define rotation range; missing limits can cause no movement.Step 2: Verify other options
Fixed joints do not move, so B is wrong. Parent/child order is correct. Underscores are allowed in names.Final Answer:
Missing <limit> tag specifying joint rotation limits -> Option BQuick Check:
Revolute joints need limits to move [OK]
Hint: Revolute joints need <limit> tags to move [OK]
Common Mistakes:
- Omitting <limit> tag for revolute joints
- Using fixed joint for moving parts
- Swapping parent and child links
- Thinking joint names can't have underscores
5. You want to build a mobile robot URDF with a base and two wheels. Which joint types and connections correctly model the wheels that spin freely?
hard
Solution
Step 1: Identify wheel joint requirements
Wheels spin freely, so joints must allow infinite rotation, which is continuous type.Step 2: Check connection direction and joint type
Parent link is base_link, child is wheel_link. Continuous joint type is correct for free spinning wheels.Step 3: Eliminate incorrect options
Fixed joints don't move. Prismatic joints slide linearly, not rotate. Revolute without limits won't move properly.Final Answer:
Use <joint type="continuous"> connecting base_link to wheel_link for both wheels -> Option CQuick Check:
Continuous joints + correct parent-child = wheels spin [OK]
Hint: Wheels need continuous joints from base to wheel [OK]
Common Mistakes:
- Using fixed joints for wheels
- Using prismatic joints for rotation
- Omitting limits on revolute joints
- Reversing parent and child links
