Transform coordinates from one frame to another


How can you obtain the coordinates of a point with respect to another reference system using a TF Listener to obtain the transformation between both frames?
Is there a function that performs this conversion?


José Enrique.

Yes, you can do
ros2 run tf2_ros tf2_echo source_frame target_frame [echo_rate]
on the terminal or create a TF listener in a script with the function
tf_listener = TransformListener(tf_buffer)

I am quite confident that this process is explained in the course, you can follow those instructions when you run into them.

Yes, I know that I can use tf_echo or TransformListener to get the transform between two frames.
But, once I have the transformation, if x,y,z are the coordinates of a point with respect to one of the frames, how do I apply the transformation to get the coordinates with respect to the other?


José Enrique.

Well, you can access the transform x, y an z fields when listening to the transform of a TF with respect to another TF.

If you then have a separate point, and you know its position with respect to one of those TFs, then you can simply do some trigonometry to find the coordinates with respect to the other TF. So it’s a triangle, you know two sides (TF1-TF2, point-TF1) so find point-TF2. Is this what you are asking?

Yes, that is what I am asking.
But, is there a function that calculates the rotation and translation matrix to convert the coordinates from one frame to another without having to do the trigonometric calculations yourself?
Because if there are rotations in the three axes between the two frames, the trigonometric calculation is quite cumbersome.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.

Hi, sorry for the late reply.

I guess I still don’t understand your question. If it’s a point, then how can it have rotations?

If you have instead an axis, you can figure out a way to actually publish a TF instead, and just do another echo