Skip to content
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

[collision monitor] Select the observation sources used with each polygon #4227

Conversation

anaelle-sw
Copy link
Contributor

Basic Info

Info Please fill out this column
Ticket(s) this addresses #4197
Primary OS tested on Ubuntu
Robotic platform tested on RobOcc's robot
Does this PR contain AI generated software? No

Description of contribution in a few bullet points

New string vector parameter <polygon_name>.sources_names. Only the sources which names are specified in parameter are used to check collision with current polygon. If the parameter is not set, all the observation sources are used.

Description of documentation updates required from your changes

Add new parameter <polygon_name>.sources_names to default configs, documentation page, and migration guide


Future work that may be required in bullet points

For Maintainers:

  • Check that any new parameters added are updated in navigation.ros.org
  • Check that any significant change is added to the migration guide
  • Check that any new features OR changes to existing behaviors are reflected in the tuning guide
  • Check that any new functions have Doxygen added
  • Check that any new features have test coverage
  • Check that any new plugins is added to the plugins page
  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists

Copy link
Contributor

mergify bot commented Mar 28, 2024

@anaelle-sw, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from f8d2bef to 95174e9 Compare March 28, 2024 17:00
Copy link
Contributor

mergify bot commented Mar 28, 2024

@anaelle-sw, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

Copy link
Member

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do this more efficiently and straight forward

  • Create the unordered map
  • Adjust the current for (std::shared_ptr<Source> source : sources_) { loop to contain (1) creating an entry for a source name key with an empty vector as the value. (2) Capture the return of insert will give you an iterator to that pair in the map
  • Pass into getData the reference to the value (vector) to populate. That eliminates an entire data copy. It also eliminates multiple calls to getData to populate both the vector and map separately
  • Adjust the processStopSlowdownLimit / processApproach / etc functions to take in this map. The vector of points should no longer exist
  • Pass the map to the isPointInside
  • When iterating through the sources, use the sources names to decide if you want to use that one or not

This eliminates any extra looping and a bunch of data copies (and not parallel populating a map and a vector of data). Speed here is really key and copying pointclouds and laserscans is a pretty worst-case situation

nav2_collision_monitor/src/collision_monitor_node.cpp Outdated Show resolved Hide resolved
nav2_collision_monitor/src/collision_monitor_node.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

mergify bot commented Apr 24, 2024

This pull request is in conflict. Could you fix it @anaelle-sw?

@SteveMacenski
Copy link
Member

SteveMacenski commented Apr 24, 2024

@anaelle-sw looks like some small changes needed from merging your other PR 😄 Can we get this one in next?

I do really appreciate your time and effort to contribute this work back to Nav2, it is very useful and thank you!

@SteveMacenski
Copy link
Member

@anaelle-sw Hi! Any update here?

@anaelle-sw
Copy link
Contributor Author

Sorry, I haven't had the time to work on this properly lately. I will rebase the branch on main and begin to apply to changes you requested by the end of the week.

@SteveMacenski
Copy link
Member

Thanks @anaelle-sw :-)

@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from 95174e9 to 8264866 Compare June 7, 2024 07:49
Copy link
Contributor

mergify bot commented Jun 7, 2024

@anaelle-sw, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

1 similar comment
Copy link
Contributor

mergify bot commented Jun 7, 2024

@anaelle-sw, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@anaelle-sw
Copy link
Contributor Author

anaelle-sw commented Jun 7, 2024

The MR is now rebased on current main branch. I have also applied your optimization suggestions. But I have not tested yet the behaviour with these changes.

I entirely agree with most of the optimizations you asked for, but actually I have a slightly better solution about function getPointsInside():

You suggested to pass the entire map (which associates the sources names to their vector of points) to function getPointsInside(), instead of a simple array of points. So, in this function, we should have a "for" loop on the map in order to choose to use or not each source (depending on the polygon config). This clearly optimizes the processing of points for Stop, Slowdown, and Limit polygons (function processStopSlowdownLimit() is calling only once function getPointsInside).

