Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Static transforms for fixed frames
📖 Scenario: You are working on a robot that has a fixed sensor mounted on its base. To help the robot understand where the sensor is relative to its base, you need to create a static transform. This transform will not change over time because the sensor is fixed in place.
🎯 Goal: Create a ROS static transform publisher node that broadcasts the fixed position and orientation of the sensor frame relative to the robot base frame.
📋 What You'll Learn
Create a ROS node that publishes a static transform
Use the static_transform_publisher from tf2_ros
Set the translation to x=0.5, y=0.0, z=0.2
Set the rotation as a quaternion x=0.0, y=0.0, z=0.0, w=1.0
Set the parent frame as base_link and child frame as sensor_link
💡 Why This Matters
🌍 Real World
Robots often have sensors or parts fixed in place relative to their base. Static transforms help the robot understand where these parts are in space.
💼 Career
Knowing how to publish static transforms is essential for robot developers working with ROS to integrate sensors and coordinate frames correctly.
Progress0 / 4 steps
1
Create the ROS node script
Create a Python script named static_tf_publisher.py and import rclpy and StaticTransformBroadcaster from tf2_ros. Initialize the ROS node with the name static_tf_publisher.
ROS
Hint
Use import rclpy and from tf2_ros.static_transform_broadcaster import StaticTransformBroadcaster. Then call rclpy.init() and create a node with Node('static_tf_publisher').
2
Create the static transform message
Create a geometry_msgs.msg.TransformStamped message named static_transformStamped. Set its header.frame_id to base_link and child_frame_id to sensor_link. Set the translation to x=0.5, y=0.0, z=0.2 and rotation quaternion to x=0.0, y=0.0, z=0.0, w=1.0.
ROS
Hint
Import geometry_msgs.msg. Create static_transformStamped as geometry_msgs.msg.TransformStamped(). Set header.frame_id and child_frame_id. Then set translation and rotation values.
3
Publish the static transform
Create a StaticTransformBroadcaster instance named broadcaster using the node. Use broadcaster.sendTransform() to send a list containing static_transformStamped.
ROS
Hint
Create broadcaster as StaticTransformBroadcaster(node). Then call broadcaster.sendTransform() with a list containing static_transformStamped.
4
Keep the node alive
Add rclpy.spin(node) to keep the node running and then call rclpy.shutdown() after spinning.
ROS
Hint
Use rclpy.spin(node) to keep the node alive and rclpy.shutdown() to clean up after.
Practice
(1/5)
1. What is the main purpose of using static_transform_publisher in ROS?
easy
A. To dynamically update the position of a robot part during movement
B. To define a fixed position and orientation between two frames that do not move relative to each other
C. To visualize sensor data in RViz
D. To launch multiple ROS nodes simultaneously
Solution
Step 1: Understand the role of static transforms
Static transforms are used to represent fixed relationships between frames that do not change over time.
Step 2: Identify the function of static_transform_publisher
This command publishes a fixed transform between two frames, meaning the position and orientation remain constant.
Final Answer:
To define a fixed position and orientation between two frames that do not move relative to each other -> Option B
Quick Check:
Static transform = fixed frame relation [OK]
Hint: Static transforms fix frame relations that never change [OK]
Common Mistakes:
Confusing static with dynamic transforms
Thinking it updates during robot movement
Mixing it up with sensor data visualization
2. Which of the following is the correct syntax to publish a static transform from frame base_link to camera_link with translation (1, 0, 0) and no rotation using static_transform_publisher?
Correct argument order and values = static_transform_publisher 1 0 0 0 0 0 1 base_link camera_link 100 [OK]
Hint: Remember translation then quaternion then frames [OK]
Common Mistakes:
Swapping frame order
Incorrect quaternion values for no rotation
Placing frames before numbers
3. Given the command: static_transform_publisher 0 0 1 0 0 0 1 world map 50 What does this static transform represent?
medium
A. A translation of 1 meter along the Y-axis from world to map with 180 degrees rotation
B. A translation of 1 meter along the X-axis from map to world with no rotation
C. A rotation of 1 radian around the Z-axis between world and map
D. A translation of 1 meter along the Z-axis from world to map with no rotation
Solution
Step 1: Analyze translation and rotation values
Translation is (0, 0, 1), meaning 1 meter along Z-axis. Quaternion (0, 0, 0, 1) means no rotation.
Step 2: Identify frame order
The transform is from world frame to map frame, so map is positioned 1 meter above world.
Final Answer:
A translation of 1 meter along the Z-axis from world to map with no rotation -> Option D
Quick Check:
Translation Z=1, no rotation, world to map [OK]
Hint: Check translation vector and quaternion carefully [OK]
Common Mistakes:
Mixing up frame order
Misreading quaternion as rotation angle
Confusing axis directions
4. You run the command: static_transform_publisher 0 0 0 0 0 0 0 base_link camera_link 100 but no transform appears in tf. What is the likely problem?
medium
A. The quaternion rotation is invalid because the w component is zero
B. The translation values are all zero, so no transform is published
C. The frame names are reversed; camera_link should be first
D. The period 100 is too short to publish the transform
Solution
Step 1: Check quaternion validity
A quaternion must be normalized; here (0,0,0,0) is invalid. The w component cannot be zero for a valid rotation.
Step 2: Understand effect on transform publishing
An invalid quaternion causes the transform publisher to fail silently, so no transform appears in tf.
Final Answer:
The quaternion rotation is invalid because the w component is zero -> Option A
Quick Check:
Quaternion w=0 invalid = no transform [OK]
Hint: Quaternion w must not be zero for valid rotation [OK]
Common Mistakes:
Assuming zero translation means no transform
Swapping frame order without checking syntax
Thinking publish period affects visibility immediately
5. You want to create a static transform tree where base_link is fixed to odom with translation (0, 0, 0) and no rotation, and camera_link is fixed to base_link with translation (0.5, 0, 1) and a 90-degree rotation around the Y-axis. Which two commands correctly publish these static transforms?