Static transforms let you tell your robot how parts are connected when they don't move. This helps the robot understand where things are in space.
Static transforms for fixed frames in ROS
Start learning this pattern below
Jump into concepts and practice - no test required
or
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Syntax
ROS
ros2 run tf2_ros static_transform_publisher x y z qx qy qz qw frame_id child_frame_id
x, y, z are the translation values in meters.
qx, qy, qz, qw are the quaternion values representing rotation.
Examples
base_link and camera_link.ROS
ros2 run tf2_ros static_transform_publisher 0 0 0 0 0 0 1 base_link camera_link
laser_frame is 0.1 meters in front of base_link with no rotation.ROS
ros2 run tf2_ros static_transform_publisher 0.1 0 0 0 0 0 1 base_link laser_frame
Sample Program
This command publishes a static transform where sensor_frame is 0.2 meters forward and 0.5 meters up from base_link with no rotation.
ROS
# Run this command in your terminal to publish a static transform ros2 run tf2_ros static_transform_publisher 0.2 0.0 0.5 0 0 0 1 base_link sensor_frame
Important Notes
Static transforms are for parts that never move relative to each other.
Use quaternions for rotation to avoid problems like gimbal lock.
You can run multiple static transform publishers for different fixed frames.
Summary
Static transforms define fixed positions and rotations between frames.
They help the robot understand how sensors and parts are connected.
Use the static_transform_publisher command with translation and quaternion rotation values.
Practice
1. What is the main purpose of using
static_transform_publisher in ROS?easy
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
This command publishes a fixed transform between two frames, meaning the position and orientation remain constant.static_transform_publisherFinal Answer:
To define a fixed position and orientation between two frames that do not move relative to each other -> Option BQuick 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?easy
Solution
Step 1: Recall the static_transform_publisher argument order
The syntax is:static_transform_publisher x y z qx qy qz qw frame_id child_frame_id period_in_ms.Step 2: Match values to the syntax
Translation is (1, 0, 0), rotation quaternion is (0, 0, 0, 1) for no rotation, frames arebase_linkandcamera_link, and period is 100 ms.Final Answer:
static_transform_publisher 1 0 0 0 0 0 1 base_link camera_link 100 -> Option CQuick Check:
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:
What does this static transform represent?
static_transform_publisher 0 0 1 0 0 0 1 world map 50What does this static transform represent?
medium
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 fromworldframe tomapframe, somapis positioned 1 meter aboveworld.Final Answer:
A translation of 1 meter along the Z-axis fromworldtomapwith no rotation -> Option DQuick 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:
but no transform appears in
static_transform_publisher 0 0 0 0 0 0 0 base_link camera_link 100but no transform appears in
tf. What is the likely problem?medium
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 intf.Final Answer:
The quaternion rotation is invalid because the w component is zero -> Option AQuick 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?hard
Solution
Step 1: Verify first transform from
Translation is zero, no rotation quaternion is (0,0,0,1), frames ordered correctly as parent then child.odomtobase_linkStep 2: Verify second transform from
Translation is (0.5,0,1). A 90-degree rotation around Y-axis quaternion is approximately (0, 0.7071, 0, 0.7071). Frames ordered correctly.base_linktocamera_linkFinal Answer:
static_transform_publisher 0 0 0 0 0 0 1 odom base_link 100 static_transform_publisher 0.5 0 1 0 0.7071 0 0.7071 base_link camera_link 100 -> Option AQuick Check:
Correct quaternions and frame order = static_transform_publisher 0 0 0 0 0 0 1 odom base_link 100 static_transform_publisher 0.5 0 1 0 0.7071 0 0.7071 base_link camera_link 100 [OK]
Hint: Check quaternion for 90° Y rotation and frame order carefully [OK]
Common Mistakes:
- Swapping parent and child frames
- Using wrong quaternion for rotation
- Setting quaternion w to zero
