# How can I calculate the static transform between 2 coordinate frames?

I have a list of poses that I'm trying to publish after converting into the 'map' coordinate frame of reference. I understand that this is done with the help of tf/static_transform_publisher, however I am not sure how to determine the values of the transform.

Is there a standard method for this? Thank you!

Welcome to Robotics Stack Exchange!

How can I calculate the static transform between 2 coordinate frames?

### Using terminal

Please use tf_echo utility from tf package as shown below:

1. ROS 1: $rosrun tf tf_echo turtle1 turtle2 2. ROS 2: $ ros2 run tf2_ros tf2_echo turtle2 turtle1

### Using API inside code

Please use lookupTransform from tf package as shown below:

1. ROS 1: listener.lookupTransform("/turtle2", "/turtle1", ros::Time(0), transform);
2. ROS 2: tf_buffer_->lookupTransform(toFrameRel, fromFrameRel, tf2::TimePointZero);
• Thanks very much for your response! However, I have not yet defined the transform from "map-gt" to "map". I am unsure how to calculate the numbers to correctly transform between the 2 frames Sep 4, 2023 at 14:31
• I suggest improving your question. You said "I have a list of poses..." in your question already. You are either confused or not sharing the complete information with us.
– ravi
Sep 5, 2023 at 1:31
• Ah sorry about that. I have a list of poses in one coordinate frame, I don't yet have their equivalent in the map frame. Sep 9, 2023 at 16:20

• Probably is not suitable for the case at your hand, but the transform can be trivial. E.g. if you place a camera (RF with z forward) parallel to the ground, 10cm above a mobile base (RF with x forward), you have a translation of 10cm and a rotation of 90°, thus you can "manually" define your transform. See an example in the tf tutorial. If you fall into this scenario, thus you probably should edit your robot urdf to include the camera-to-base link, and let the robot_state_publisher do the rest.
• From your answer to ravi, I guess you are able to retrieve the pose of an object (more in general, a point) in the map-gt reference frame. You should place something in known poses in the map reference frame, assuming that you are able to locate the map origin in the real world. One option is to measure (yes, with a tape measure, a ruler, or whatever) where they are. Once you have got the same point both in map and map-gt, you can use an algorithm such as ICP (iterative closest point) to find the transform. Here some extra info about the algorithm, and here some possible Python implementations of it.