ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Difference between tf2 broadcaster and tf2 frame.

asked 2022-10-02 22:32:35 -0500

sdu568 gravatar image

Hello, I was a little confused by the concept presented in the following 2 tutorials.

https://docs.ros.org/en/humble/Tutori...

https://docs.ros.org/en/humble/Tutori...

My question is, what is the difference between the first tutorial (broadcaster) and the second tutorial (adding a frame)? I mean, it seems to me that they are all just playing with tf transforms.

Currently, what I understood is that the first tutorial (Broadcaster) modifies based on an already existing tf frame. So in this case, if somehow we have IMU that is statically transformed with base_link, we can use this method to update the IMU's axis in rviz?

And on the other hand, the second tutorial (adding a frame) adds a new frame to ROS2. So in this case, it will be we create a new frame for the IMU.

Did I understand it correctly? Please correct me if I am wrong.

Thank you very much!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-10-04 13:20:48 -0500

MarcoB gravatar image

Hi, the two examples are indeed very similar: In the first the node subscribes to to a topic and dynamically updates the published tf according to the read pose, while the second periodically publishes the same transformation using a timer.

The second example could actually be a bit misleading, if you want to publish a fixed transformation that never changes, you should use a static transform broadcaster:

https://docs.ros.org/en/humble/Tutori...

This will publish on the "latched" /tf_static topic instead of /tf, meaning that new subscribers will get the last published message without the need of continuously publishing it.

edit flag offensive delete link more

Comments

If that is the case, which example should I use if I want to add an IMU frame?

sdu568 gravatar image sdu568  ( 2022-10-04 22:15:54 -0500 )edit

Would it be the first example? Since I can subscribe to Imu/raw, and update the tf for each imu message?

Also, do you mind if you can give an real-life example of when should I use the second case? Thanks a lot!!!

sdu568 gravatar image sdu568  ( 2022-10-04 22:19:51 -0500 )edit

The imu frame represents the position of the sensor on the robot: it shouldn't change with each message provided by the sensor, but only when calibrating it. Hence the "static tf publisher" would be more adequate. If you are using the data of the imu to compute the "odometry" of your robot, then the transformation from the /odom frame to your robot should be updated and published continuously.

MarcoB gravatar image MarcoB  ( 2022-10-05 02:02:41 -0500 )edit

I see, and in that case, I will just be publishing a odometry message (http://docs.ros.org/en/noetic/api/nav...), with header_id to be odometry, and child_id to be imu?

Also, will it be correct if I use the dynamic tf transform in situations such as imu is attached to a robotic arm? Or should I still just use a static transform, and rely on the odometry message as mentioned above?

Also, I wonder if you can give me an example on when should I use a dynamic tf transform instead of a static transform? Thank you very much!

sdu568 gravatar image sdu568  ( 2022-10-05 07:44:06 -0500 )edit

You would use a dynamic tf transform to publish transformations that are not fixed, like for example the https://github.com/ros/joint_state_pu... does. The child Id of the odometry transform is usually a fixed frame on your robot, for example base_link. If you are using the information produced by the imu to compute the odometry, then it's a different story.

MarcoB gravatar image MarcoB  ( 2022-10-13 07:04:07 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-10-02 22:32:35 -0500

Seen: 328 times

Last updated: Oct 04 '22