Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a TransformBroadcaster object in ROS.
ROS
import tf broadcaster = tf.[1]()
Attempts:
3 left
💡 Hint
Common Mistakes
Using TransformListener instead of TransformBroadcaster
Confusing StaticTransformBroadcaster with TransformBroadcaster
✗ Incorrect
The TransformBroadcaster class is used to broadcast coordinate frame transforms in ROS.
2fill in blank
mediumComplete the code to fill the header frame_id for a TransformStamped message.
ROS
from geometry_msgs.msg import TransformStamped transform = TransformStamped() transform.header.[1] = 'world'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting child_frame_id instead of header.frame_id
Confusing stamp with frame_id
✗ Incorrect
The frame_id field in the header specifies the parent coordinate frame for the transform.
3fill in blank
hardFix the error in setting the translation values of the transform.
ROS
transform.transform.translation.x = [1] transform.transform.translation.y = 0.0 transform.transform.translation.z = 0.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using string '1.0' instead of float 1.0
Assigning None or boolean values
✗ Incorrect
Translation values must be floats, not strings or other types.
4fill in blank
hardFill both blanks to set the rotation as a unit quaternion representing no rotation.
ROS
transform.transform.rotation.[1] = 0.0 transform.transform.rotation.[2] = 1.0
Attempts:
3 left
💡 Hint
Common Mistakes
Setting w to 0.0 instead of 1.0
Confusing x, y, z components with w
✗ Incorrect
A unit quaternion for no rotation has x, y, z = 0.0 and w = 1.0.
5fill in blank
hardFill all three blanks to broadcast the transform with the current time and child frame id 'robot_base'.
ROS
import rospy from geometry_msgs.msg import TransformStamped transform.header.stamp = rospy.[1]() transform.header.frame_id = 'world' transform.child_frame_id = [2] broadcaster.sendTransform([3])
Attempts:
3 left
💡 Hint
Common Mistakes
Using Duration.now instead of Time.now
Passing wrong argument to sendTransform
Not quoting 'robot_base' as a string
✗ Incorrect
rospy.Time.now() gets current time, child_frame_id is 'robot_base', and sendTransform sends the transform message.
