-
Notifications
You must be signed in to change notification settings - Fork 1.8k
CM/CD: Add polygon source #3885
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
Closed
tonynajjar
wants to merge
38
commits into
ros-navigation:main
from
logivations:add-polygon-source-main
Closed
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
a68c971
Merge remote-tracking branch 'upstream/main'
a5f870c
Merge branch 'ros-planning:main' into main
tonynajjar 1e673c7
Merge branch 'ros-planning:main' into main
tonynajjar 79aff93
Merge remote-tracking branch 'upstream/main'
0dd0492
Merge branch 'ros-planning:main' into main
tonynajjar c598634
Merge branch 'ros-planning:main' into main
tonynajjar 5f8281e
Rename PushRosNamespace to PushROSNamespace
212bbbd
Fix min_points checking
4bce8ea
Merge branch 'ros-planning:main' into main
tonynajjar d00acc3
Merge branch 'ros-planning:main' into main
tonynajjar f91f3b3
Merge branch 'ros-planning:main' into main
tonynajjar 4b0bd57
Merge branch 'ros-planning:main' into main
tonynajjar c46e3a8
Add polygon source
6cf964f
Revert "Merge branch 'add-collision-points-debug' into add-polygon-so…
a5087b0
.
fc08f37
fix
d2087a2
fix
c93ff74
fix lint
0802fd7
PR comments fixes
3422dec
fixes
cce30dc
add test
f3358f2
Merge branch 'main' into add-polygon-source-main
c56ce42
Merge remote-tracking branch 'upstream/main'
f86b641
fix space
a5e95c5
use standard msg Polygonstamped
9fec3ac
Merge branch 'ros-planning:main' into main
tonynajjar b6ea8c6
Merge remote-tracking branch 'origin/HEAD' into add-polygon-source-main
0522319
draft
539ba64
.
645118e
fixes
50e0508
fixes
f9ed386
fixes
d635018
fix
0bf9ea8
revert
1c282c8
fixes
893a7b4
add detector test
8b0ef86
Merge remote-tracking branch 'origin/main' into add-polygon-source-main
bfc5406
rebasing fixes
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
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
127 changes: 127 additions & 0 deletions
127
nav2_collision_monitor/include/nav2_collision_monitor/polygon_source.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,127 @@ | ||
| // Copyright (c) 2023 Pixel Robotics GmbH | ||
| // | ||
| // 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__POLYGON_SOURCE_HPP_ | ||
| #define NAV2_COLLISION_MONITOR__POLYGON_SOURCE_HPP_ | ||
|
|
||
| #include <memory> | ||
| #include <vector> | ||
| #include <string> | ||
|
|
||
| #include "geometry_msgs/msg/polygon_stamped.hpp" | ||
|
|
||
| #include "nav2_collision_monitor/source.hpp" | ||
|
|
||
| namespace nav2_collision_monitor | ||
| { | ||
|
|
||
| /** | ||
| * @brief Implementation for polygon source | ||
| */ | ||
| class PolygonSource : public Source | ||
| { | ||
| public: | ||
| /** | ||
| * @brief PolygonSource constructor | ||
| * @param node Collision Monitor node pointer | ||
| * @param source_name Name of data source | ||
| * @param tf_buffer Shared pointer to a TF buffer | ||
| * @param base_frame_id Robot base frame ID. The output data will be transformed into this frame. | ||
| * @param global_frame_id Global frame ID for correct transform calculation | ||
| * @param transform_tolerance Transform tolerance | ||
| * @param source_timeout Maximum time interval in which data is considered valid | ||
| * @param base_shift_correction Whether to correct source data towards to base frame movement, | ||
| * considering the difference between current time and latest source time | ||
| */ | ||
| PolygonSource( | ||
| const nav2_util::LifecycleNode::WeakPtr & node, | ||
| const std::string & source_name, | ||
| const std::shared_ptr<tf2_ros::Buffer> tf_buffer, | ||
| const std::string & base_frame_id, | ||
| const std::string & global_frame_id, | ||
| const tf2::Duration & transform_tolerance, | ||
| const rclcpp::Duration & source_timeout, | ||
| const bool base_shift_correction); | ||
| /** | ||
| * @brief PolygonSource destructor | ||
| */ | ||
| ~PolygonSource(); | ||
|
|
||
| /** | ||
| * @brief Data source configuration routine. Obtains ROS-parameters | ||
| * and creates subscriber. | ||
| */ | ||
| void configure(); | ||
|
|
||
| /** | ||
| * @brief Adds latest data from polygon source to the data array. | ||
| * @param curr_time Current node time for data interpolation | ||
| * @param data Array where the data from source to be added. | ||
| * Added data is transformed to base_frame_id_ coordinate system at curr_time. | ||
| * @return false if an invalid source should block the robot | ||
| */ | ||
| bool getData( | ||
| const rclcpp::Time & curr_time, | ||
| std::vector<Point> & data) const; | ||
|
|
||
| /** | ||
| * @brief Converts a PolygonStamped to a std::vector<Point> | ||
| * @param polygon Input Polygon to be converted | ||
| * @param data Output vector of Point | ||
| */ | ||
| void convertPolygonStampedToPoints( | ||
| const geometry_msgs::msg::PolygonStamped & polygon, | ||
| std::vector<Point> & data) const; | ||
|
|
||
| protected: | ||
| /** | ||
| * @brief Getting sensor-specific ROS-parameters | ||
| * @param source_topic Output name of source subscription topic | ||
| */ | ||
| void getParameters(std::string & source_topic); | ||
|
|
||
| /** | ||
| * @brief PolygonSource data callback | ||
| * @param msg Shared pointer to PolygonSource message | ||
| */ | ||
| void dataCallback(geometry_msgs::msg::PolygonStamped::ConstSharedPtr msg); | ||
|
|
||
| /** | ||
| * @brief Checks if two polygons are similar | ||
| * @param polygon1 First polygon | ||
| * @param polygon2 Second polygon | ||
| * @return True if polygons are similar, false otherwise | ||
| */ | ||
| bool arePolygonsSimilar( | ||
| const geometry_msgs::msg::Polygon & polygon1, | ||
| const geometry_msgs::msg::Polygon & polygon2) const; | ||
|
|
||
| // ----- Variables ----- | ||
|
|
||
| /// @brief PolygonSource data subscriber | ||
| rclcpp::Subscription<geometry_msgs::msg::PolygonStamped>::SharedPtr data_sub_; | ||
|
|
||
| /// @brief Latest data obtained | ||
| std::vector<geometry_msgs::msg::PolygonStamped> data_; | ||
|
|
||
| /// @brief distance between sampled points on polygon edges | ||
| double sampling_distance_; | ||
|
|
||
| /// @brief maximum distance between points of polygons to be considered similar | ||
| double polygon_similarity_threshold_; | ||
| }; // class PolygonSource | ||
|
|
||
| } // namespace nav2_collision_monitor | ||
|
|
||
| #endif // NAV2_COLLISION_MONITOR__POLYGON_SOURCE_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
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
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.
Uh oh!
There was an error while loading. Please reload this page.