But in the case of Approach polygons, the function processApproach() calls getCollisionTime(), which can call twice getPointsInside(). This means we get to go through the "for" loop on the entire map twice. To avoid this, I have simply moved this "for" loop to getCollisionTime() function. This way, 1 - we make sure to go through the map only once for each polygon, and 2 - it avoids useless computation (i.e. points frame transformation made in getCollisionTime()) when the sources are actually not used for current polygon.

To do so, I have kept the already existing getPointsInside() function, which takes a vector of points as argument. This function is called by getCollisionTime the same way as it was before. But I have also overloaded this getPointsInside() function to be able to take the entire map as argument, which is more convenient to call from function processStopSlowdownLimit(), in the case of the Stop/Slowdown/Limit polygons.

@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from 5af93f6 to b46fc72 Compare June 7, 2024 15:29
Copy link
Contributor

mergify bot commented Jun 7, 2024

@anaelle-sw, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from b46fc72 to 3a067b9 Compare June 7, 2024 15:37
Copy link
Contributor

mergify bot commented Jun 7, 2024

@anaelle-sw, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@SteveMacenski
Copy link
Member

SteveMacenski commented Jun 7, 2024

It does not appear to be building properly, but I love this idea and looks good to me! A couple of tests for this feature would be nice - since this is a pretty low-level system that we should be especially careful about.

@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from 3a067b9 to 1c672fa Compare June 11, 2024 16:49
Copy link
Contributor

mergify bot commented Jun 11, 2024

@anaelle-sw, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from 1c672fa to 3b7f4e4 Compare June 11, 2024 17:09
Copy link
Contributor

mergify bot commented Jun 11, 2024

@anaelle-sw, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from 3b7f4e4 to 1f132cf Compare June 11, 2024 17:12
Copy link
Contributor

mergify bot commented Jun 11, 2024

@anaelle-sw, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from 1f132cf to 8a036bd Compare June 11, 2024 17:28
@SteveMacenski
Copy link
Member

Many of the collision monitor tests are now failing!

@SteveMacenski
Copy link
Member

Hi @anaelle-sw how can I help push this along?

@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from 8a036bd to 3186c2b Compare August 22, 2024 16:34
Copy link
Contributor

mergify bot commented Aug 22, 2024

@anaelle-sw, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@SteveMacenski
Copy link
Member

SteveMacenski commented Aug 22, 2024

@anaelle-sw Please rebase after I merge #4642 to fix the build issue. TF2 changed a header location on us :-) (and probably fix the linting/DCO issues while you're at it)

Is this good for another review then?

@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch 2 times, most recently from 5e82501 to 19b8246 Compare August 23, 2024 08:49
@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch 2 times, most recently from e53372f to 3650cdc Compare August 23, 2024 16:06
@anaelle-sw
Copy link
Contributor Author

Hi @SteveMacenski , sorry it took me so long to work on this and fix the tests. It should be good to be reviewed now, the branch is rebased, and DCO, linting and collision monitor tests are fixed.

I also add 3 new tests for polygons:

  • if no specific sources are declared for polygon, all observation sources should be used
  • if not declared source is associated to polygon, configuration should fail
  • if specific sources are declared for polygon, only these observation sources will be used

And a test for collision monitor node:
Two polygons are declared, with the same size. The first one uses all observation sources (range + scan) and has a "slowdown" action type. The second one uses only the range source and has a "stop" action type.
If the range source publishes an obstacle far away from the polygons, while the scan source publishes an obstacle inside the polygons, only the "slowdown" action type coming from the first polygon should be applied.

Copy link

codecov bot commented Aug 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
..._collision_monitor/src/collision_detector_node.cpp 97.56% <100.00%> (-0.61%) ⬇️
...2_collision_monitor/src/collision_monitor_node.cpp 97.44% <100.00%> (-0.34%) ⬇️
nav2_collision_monitor/src/polygon.cpp 97.38% <100.00%> (+0.23%) ⬆️

... and 5 files with indirect coverage changes

