Bird
Raised Fist0
ROSframework~10 mins

Static transforms for fixed frames in ROS - Step-by-Step Execution

Choose your learning style10 modes available

Start learning this pattern below

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
Concept Flow - Static transforms for fixed frames
Define fixed frames
Create static transform broadcaster
Set transform parameters (translation, rotation)
Broadcast transform once
Other nodes receive fixed transform
Use transform for coordinate conversions
This flow shows how a static transform is defined once and broadcasted for fixed frames, so other parts of the system can use it for coordinate conversions.
Execution Sample
ROS
import tf2_ros
from geometry_msgs.msg import TransformStamped

broadcaster = tf2_ros.StaticTransformBroadcaster()
static_transformStamped = TransformStamped()
static_transformStamped.header.frame_id = "world"
static_transformStamped.child_frame_id = "robot"
static_transformStamped.transform.translation.x = 1.0
static_transformStamped.transform.translation.y = 0.0
static_transformStamped.transform.translation.z = 0.0
static_transformStamped.transform.rotation.x = 0.0
static_transformStamped.transform.rotation.y = 0.0
static_transformStamped.transform.rotation.z = 0.0
static_transformStamped.transform.rotation.w = 1.0
broadcaster.sendTransform(static_transformStamped)
This code creates and sends a static transform from 'world' to 'robot' frame with a fixed translation and rotation.
Execution Table
StepActionVariable/Field SetValueEffect
1Import tf2_ros and geometry_msgs--Prepare to create static transform
2Create StaticTransformBroadcaster instancebroadcasterStaticTransformBroadcaster()Ready to send static transforms
3Create TransformStamped messagestatic_transformStampedTransformStamped()Empty transform message created
4Set header.frame_idstatic_transformStamped.header.frame_id"world"Parent frame set
5Set child_frame_idstatic_transformStamped.child_frame_id"robot"Child frame set
6Set translation.xstatic_transformStamped.transform.translation.x1.0Translation along x-axis set
7Set rotation.wstatic_transformStamped.transform.rotation.w1.0Rotation set to identity (no rotation)
8Call sendTransformbroadcaster.sendTransformstatic_transformStampedStatic transform broadcasted once
9Other nodes receive transform--Fixed frame relation available system-wide
10Use transform for conversions--Coordinate conversions between 'world' and 'robot' frames possible
11End--Static transform remains fixed, no updates needed
💡 Static transform broadcasted once; no further updates as frames are fixed.
Variable Tracker
VariableStartAfter Step 4After Step 5After Step 6After Step 7Final
static_transformStamped.header.frame_id''"world""world""world""world""world"
static_transformStamped.child_frame_id''''"robot""robot""robot""robot"
static_transformStamped.transform.translation.x0.00.00.01.01.01.0
static_transformStamped.transform.rotation.w0.00.00.00.01.01.0
Key Moments - 3 Insights
Why do we only call sendTransform once for static transforms?
Because static transforms represent fixed relationships that do not change over time, broadcasting once is enough for other nodes to use them continuously, as shown in execution_table step 8.
What happens if we forget to set the child_frame_id?
Without child_frame_id set (see step 5), the transform has no target frame, so other nodes cannot use it properly for coordinate conversions.
Why is rotation.w set to 1.0 and others to 0.0?
Setting rotation.w to 1.0 and x,y,z to 0.0 means no rotation (identity quaternion), which is a common default for static transforms (step 7).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 6, what value is assigned to translation.x?
A0.0
B-1.0
C1.0
DNot set
💡 Hint
Check the 'Value' column at step 6 in execution_table.
At which step is the static transform actually broadcasted?
AStep 7
BStep 8
CStep 4
DStep 10
💡 Hint
Look for the action 'sendTransform' in execution_table.
If we change child_frame_id to 'base_link', which step's value changes in variable_tracker?
AAfter Step 5
BAfter Step 4
CAfter Step 6
DAfter Step 7
💡 Hint
child_frame_id is set at step 5; check variable_tracker column 'After Step 5'.
Concept Snapshot
Static transforms define fixed frame relationships.
Use StaticTransformBroadcaster to send once.
Set header.frame_id (parent) and child_frame_id.
Set translation and rotation (quaternion).
Broadcast once; other nodes use it continuously.
No updates needed for fixed frames.
Full Transcript
Static transforms in ROS are used to define fixed relationships between coordinate frames. You create a StaticTransformBroadcaster and a TransformStamped message. You set the parent frame (header.frame_id), the child frame (child_frame_id), and the transform parameters like translation and rotation. Then you broadcast this transform once using sendTransform. Other nodes receive this fixed transform and use it for coordinate conversions. Because the frames are fixed, you do not need to update or resend the transform repeatedly. This makes static transforms efficient and simple for fixed frame relationships.

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

  1. Step 1: Understand the role of static transforms

    Static transforms are used to represent fixed relationships between frames that do not change over time.
  2. 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.
  3. Final Answer:

    To define a fixed position and orientation between two frames that do not move relative to each other -> Option B
  4. 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?
easy
A. static_transform_publisher base_link camera_link 1 0 0 0 0 0 1 100
B. static_transform_publisher 0 0 0 1 0 0 0 base_link camera_link 100
C. static_transform_publisher 1 0 0 0 0 0 1 base_link camera_link 100
D. static_transform_publisher 1 0 0 0 0 0 0 base_link camera_link 100

Solution

  1. 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.
  2. Step 2: Match values to the syntax

    Translation is (1, 0, 0), rotation quaternion is (0, 0, 0, 1) for no rotation, frames are base_link and camera_link, and period is 100 ms.
  3. Final Answer:

    static_transform_publisher 1 0 0 0 0 0 1 base_link camera_link 100 -> Option C
  4. Quick 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:
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

  1. 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.
  2. Step 2: Identify frame order

    The transform is from world frame to map frame, so map is positioned 1 meter above world.
  3. Final Answer:

    A translation of 1 meter along the Z-axis from world to map with no rotation -> Option D
  4. 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

  1. 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.
  2. Step 2: Understand effect on transform publishing

    An invalid quaternion causes the transform publisher to fail silently, so no transform appears in tf.
  3. Final Answer:

    The quaternion rotation is invalid because the w component is zero -> Option A
  4. 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?
hard
A. 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
B. static_transform_publisher 0 0 0 0 0 0 1 base_link odom 100 static_transform_publisher 0.5 0 1 0 0.7071 0 0.7071 camera_link base_link 100
C. static_transform_publisher 0 0 0 0 0 0 1 odom base_link 100 static_transform_publisher 0.5 0 1 0 1 0 0 base_link camera_link 100
D. static_transform_publisher 0 0 0 0 0 0 0 odom base_link 100 static_transform_publisher 0.5 0 1 0 0.7071 0 0.7071 base_link camera_link 100

Solution

  1. Step 1: Verify first transform from odom to base_link

    Translation is zero, no rotation quaternion is (0,0,0,1), frames ordered correctly as parent then child.
  2. Step 2: Verify second transform from base_link to camera_link

    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.
  3. Final 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 A
  4. Quick 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