Ubuntu Linux for Robotics · Lesson 54 of 96
URDF
Writing a robot description and checking it with the Ubuntu tools.
Estimated time · 60–90 min
Learning goals
What you will understand
- Explain urdf in your own words
- Use it in a small workstation example
- Verify the result instead of assuming it worked
Understand the idea first
The mental model
URDF is an XML file that describes a robot's links (rigid bodies) and joints (how they move). Install the checking tools with sudo apt install liburdfdom-tools and validate a file with check_urdf robot.urdf. urdf_to_graphviz draws the link and joint tree as a PDF.
Use metres and radians, one root link, and give every movable joint a limit. Keep the description in its own package (robot_description) with urdf/, meshes/ and launch/ folders, and install them from CMake so other packages can find the files with package:// paths.
Guided lesson
Work through these steps
- 1.
Open a terminal and record the current state before changing anything.
- 2.
Read the urdf commands and predict what each one does.
- 3.
Run the commands one at a time and compare each output with your prediction.
- 4.
Write the commands that worked in a setup note you can repeat later.
Worked example
Read it before you run it
sudo apt install liburdfdom-tools
# Install check_urdf and urdf_to_graphviz.
check_urdf mini_arm.urdf
# Validate the file and print the link tree.
urdf_to_graphviz mini_arm.urdf
# Draw the tree into mini_arm.pdf.
xdg-open mini_arm.pdf
# Open the drawing.
ros2 launch urdf_tutorial display.launch.py model:=mini_arm.urdf
# View the robot in RViz2 with joint sliders.What the example is doing
- 1.Lines without sudo only inspect or change files you own; sudo authorizes a system-wide change.
- 2.Read command output before moving to the next line. Stop if names, versions, disks, or paths differ from the lesson.
- 3.Comments beginning with # explain safety checks and are not executed by the shell.
Watch it run · Robot arm
See what this code does
The terminal types this lesson's practice solution and runs it. The scene shows the kind of robot behaviour that code drives. It plays by itself and loops.
Demo for URDF. Expected result: robot name is: mini_arm
Practice code
Now type it yourself
Open a terminal, run the starter line by line (or save it as practice.sh and run bash practice.sh), and replace every TODO with your own command.
# TODO: validate mini_arm.urdf with check_urdfExpected output
robot name is: mini_armStuck? Show the full solution (try it yourself first)
check_urdf mini_arm.urdfExpected result
How you know it worked
- Each command completes without an unexplained error.
- Your notes contain the command, the important output, and what it proves.
Practical exercise
Apply the lesson
Write a URDF for a two-link arm, validate it with check_urdf, draw its tree, and view it in RViz2 with the joint sliders.
Before you continue
- You recorded the starting state
- Every command and output is understood
- The change can be repeated from your notes
If something goes wrong
Check ownership and permissions first. Do not add sudo unless the command changes a documented system location.
Check spelling, Ubuntu version, enabled repositories, and whether the previous installation command succeeded.