ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You are right about the NodeHandle in StaticTransformBroadcaster https://github.com/ros/geometry2/blob/melodic-devel/tf2_ros/include/tf2_ros/static_transform_broadcaster.h#L65
You should put the subscriber and the static broadcaster inside a class and construct that after ros::init(), and pass it around as needed instead of the globals if other objects need to use it.
Or if you insist then don't use StaticTransformBroadcaster, instead have a global ros publisher publish tf2_msgs::TFMessage
as needed. The broadcaster isn't doing a whole lot as you can see in https://github.com/ros/geometry2/blob/melodic-devel/tf2_ros/src/static_transform_broadcaster.cpp - it doesn't take much to duplicate the functionality.
2 | No.2 Revision |
You are right about the NodeHandle in StaticTransformBroadcaster https://github.com/ros/geometry2/blob/melodic-devel/tf2_ros/include/tf2_ros/static_transform_broadcaster.h#L65
You should put the subscriber and the static broadcaster inside a class and construct that after ros::init(), and pass it around as needed instead of the globals if other objects need to use it.
Or if you insist then don't use StaticTransformBroadcaster, instead have a global ros publisher publish tf2_msgs::TFMessage
as needed. The broadcaster isn't doing a whole lot as you can see in https://github.com/ros/geometry2/blob/melodic-devel/tf2_ros/src/static_transform_broadcaster.cpp - it doesn't take much to duplicate the functionality.
Or make static_broadcaster a pointer and again wait until after ros::init to create it.