tf broadcaster every frame?
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"));