ROS 2 Lyrical lab 07 ยท 2 hours
tf2, URDF and xacro
Describe a small arm, publish its state and verify every coordinate frame.
Before you start
- Lab 06 complete
- Radians and coordinate frames
Files you will touch
src/training_arm_description/urdf/training_arm.urdf.xacrosrc/training_arm_description/launch/display.launch.py
Step 1
Set up
sudo apt install ros-lyrical-tf2-tools ros-lyrical-robot-state-publisher ros-lyrical-joint-state-publisher-gui ros-lyrical-rviz2Step 2
Create the file
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="training_arm">
<link name="base_link"/>
<link name="tool0"/>
<joint name="tool_joint" type="fixed">
<parent link="base_link"/><child link="tool0"/>
<origin xyz="0 0 0.5" rpy="0 0 0"/>
</joint>
</robot>Step 3
Build, run and inspect
ros2 launch training_arm_description display.launch.py
ros2 run tf2_ros tf2_echo base_link tool0
ros2 run tf2_tools view_framesProof that it works
- RViz shows the model without TF errors
- tf2_echo reports the 0.5 m transform
- view_frames creates a connected frame tree
Recovery notes
- Every non-root link must have exactly one parent joint.
- Use SI units: metres, kilograms, seconds and radians.