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

tf broadcaster every frame?

asked 2016-06-23 10:12:18 -0600

uwleahcim gravatar image

I have a node that reads data from my robot, so I have the node also broadcast tf frames. Now my robot has multiple joints and thus frames. Should I declare a separate tf::TransformBroadcaster in my code for each frame or just reuse one tf::TransformBroadcaster. If both methods work, which one is the better programming practice?

Example

tf::TransformBroadcaster frame1__broadcaster;
tf::TransformBroadcaster frame2__broadcaster;
tf::TransformBroadcaster frame3__broadcaster;
...
frame1_broadcaster.sendTransform(tf::StampedTransform(transform, current_time, "base_link", "frame1"));
frame2_broadcaster.sendTransform(tf::StampedTransform(transform, current_time, "base_link", "frame2"));
frame3_broadcaster.sendTransform(tf::StampedTransform(transform, current_time, "base_link", "frame3"));

Or can I just reuse the same tf::TransformBroadcaster to publish transformations for multiple frames like this

tf::TransformBroadcaster frame__broadcaster;
...
frame_broadcaster.sendTransform(tf::StampedTransform(transform, current_time, "base_link", "frame1"));
frame_broadcaster.sendTransform(tf::StampedTransform(transform, current_time, "base_link", "frame2"));
frame_broadcaster.sendTransform(tf::StampedTransform(transform, current_time, "base_link", "frame3"));
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-06-23 10:47:33 -0600

It is very common to use the second setup, and that's what I would recommend. However, the first should work just fine. Presumably there is a small performance hit for running the constructor for each broadcaster, and slightly increased memory usage.

As another note, if you are trying to broadcast frames at joints of robots, you should likely be building a URDF and sending joint states. Then the robot_state_publisher can be used to automatically send the tf information.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-06-23 10:12:18 -0600

Seen: 1,450 times

Last updated: Jun 23 '16