Ask Your Question
1

Child to parent tf2 transform (c++)

asked 2021-09-20 09:31:12 -0600

anguyen9630 gravatar image

updated 2021-09-20 14:41:49 -0600

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....

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-09-20 13:34:17 -0600

tfoote gravatar image

updated 2021-09-20 17:33:28 -0600

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/2071...

Tree structure: https://answers.ros.org/question/1900...

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".

edit flag offensive delete link more

Comments

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?

anguyen9630 gravatar image anguyen9630  ( 2021-09-20 14:33:54 -0600 )edit

@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.

anguyen9630 gravatar image anguyen9630  ( 2021-09-20 16:33:51 -0600 )edit

Oh, you're trying to add a frame to the transform tree not evaluate or apply a transform. I'm editing my answer above.

tfoote gravatar image tfoote  ( 2021-09-20 17:20:07 -0600 )edit

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.

anguyen9630 gravatar image anguyen9630  ( 2021-09-21 02:37:20 -0600 )edit
1

If you're looking for odometry in ROS 2 there's good documentation in the navigation 2 project: https://navigation.ros.org/setup_guid...

tfoote gravatar image tfoote  ( 2021-09-21 03:06:45 -0600 )edit

Thanks, this link is really helpful!

anguyen9630 gravatar image anguyen9630  ( 2021-09-22 05:24:53 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

Asked: 2021-09-20 09:31:12 -0600

Seen: 61 times

Last updated: Sep 20