Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a TransformListener in ROS.
ROS
listener = tf2_ros.[1]()Attempts:
3 left
💡 Hint
Common Mistakes
Using TransformBroadcaster instead of TransformListener
Confusing Buffer with Listener
✗ Incorrect
The TransformListener listens to the TF tree and receives transform data.
2fill in blank
mediumComplete the code to lookup a transform from 'base_link' to 'camera_link'.
ROS
transform = tf_buffer.lookup_transform('base_link', [1], rospy.Time())
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping source and target frames
Using 'base_link' twice
✗ Incorrect
You want to get the transform from 'base_link' to 'camera_link', so the target frame is 'camera_link'.
3fill in blank
hardFix the error in the code to correctly broadcast a static transform.
ROS
static_broadcaster = tf2_ros.[1]()
static_broadcaster.sendTransform(transform_stamped)Attempts:
3 left
💡 Hint
Common Mistakes
Using TransformListener instead of broadcaster
Using TransformBroadcaster for static transforms
✗ Incorrect
StaticTransformBroadcaster is used to send static transforms that do not change over time.
4fill in blank
hardFill both blanks to create a transform stamped message with correct header and child frame.
ROS
transform_stamped.header.frame_id = [1] transform_stamped.child_frame_id = [2]
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping parent and child frames
Using the same frame for both
✗ Incorrect
The header frame_id is usually the parent frame like 'world', and child_frame_id is the frame being defined like 'camera_link'.
5fill in blank
hardFill all three blanks to create a dictionary comprehension that maps frame names to their parent frames from a TF tree.
ROS
frame_parents = {frame: [1] for frame, [2] in tf_tree.items() if frame != [3]Attempts:
3 left
💡 Hint
Common Mistakes
Using 'child' instead of 'parent'
Not excluding the root frame
✗ Incorrect
In the TF tree dictionary, each frame maps to its parent. We skip the 'world' frame as it has no parent.
