Introduction
The TF tree helps robots understand where things are by keeping track of all parts and sensors in space.
Jump into concepts and practice - no test required
The TF tree helps robots understand where things are by keeping track of all parts and sensors in space.
rosrun tf view_frames rosrun tf tf_echo [source_frame] [target_frame]
view_frames creates a picture of the TF tree.
tf_echo shows the transform between two frames live.
rosrun tf view_frames
rosrun tf tf_echo base_link camera_link
This Python node listens for the transform between the robot base and camera frames and prints their position and rotation every second.
#!/usr/bin/env python3 import rospy import tf rospy.init_node('tf_listener') listener = tf.TransformListener() rate = rospy.Rate(1.0) while not rospy.is_shutdown(): try: (trans, rot) = listener.lookupTransform('base_link', 'camera_link', rospy.Time(0)) print(f"Translation: {trans}") print(f"Rotation: {rot}") except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException): print("Waiting for transform...") rate.sleep()
The TF tree is like a family tree but for robot parts and sensors.
Each frame has a parent and children frames, showing how they connect.
Transforms update constantly as the robot moves.
TF tree organizes all robot parts and sensors in space.
It helps convert positions between different frames.
Use tools like view_frames and tf_echo to explore the tree.
view_frames generates a PDF showing the TF tree structure.tf_echo shows transform between two frames, not the whole tree. Other options are invalid.rosrun tf tf_echo base_link camera_link output?tf_echo shows the transform between two frames at the current time.base_link to camera_link.rosrun tf tf_echo base_link camera_link but get an error: "Lookup would require extrapolation into the future." What is the likely cause?base_link, odom, and map, which TF tree structure correctly represents their typical relationship?map is the fixed world frame, odom tracks odometry relative to map, and base_link is robot base relative to odom.map (world) -> odom -> base_link.