-
Notifications
You must be signed in to change notification settings - Fork 1.8k
nav2_ros_common: add lifecycle-managed Subscription wrapper #5834
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
Draft
Lotusymt
wants to merge
37
commits into
ros-navigation:main
Choose a base branch
from
Lotusymt:feature/nav2_ros_common-lifecycle-interfaces-5298
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
a0d374f
nav2_ros_common: add lifecycle-managed Subscription wrapper
Lotusymt 0a73e71
modify alias
Lotusymt 9f5f9eb
fix bugs
Lotusymt 7953c21
Fix lifecycle subscription tests and add header guard
Lotusymt 5e5f949
WIP: draft subscription factory lifecycle handling (design not final)
Lotusymt ccd57ee
fix rviz
Lotusymt eff1f93
fix cpp linter
Lotusymt 84b8b45
subsscription2.0, imitating publisher
Lotusymt 216d394
fix cpp linter
Lotusymt 020eab4
cleanup
Lotusymt 7a7e7ab
Restore files to upstream/main
Lotusymt 9dd1d1b
Ignore CTest Testing/ artifacts
Lotusymt 8cb1594
revert unintended testfile changes
Lotusymt a9c12e9
update subscription
Lotusymt 7ecc46c
Clean up CMakeLists.txt by removing unused lines
Lotusymt d3839fe
Update nav2_ros_common/include/nav2_ros_common/interface_factories.hpp
Lotusymt b897c7b
Update nav2_ros_common/include/nav2_ros_common/interface_factories.hpp
Lotusymt ba3f245
Update nav2_ros_common/include/nav2_ros_common/subscription.hpp
Lotusymt 91640b9
fixes
Lotusymt 1e55192
fix param order
Lotusymt 0013d84
fix linter
Lotusymt fa7eb4c
safe logic for templated node's subscription
Lotusymt 6c01742
use handle message, bypass latched message, tests passed
Lotusymt d504958
make cloud points compatible
Lotusymt 6d54181
fix bug
Lotusymt d09c3fa
fix generate result error
Lotusymt 344fc94
nav2_ros_common: create subscription on activate, destroy on deactivate
Lotusymt 75848e8
nav2_costmap_2d, nav2_map_server: align with create-on-activate subs
Lotusymt 7e73798
nav2_costmap_2d, nav2_map_server: activate test subs after PR #5834
Lotusymt 990927f
nav2_util: break LifecycleServiceClient ctor wait loop on shutdown
Lotusymt 2e3f88b
Re-trigger CI
Lotusymt 7b91f99
Re-trigger CI (round 2)
Lotusymt 73f7ff0
Re-trigger CI (round 3)
Lotusymt d77b3c7
nav2_ros_common, nav2_costmap_2d, nav2_route: activate subs created d…
Lotusymt 36462f4
nav2_behaviors, nav2_route: activate plugin-owned and behavior Costma…
Lotusymt 25826b2
nav2_route: expand for-loop bodies to satisfy uncrustify
Lotusymt deedeee
nav2_loopback_sim: activate lifecycle subscriptions and fix unit-test…
Lotusymt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,3 +70,6 @@ Session.vim | |
|
|
||
| # Vim Temporary | ||
| .netrwhist | ||
|
|
||
| # CTest | ||
| Testing/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
nav2_collision_monitor/include/nav2_collision_monitor/lifecycle_point_cloud_subscription.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // Copyright (c) 2025 Angsa Robotics | ||
| // Copyright (c) 2025 lotusymt | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef NAV2_COLLISION_MONITOR__LIFECYCLE_POINT_CLOUD_SUBSCRIPTION_HPP_ | ||
| #define NAV2_COLLISION_MONITOR__LIFECYCLE_POINT_CLOUD_SUBSCRIPTION_HPP_ | ||
|
|
||
| #include <functional> | ||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "rclcpp_lifecycle/lifecycle_node.hpp" | ||
| #include "sensor_msgs/msg/point_cloud2.hpp" | ||
| #include "point_cloud_transport/point_cloud_transport.hpp" | ||
|
|
||
| namespace nav2_collision_monitor | ||
| { | ||
|
|
||
| /** | ||
| * @brief Lifecycle-managed subscription that wraps point_cloud_transport::Subscriber. | ||
| * | ||
| * Gates message delivery on activation state (on_activate/on_deactivate), so it can be | ||
| * used like nav2::Subscription when using point_cloud_transport for transport hints. | ||
| */ | ||
| class LifecyclePointCloudSubscription : public rclcpp_lifecycle::SimpleManagedEntity | ||
| { | ||
| public: | ||
| RCLCPP_SMART_PTR_DEFINITIONS(LifecyclePointCloudSubscription) | ||
|
|
||
| using Callback = std::function<void(sensor_msgs::msg::PointCloud2::ConstSharedPtr)>; | ||
|
|
||
| /** | ||
| * @brief Construct and create the PointCloudTransport. | ||
| * @param node Lifecycle node shared pointer (PointCloudTransport requires Node::SharedPtr on ROS 2 Jazzy). | ||
| */ | ||
| explicit LifecyclePointCloudSubscription( | ||
| rclcpp_lifecycle::LifecycleNode::SharedPtr node); | ||
|
|
||
| ~LifecyclePointCloudSubscription(); | ||
|
|
||
| /** | ||
| * @brief Subscribe to a topic with transport hints; callback is only invoked when activated. | ||
| * @param topic Topic name | ||
| * @param qos QoS profile | ||
| * @param callback User callback (invoked only when this entity is activated) | ||
| * @param transport_hints Transport hints for point_cloud_transport | ||
| */ | ||
| void subscribe( | ||
| const std::string & topic, | ||
| const rclcpp::QoS & qos, | ||
| Callback callback, | ||
| const point_cloud_transport::TransportHints & transport_hints); | ||
|
|
||
| void on_activate() override; | ||
| void on_deactivate() override; | ||
|
|
||
| /** @brief Unsubscribe and release the underlying subscriber. */ | ||
| void shutdown(); | ||
|
|
||
| private: | ||
| std::shared_ptr<rclcpp_lifecycle::LifecycleNode> node_; | ||
| std::shared_ptr<point_cloud_transport::PointCloudTransport> pct_; | ||
| point_cloud_transport::Subscriber data_sub_; | ||
| }; | ||
|
|
||
| } // namespace nav2_collision_monitor | ||
|
|
||
| #endif // NAV2_COLLISION_MONITOR__LIFECYCLE_POINT_CLOUD_SUBSCRIPTION_HPP_ | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why this specialization?