Copy link
Member

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick, but overall looks good to me!

nav2_collision_monitor/src/collision_monitor_node.cpp Outdated Show resolved Hide resolved
nav2_collision_monitor/src/collision_monitor_node.cpp Outdated Show resolved Hide resolved
nav2_collision_monitor/src/polygon.cpp Outdated Show resolved Hide resolved
nav2_collision_monitor/src/polygon.cpp Outdated Show resolved Hide resolved
nav2_collision_monitor/src/polygon.cpp Outdated Show resolved Hide resolved
@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from 3650cdc to be63b55 Compare August 27, 2024 15:31
@SteveMacenski
Copy link
Member

Otherwise, LGTM, but you have a test failing so I can't see the coverage metrics to see if this covers the bulk of the important changes

Signed-off-by: asarazin <[email protected]>
@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from be63b55 to 1860732 Compare August 28, 2024 12:32
Signed-off-by: asarazin <[email protected]>
@anaelle-sw anaelle-sw force-pushed the collision_monitor_specific_observation_sources_for_polygon branch from 1860732 to b4c2925 Compare August 28, 2024 12:39
@SteveMacenski
Copy link
Member

LGTM! Any reason this is still a draft? I could merge this in I think!

@anaelle-sw anaelle-sw marked this pull request as ready for review August 29, 2024 08:27
@anaelle-sw
Copy link
Contributor Author

Any reason this is still a draft?

No, I just forgot to update it. It should be good now

