Robotics StackExchange | Archived questions

The relationship between tf in rviz and tf_echo is very different

When I do simulation experiments with gazebo+rviz, the relationship of each frame of tf in the rviz screen is accurate, my concern is the relationship of the coordinate transformations of wamv/odom and wamv/baselink, which is shown in rviz to be ‘[30.581, 2.674, -0.1031]’, but running in the terminal rosrun tf tfecho wamv/base_link wamv/odom gets ‘- Translation: [-27.193, 9.677, 0.484]’, especially in the Y direction.

Asked by lohwanyan on 2023-07-31 07:36:39 UTC

Comments

Hi!

Are you sure to have specified the two RF in the same order in both cases. The problem might be that on one side you are looking at the odom to base_link transformation, and on the other one you are looking base_link to odom.

The reason why I am suggesting this is that Rviz is just a visualization tool. The information that you are looking to are in the end published by tf itself in both cases (Rviz and terminal), thus it would be weird that they do not coincide.

If this is not the case, adding some more info about your situation (e.g. the Rviz visualization of the two frames) could help us have a better understanding of the problem.

Asked by bluegiraffe-sc on 2023-07-31 09:05:09 UTC

I found out where the problem was. Because the order of 'source_frame' and 'target_frame' in the command rosrun tf tf_echo wamv/base_link wamv/odom was reversed. But I understood that the reverse order should give the opposite result, but it didn't turn out to be the case.

Asked by lohwanyan on 2023-07-31 20:33:37 UTC

Glad you solved, you can post the solution as an answer to your question for future readers.

About the "the reverse order should give the opposite result", the key to understand this in the tf docs, where it says

"The relationship between two frames is represented by a 6 DOF relative pose, a translation followed by a rotation."

In your case, to go from base_link to odom you apply a translation expressed in base_link RF and then rotate. To go back, you first apply a rotation in odom RF and then rotate. The two transforms are indeed "opposite", but as they are not expressed wrt the same RF, it is not just a matter of putting a minus sign in front.

Asked by bluegiraffe-sc on 2023-08-01 02:45:18 UTC

yes,i seem know ,thanks a lot

Asked by lohwanyan on 2023-08-01 21:47:09 UTC

Answers