use node interfaces throughout tf2_ros#108
Conversation
In the TransformListener class, use node interfaces instead of using the node directly so that the code works with either rclcpp::Node or rclcpp_lifecycle::LifecycleNode. Retain the existing node-based interface for backwards compatibility.
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
87c25e2 to
48dedcf
Compare
ec68a93 to
ff4e97b
Compare
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
ff4e97b to
68d5597
Compare
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
| rclcpp::PublisherOptionsWithAllocator<AllocatorT>()) | ||
| { | ||
| auto qos = rclcpp::QoS(rclcpp::KeepLast(100)); | ||
| // TODO(tfoote) latched equivalent |
There was a problem hiding this comment.
Make it latched or leave the TODO. @tfoote do you have any input?
There was a problem hiding this comment.
just for completeness: rclcpp::QoS(rclcpp::KeepLast(100)) is not the same as rclcpp::QoS(100)? Should be default to keep last then?
There was a problem hiding this comment.
Also, at least restore the TODO until @tfoote can respond.
|
|
||
| void init_tf_broadcaster() | ||
| { | ||
| tf_broadcaster_ = std::make_shared<tf2_ros::StaticTransformBroadcaster>(shared_from_this()); |
There was a problem hiding this comment.
Can you not pass this here? and therefore do it in the constructor?
There was a problem hiding this comment.
the reason why I do this specific test is that the original version with std::forward<NodeT>(node) failed when passing in a shared pointer to node.
see here:
15:41:38 from /home/jenkins-agent/workspace/ci_linux/ws/src/ros2/rviz/rviz_default_plugins/test/rviz_default_plugins/displays/odometry/odometry_display_visual_test.cpp:37:
15:41:38 /home/jenkins-agent/workspace/ci_linux/ws/install/tf2_ros/include/tf2_ros/transform_broadcaster.h:58:68: error: cannot bind non-const lvalue reference of type ‘std::shared_ptr<rclcpp::Node>&’ to an rvalue of type ‘std::shared_ptr<rclcpp::Node>’
15:41:38 publisher_ = rclcpp::create_publisher<tf2_msgs::msg::TFMessage>(
15:41:38 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
15:41:38 std::forward<NodeT>(node), "/tf", qos, options);
So this test is mimicking the behavior applied in the rviz default plugin.
There was a problem hiding this comment.
I mean why not pass this (or *this), not shared_from_this(). rclcpp::create_publisher<>(*this, ...) should work I think.
We can follow up on that later, but otherwise this code would not work:
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
wjwwood
left a comment
There was a problem hiding this comment.
lgtm, for merge as-is. There was a follow up that would be interesting to test, but it can come later.
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
this PR is based on #100 and rebased on top of current ros2 master.
It is using the node interfaces consistently throughout the
static_transform_broadcaster,transform_broadcasterandtransform_listener.this should fix, provide solutions for lifecycle nodes. See #94 and #70