@SteveMacenski SteveMacenski merged commit 6d24c7f into ros-navigation:main Aug 29, 2024
11 checks passed
SteveMacenski pushed a commit that referenced this pull request Nov 8, 2024
…ygon (#4227)

* Collision monitor: select specific observation sources for polygon

Signed-off-by: asarazin <[email protected]>

* optimization

Signed-off-by: asarazin <[email protected]>

* add tests

Signed-off-by: asarazin <[email protected]>

---------

Signed-off-by: asarazin <[email protected]>
Co-authored-by: asarazin <[email protected]>
SteveMacenski added a commit that referenced this pull request Nov 8, 2024
* Adding non-charging dock support to docking server (for conveyers, pallots, etc) (#4627)

* adding non-charging dock support to docking server

Signed-off-by: Steve Macenski <[email protected]>

* docs and linting

* adding unit tests

Signed-off-by: Steve Macenski <[email protected]>

---------

Signed-off-by: Steve Macenski <[email protected]>

* Publish optimal trajectory as a Path message (#4640)

* Publish optimal trajectory as a Path message

Signed-off-by: Alyssa Agnissan <[email protected]>

* move publish_optimal_path to TrajectoryVisualizer + minor refactoring

Signed-off-by: Alyssa Agnissan <[email protected]>

* tests added for optimal path publication

Signed-off-by: Alyssa Agnissan <[email protected]>

* populate optimal path message in add()

Signed-off-by: Alyssa Agnissan <[email protected]>

* move path population in add_marker

Signed-off-by: Alyssa Agnissan <[email protected]>

---------

Signed-off-by: Alyssa Agnissan <[email protected]>

* [collision monitor] Select the observation sources used with each polygon (#4227)

* Collision monitor: select specific observation sources for polygon

Signed-off-by: asarazin <[email protected]>

* optimization

Signed-off-by: asarazin <[email protected]>

* add tests

Signed-off-by: asarazin <[email protected]>

---------

Signed-off-by: asarazin <[email protected]>
Co-authored-by: asarazin <[email protected]>

* Restore exported BT test utils header files after cmake revamp (#4652) (#4654)

Signed-off-by: Mike Wake <[email protected]>

* fix(bt_nodes): Correct default `server_timeout` behavior by using `getInputPortOrBlackboard()` (#4649)

Signed-off-by: Alan Xue <[email protected]>

* PoseStamped vector specialization (#4607)

* PoseStamped vector specialization

Signed-off-by: Tony Najjar <[email protected]>

* merge master

Signed-off-by: Tony Najjar <[email protected]>

* add path

Signed-off-by: Tony Najjar <[email protected]>

* fix size check

Signed-off-by: Tony Najjar <[email protected]>

* fix test

Signed-off-by: Tony Najjar <[email protected]>

* Revert "fix test"

This reverts commit 51f54eb.

* fix test

Signed-off-by: Tony Najjar <[email protected]>

---------

Signed-off-by: Tony Najjar <[email protected]>

* [DWB] Option to limit velocity commands in trajectory generator (#4663)

* Option to limit vel cmd through traj generator

Signed-off-by: huiyulhy <[email protected]>

* Cleanup

Signed-off-by: huiyulhy <[email protected]>

* fix linting

Signed-off-by: huiyulhy <[email protected]>

* Update linting

Signed-off-by: huiyulhy <[email protected]>

* uncrustify

Signed-off-by: huiyulhy <[email protected]>

* uncrustify

Signed-off-by: huiyulhy <[email protected]>

---------

Signed-off-by: huiyulhy <[email protected]>

* Adding planner server timeout for costmap waiting (#4673)

* Adding planner server timeout for costmap waiting

Signed-off-by: Steve Macenski <[email protected]>

* Adding controller server's costmap timeout as well

Signed-off-by: Steve Macenski <[email protected]>

---------

Signed-off-by: Steve Macenski <[email protected]>

* fixing path longer on approach (#4622)

* fixing path longer on approach

Signed-off-by: Pradheep <[email protected]>

* removing the short circuit

Signed-off-by: Pradheep <[email protected]>

* adding additional layer of check

Signed-off-by: Pradheep <[email protected]>

---------

Signed-off-by: Pradheep <[email protected]>

* fix to bt action server logging before bt execution result being ready (#4677)

Signed-off-by: DreamWest <[email protected]>

* Correct paper name for graceful controller

Signed-off-by: Steve Macenski <[email protected]>

* Added missing action clients in robot_navigator(BasicNavigator) to destroy_node (#4698)

* fix: added assisted_teleop_client to robot_navigator(BasicNavigator) destroy_node

Signed-off-by: Tiwa Ojo <[email protected]>

* fix: added other missing action clients to robot_navigator(BasicNavigator) destroy_node

Signed-off-by: Tiwa Ojo <[email protected]>

---------

Signed-off-by: Tiwa Ojo <[email protected]>

* Fixing SGF in MPPI and Smoother (#4669)

Signed-off-by: Steve Macenski <[email protected]>

* fix: handle transition failures in all servers (#4708)

* fix: handle transition failures in planner/controller/smoother servers

Signed-off-by: Kemal Bektas <[email protected]>

* adding support for rest of servers + review comments

Signed-off-by: Steve Macenski <[email protected]>

* Replacing throws with error and failed lifecycle transitions

Signed-off-by: Steve Macenski <[email protected]>

* fix vel smoother unit tests

Signed-off-by: Steve Macenski <[email protected]>

* fixing docking server unit testing

Signed-off-by: Steve Macenski <[email protected]>

* fixing last bits

Signed-off-by: Steve Macenski <[email protected]>

---------

Signed-off-by: Kemal Bektas <[email protected]>
Signed-off-by: Steve Macenski <[email protected]>
Co-authored-by: Kemal Bektas <[email protected]>

* [RotationShimController] fix: rotate on short paths (#4716)

Add header data to goal for short paths.

Commit d8ae3c1 added the possibility to
the rotation shim controller to rotate towards the goal when the goal
was closer that the `forward_sampling_distance`. This feature was not
fully working as the goal was missing proper header data, causing the
rotation shim to give back control to the main controller.

Co-authored-by: agennart <[email protected]>

* Added parameter `rotate_to_heading_once` (#4721)

Signed-off-by: Daniil Khaninaev <[email protected]>

* [RotationShimController] fix: rotate to goal heading (#4724)

Add frame_id to goal when rotating towards goal heading, otherwise the
transform would fail. This bug was introduced in 30e2cde by not setting
the frame_id.

Signed-off-by: agennart <[email protected]>
Co-authored-by: agennart <[email protected]>

* [loopback_sim] Publish clock, [nav2_costmap_2d] Fix Qos (#4726)

* Publish /clock from loopback sim

Signed-off-by: Adi Vardi <[email protected]>

* [nav2_costmap_2d] Fix obstacle_layer trying to use RELIABLE QoS

Use QoS profile from rclcpp::SensorDataQoS() instead of rmw_qos_profile_t.
This solves an issue where the subscriber uses RELIABLE setting even when initialized from rmw_qos_profile_sensor_data.
In addition the Subscriber(..., rmw_qos_profile_t) constructor is deprecated in favor of Subscriber(..., rclcpp::QoS)

Signed-off-by: Adi Vardi <[email protected]>

* [nav2_smac_planner] fix typos

Signed-off-by: Adi Vardi <[email protected]>

* Use single quotes

Signed-off-by: Adi Vardi <[email protected]>

---------

Signed-off-by: Adi Vardi <[email protected]>

* Fix incorrect doxygen comment (#4741)

Signed-off-by: Ryan Friedman <[email protected]>

* Updating error logging in Smac collision detector object (#4743)

* Updating error logging in Smac configs

Signed-off-by: Steve Macenski <[email protected]>

* linting

Signed-off-by: Steve Macenski <[email protected]>

---------

Signed-off-by: Steve Macenski <[email protected]>

* [map_io] Replace std logs by rclcpp logs (#4720)

* replace std logs by rclcpp logs

Signed-off-by: Guillaume Doisy <[email protected]>

* RCLCPP_DEBUG to RCLCPP_INFO for visibility

Signed-off-by: Guillaume Doisy <[email protected]>

---------

Signed-off-by: Guillaume Doisy <[email protected]>
Co-authored-by: Guillaume Doisy <[email protected]>

* manual backport to Jazzy of 6b2e244

Signed-off-by: Steve Macenski <[email protected]>

* bump to 1.3.3 for jazzy sync

Signed-off-by: Steve Macenski <[email protected]>

* fixing backport issue

Signed-off-by: Steve Macenski <[email protected]>

* fixing backport of docking linking changes

Signed-off-by: Steve Macenski <[email protected]>

---------

Signed-off-by: Steve Macenski <[email protected]>
Signed-off-by: Alyssa Agnissan <[email protected]>
Signed-off-by: asarazin <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Alan Xue <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: huiyulhy <[email protected]>
Signed-off-by: Pradheep <[email protected]>
Signed-off-by: DreamWest <[email protected]>
Signed-off-by: Tiwa Ojo <[email protected]>
Signed-off-by: Kemal Bektas <[email protected]>
Signed-off-by: Daniil Khaninaev <[email protected]>
Signed-off-by: agennart <[email protected]>
Signed-off-by: Adi Vardi <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Guillaume Doisy <[email protected]>
Co-authored-by: alyquantillion <[email protected]>
Co-authored-by: anaelle-sw <[email protected]>
Co-authored-by: asarazin <[email protected]>
Co-authored-by: aosmw <[email protected]>
Co-authored-by: Alan <[email protected]>
Co-authored-by: Tony Najjar <[email protected]>
Co-authored-by: Huiyu Leong <[email protected]>
Co-authored-by: Pradheep Krishna <[email protected]>
Co-authored-by: DreamWest <[email protected]>
Co-authored-by: Tiwa Ojo <[email protected]>
Co-authored-by: Kemal Bektas <[email protected]>
Co-authored-by: Saitama <[email protected]>
Co-authored-by: agennart <[email protected]>
Co-authored-by: Daniil Khaninaev <[email protected]>
Co-authored-by: Adi Vardi <[email protected]>
Co-authored-by: Ryan <[email protected]>
Co-authored-by: Guillaume Doisy <[email protected]>
Co-authored-by: Guillaume Doisy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[collision monitor] Select the observation sources used with each polygon
2 participants