Rosanswers logo

Hello again,

I am not sure if this is possible but is there anyway to transform from child to parent instead of parent to child?

I would like to transform with the hierarchy /odom -> /base_link but when the transform happen I want the base_link to move not the odom.

Thanks in advance!

EDIT: To clear confusion. The full tree should look like /earth -> /map -> /odom -> /base_link -> (sensors). The transformation that I am aiming to make is /odom -> /base_link where /base_link is the one that is supposed to be moving. All this without manually fixing /odom in place with a transformation using /map -> /odom since that transform is currently supposed to be published by the NDT algorithm.

I am aware that this is confusing, I didn't want it to be like this either....

Originally posted by anguyen9630 on ROS Answers with karma: 23 on 2021-09-20

Post score: 1


1 Answer 1


Rosanswers logo

Edit: answering about adding an additional transform.

The transform structure is required to be a directed tree structure with no loops or cycles. I am not clear on exactly what you are wanting to do but I think that you're getting confused about position in the tree versus value.

To start off with. There's no such thing as a "fixed frame" in the tree. Every transform is relative. When you are viewing it or querying the tree you can pick your "fixed frame" for your context. But that does not change the tree at all.

If you have the base -> odom transform that is the same as the inverse of the odom -> base transform. Or vice versa, and you can publish that result just by using the inverse value and reversing the parent child values. But because you're getting a loop it suggests that you already have a value for that transform.

If you have two sources of information for estimating the transform from base_link to odom. You will need to create an estimator which will consume both sources of information for that transform and then create the fused estimate. This is how things like wheel odometry are fused with visual odometry etc. You likely want to leverage that framework.

There's lots of resources on this.

How to attach things as leaves: https://answers.ros.org/question/207148/problem-with-tf-tree-robot_pose_ekf-odom_combined/

Tree structure: https://answers.ros.org/question/190072/about-tf-transformations-between-odom-and-base_footprint/

robot_pose_ekf: http://wiki.ros.org/robot_pose_ekf

Previous answer about how to evaluate transforms.

Yes. All transforms are relative to other elements in the tree.

You can ask tf for any transfrom to take data from the source_frame to the target_frame Where the logic is that source_frame is the frame in which the data is initially represented, and target_frame is the one that you want it represented in afterwards.

The relationship of the frames in the internal tf tree representation does not matter.

If you're asking about how to view things in rviz or similar such that the base_link is fixed. Use the setting "Fixed Frame".

Originally posted by tfoote with karma: 58457 on 2021-09-20

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by anguyen9630 on 2021-09-20:
The question is more because of the rigidity of the hierarchy. I've just made an edit which gives you a more solid understanding of the tree. So the /map would be the fixed frame, neither the /odom nor the /base_link is fixed.

If I understood your answer correctly, I would first just give a transformation to say that the /odom frame is positioned higher up on the tree in relation to /base_link. After that is established, I would publish transformation from /base_link as source and /odom as the target_frame, correct?

Comment by anguyen9630 on 2021-09-20:
@tfoote I think I understood you wrong since I am getting this message:

[p2d_ndt_localizer_exe-12] [ERROR] [1632173087.907642348] [localization.p2d_ndt_localizer_node]: The tf tree is invalid because it contains a loop. [p2d_ndt_localizer_exe-12] Frame camera exists with parent base_link.
[p2d_ndt_localizer_exe-12] Frame base_link exists with parent odom.
[p2d_ndt_localizer_exe-12] Frame gnss exists with parent base_link.
[p2d_ndt_localizer_exe-12] Frame imu exists with parent base_link.
[p2d_ndt_localizer_exe-12] Frame lidar_front exists with parent base_link.
[p2d_ndt_localizer_exe-12] Frame lidar_rear exists with parent base_link.
[p2d_ndt_localizer_exe-12] Frame nav_base exists with parent base_link.
[p2d_ndt_localizer_exe-12] Frame map exists with parent earth.
[p2d_ndt_localizer_exe-12] Frame odom exists with parent base_link.

Comment by tfoote on 2021-09-20:
Oh, you're trying to add a frame to the transform tree not evaluate or apply a transform. I'm editing my answer above.

Comment by anguyen9630 on 2021-09-21:
Hmmm, I've heard about publishing as a reverse with /base_link as source and /odom as child but I've probably implemented it wrong because I get this error....

[rviz2-15] [INFO] [1632209690.552025004] [rviz2]: Message Filter dropping message: frame 'base_link' at time 0.000 for reason 'Unknown'

I'll definitely read on the robot_pose_ekf though. Sad that it is for the older ROS.

Comment by tfoote on 2021-09-21:
If you're looking for odometry in ROS 2 there's good documentation in the navigation 2 project: https://navigation.ros.org/setup_guides/odom/setup_odom.html

Comment by anguyen9630 on 2021-09-22:
Thanks, this link is really helpful!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.