-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
87c25e2
to
48dedcf
Compare
ec68a93
to
ff4e97b
Compare
Signed-off-by: Karsten Knese <[email protected]>
ff4e97b
to
68d5597
Compare
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
{ | ||
auto qos = rclcpp::QoS(rclcpp::KeepLast(100)); | ||
// TODO(tfoote) latched equivalent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it latched or leave the TODO. @tfoote do you have any input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you not pass this
here? and therefore do it in the constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
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_broadcaster
andtransform_listener
.this should fix, provide solutions for lifecycle nodes. See #94 and #70