ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Looks that i figured out how to solve the problem by having a look at the source code of tf2_ros: http://docs.ros.org/en/latest/api/tf2_ros/html/c++/transform__listener_8h_source.html
There are two constructors of TransformListener, one of them initialises the node_ momber and the other does not. This means that in the short constructor the member node_ is initialised by the default node constructor.
Which means that I have to run the constructor this way:
tf_listener_ = std::make_shared<tf2_ros::TransformListener>(
* tf_buffer_ // buffer
, std::make_shared<Node>("my_listener") // node
, true // spin_thread
, qos // quality of services structure
);
Which is kind of logical, because as the listener is executed as a separate thread, it should be set up as a ROS Node, and so it is the developer's responsibility to specify its name to avoid creating two nodes with duplicate names.
I wish this was explained in the documentation !
I still don't understand how the short constructor of TransformListener works in ROS2, where there is no Node constructor without arguments. Must be a sort of a miracle. May be the binaries for tf2_ros for RoS1 (which contain this argumentless constructor) are implicated ?
2 | No.2 Revision |
Looks that i figured out how to solve the problem by having a look at the source code of tf2_ros: http://docs.ros.org/en/latest/api/tf2_ros/html/c++/transform__listener_8h_source.html
There are two constructors of TransformListener, one of them initialises the node_ momber and the other does not. This means that in the short constructor the member node_ is initialised by the default node constructor.
Which means that I have to run the constructor this way:
tf_listener_ = std::make_shared<tf2_ros::TransformListener>(
* tf_buffer_ // buffer
, std::make_shared<Node>("my_listener") // node
, true // spin_thread
, qos // quality of services structure
);
Which is kind of logical, because as the listener is executed as a separate thread, it should be set up as a ROS Node, and so it is the developer's responsibility to specify its name to avoid creating two nodes with duplicate names.
I wish this was explained in the documentation !
I still don't understand how the short constructor of TransformListener works in ROS2, where
there is no Node constructor without arguments. Must be a sort of a miracle. May be the binaries
for tf2_ros compiled for RoS1 (which a different distribution, which contain this argumentless constructor) constructor, are implicated ?