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: dynamic polygon and source enable/disable #3825

Merged
merged 24 commits into from
Sep 27, 2023

Conversation

tonynajjar
Copy link
Contributor

@tonynajjar tonynajjar commented Sep 19, 2023


Basic Info

Info Please fill out this column
Ticket(s) this addresses #3824
Primary OS tested on Ubuntu
Robotic platform tested on Own gazebo simulation

Description of contribution in a few bullet points

  • Added dynamic enabling/disabling of collision monitor polygons and sources
  • Added test

Description of documentation updates required from your changes


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

@tonynajjar tonynajjar changed the title Runtime polygon enable collision_monitor: dynamic enable/disable Sep 19, 2023
@tonynajjar tonynajjar marked this pull request as draft September 19, 2023 11:00
@tonynajjar tonynajjar marked this pull request as ready for review September 19, 2023 11:03
@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (910a9f2) 90.33% compared to head (e12dc5e) 90.35%.
Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3825      +/-   ##
==========================================
+ Coverage   90.33%   90.35%   +0.02%     
==========================================
  Files         413      413              
  Lines       18040    18087      +47     
==========================================
+ Hits        16296    16343      +47     
  Misses       1744     1744              
Files Coverage Δ
..._collision_monitor/src/collision_detector_node.cpp 99.27% <100.00%> (+0.01%) ⬆️
...2_collision_monitor/src/collision_monitor_node.cpp 98.20% <100.00%> (+0.02%) ⬆️
nav2_collision_monitor/src/pointcloud.cpp 95.65% <100.00%> (+0.09%) ⬆️
nav2_collision_monitor/src/range.cpp 95.91% <100.00%> (+0.08%) ⬆️
nav2_collision_monitor/src/scan.cpp 97.22% <100.00%> (+0.07%) ⬆️
nav2_collision_monitor/src/source.cpp 97.36% <100.00%> (+2.63%) ⬆️
nav2_collision_monitor/src/polygon.cpp 97.37% <94.11%> (-0.24%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Minor changes but LGTM. Some test would be nice though, but I won't require it for this

nav2_collision_monitor/src/collision_monitor_node.cpp Outdated Show resolved Hide resolved
nav2_collision_monitor/src/polygon.cpp Outdated Show resolved Hide resolved
@tonynajjar
Copy link
Contributor Author

Do you think I should also skip publishing the polygon in publishPolygons if it's disabled?

@tonynajjar
Copy link
Contributor Author

Also, since collision monitor and detector use the same Polygon, detector polygons will also have this new parameter. We could implement the same logic in collision_detector but I don't see much benefit to it except consistency/parallelism between the two nodes. What do you think?

@SteveMacenski
Copy link
Member

Do you think I should also skip publishing the polygon in publishPolygons if it's disabled?

I think so! Anything else fall into this category?

Also, since collision monitor and detector use the same Polygon, detector polygons will also have this new parameter. We could implement the same logic in collision_detector but I don't see much benefit to it except consistency/parallelism between the two nodes. What do you think?

I don't see why not. Is it just adding the if not polygon->enabled() into the logic? If so, yeah, lets add it. Doesn't hurt anyone and really easy.

Make sure also to follow up on documentation updates to the migration guide + adding the new parameter to the configuration guide

@tonynajjar
Copy link
Contributor Author

tonynajjar commented Sep 25, 2023

I think so! Anything else fall into this category?

Done, nothing else I see

Doesn't hurt anyone and really easy.

One drawback I see to disabling a polygon in collision_detector is that it would mess up the indexing of polygons in CollisionDetectorState msg; if some node subscribing to this topic has saved at initialization that a polygon is at a certain index, then disabling a polygon would cause this node to get the wrong index in detections (or even access an index out of range).

The reason why I said I see no value in disabling a polygon in collision detector is because if you don't want the status of a certain polygon, you just don't retrieve it.

If you still think that we should add the functionality and it's safe to expect that the user should always check if CollisionDetectorState msg has changed, then I'm fine with implementing it

@tonynajjar tonynajjar changed the title collision_monitor: dynamic enable/disable collision_monitor: dynamic polygon enable/disable Sep 25, 2023
@tonynajjar tonynajjar changed the title collision_monitor: dynamic polygon enable/disable collision_monitor: dynamic polygon and source enable/disable Sep 25, 2023
@tonynajjar
Copy link
Contributor Author

tonynajjar commented Sep 25, 2023

@SteveMacenski I also added the dynamic enabling/disabling of a source, please check it out

Make sure also to follow up on documentation updates to the migration guide + adding the new parameter to the configuration guide

Will do so once the scope is clarified

Copy link
Contributor Author

@tonynajjar tonynajjar left a comment

Choose a reason for hiding this comment

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

I have a general question about dynamic parameter setting: from the Nav2 codebase I see that you prefer having these dynamicParametersCallback in which we set internal member variables with the new parameters.

Another way would be to directly read the parameter from the parameter server, roughly:

    auto node = polygon->node_.lock();
    if (node->get_parameter(polygon->getName() + ".enabled").as_bool()) {
         .....
    }

The benefit here is less boilerplate code. What's the con, is it slower? Or why do you prefer the first option?

@SteveMacenski
Copy link
Member

SteveMacenski commented Sep 25, 2023

if some node subscribing to this topic has saved at initialization that a polygon is at a certain index

That's really not good practice - we make no promises about the structure of that message array. Also, aren't only the polygons in collision published? If so, then there's no order to be assumed because there's no consistent polygon collision.

If you still think that we should add the functionality

I do - if the API exists for the base polygon/source type, we should use it anywhere applicable

dynamicParametersCallback in which we set internal member variables with the new parameters

Updating a parameter may require reinitializing other areas that parameter is being used in or you could be triggering an action mid-parameter update if trying to update many - so then the state of that action is not fully defined. Further, design wise, its not wise to inject ROS code into your deep algorithm logic, so getting the ROS params and converting to internal types lets you keep ROS out of the library cores + gives you control to explicitly accept or reject parameter updates if they're bogus or invalid, which happens.

In this particular library, in this particular case, it probably doesn't matter, but its the design pattern we use, so lets stick to them. I'm also not 100% sure how get_parameter() calls in a loop handle dynamic parameters. I don't necessarily think it will work?

@SteveMacenski
Copy link
Member

@AlexeyMerzlyakov please review

@SteveMacenski
Copy link
Member

@tonynajjar just needs migration guide entry for navigation.ros.org + configuration guide for the new parameters

@tonynajjar
Copy link
Contributor Author

@SteveMacenski SteveMacenski merged commit c2d84df into ros-navigation:main Sep 27, 2023
7 checks passed
@SteveMacenski
Copy link
Member

Great! Thanks! This is nice to have!

SteveMacenski pushed a commit that referenced this pull request Jan 24, 2024
* Rename PushRosNamespace to PushROSNamespace

* Fix min_points checking

* initial

* fix

* fix

* remove unrelated change

* reset

* fix format

* PR fixes

* Add test

* fix comments

* add to params

* publish only if enabled

* Add source dynamic enable/disable

* add enabled param to sources

* fix

* add same to collision detector
SteveMacenski added a commit that referenced this pull request Jan 24, 2024
* collision_monitor: dynamic polygon and source enable/disable (#3825)

* Rename PushRosNamespace to PushROSNamespace

* Fix min_points checking

* initial

* fix

* fix

* remove unrelated change

* reset

* fix format

* PR fixes

* Add test

* fix comments

* add to params

* publish only if enabled

* Add source dynamic enable/disable

* add enabled param to sources

* fix

* add same to collision detector

* Update README.md: fix typo (#3842)

* Update package.xml

* fix typo (#3850)

* adjust link to point to v3.8 of behavior tree docs (#3851)

BT.CPP_v3 is used, thereby the correct docs should be linked

* Fix bug in nav2_behavior_tree/bt_action_node (#3849)

* Fix bug in nav2_behavior_tree/bt_action_node

* Fixed the bug in halt function inside
  nav2_behavior_tree/plugin/action/bt_action_node.hpp

* Added new case to nav2_behavior_tree/plugin/action/bt_action_node.hpp
  for testing the scenario to cancel

* Refactored existing cases in
  nav2_behavior_tree/plugin/action/bt_action_node.hpp

Signed-off-by: CihatAltiparmak <cihataltiparmak1@gmail.com>

* Fix bug in nav2_behavior_tree/bt_action_node

* Fixed the bug in halt function inside
  nav2_behavior_tree/plugin/action/bt_action_node.hpp

* Added new case to nav2_behavior_tree/plugin/action/bt_action_node.hpp
  for testing the scenario to cancel

* Refactored existing cases in
  nav2_behavior_tree/plugin/action/bt_action_node.hpp

Signed-off-by: CihatAltiparmak <cihataltiparmak1@gmail.com>

---------

Signed-off-by: CihatAltiparmak <cihataltiparmak1@gmail.com>

* Fix action test failure due to rate after Rolling sync API change (#3852)

* Update CMakeLists.txt (#3843)

* add option for sse4 and avs512 (#3853)

* Remove all exit(-1) crash conditions (#3846)

* Update transform_available_condition.cpp

* wrapping all examples of get_plugin_type_param in exceptions and making that throw instead of crash

* some linting

* fix typo

* Update controller.cpp

* Update nav2_params.yaml

* Update nav2_params.yaml

* simplication of lattice_generator.py, fixes #3858 (#3859)

* simplification of equation to compute the max_value/outer edge of the lattice based on number of headings.

* Stop error diagnostics when pausing nav (#3830)

* Added nodestate enum and a variable to keep track of current state of managed nodes.

* Updating state_of_managed_nodes_ when switching states and using it to determine an accurate diagnostics message.

* Fixing bugs.

* Updated/added docstrings.

* Publishing OK status when nodes are unconfigured. Changed if-else chain to switch case.

* Renamed NodeState PAUSED to INACTIVE, state_of_managed_nodes_ to managed_nodes_state_ and replaced system_active_ with an inline method.

* Bugfix.

---------

Co-authored-by: Pekka Myller <pekka.myller@karelics.fi>

* Add a timeout to the wait for transforms step of the costmap activation. (#3866)

* Add a timeout to the wait for transforms step of the costmap activation.

Signed-off-by: Fabian König <fabiankoenig@gmail.com>

* Rename wait_for_transforms_timeout to initial_transform_timeout

* Activate costmap publishers only after transforms are checked

* Check if controller server activation was succesful in planner_server

* Add unittest for costmap activation

Signed-off-by: Fabian König <fabiankoenig@gmail.com>

---------

Signed-off-by: Fabian König <fabiankoenig@gmail.com>

* Fix class doxygen

* fix minor typos (#3892)

Signed-off-by: Anton Kesy <antonkesy@gmail.com>

* Publish collision points for debug purposes (#3879)

* Rename PushRosNamespace to PushROSNamespace

* Fix min_points checking

* .

* fixes

* add to collision detector

* fix

* fix

* .

* fixes

* add namespace to topic

* fixes

* fix use after free (#3910)

* fix build mppi (#3927)

Signed-off-by: kevin <kevin@floatic.io>
Co-authored-by: kevin <kevin@floatic.io>

* Removing old TODOs

* protect invalid max_velocity min_velocity (#3953)

Co-authored-by: Guillaume Doisy <guillaume@dexory.com>

* protect properly max_accel and max_decel (#3952)

Co-authored-by: Guillaume Doisy <guillaume@dexory.com>

* Fixed links for install and build in README (#3963)

Currently the readme is linking to an invalida page in the docs (404 error).

* adding support for rotate in place cusps (#3934)

* Fix linting error (#3969)

* Fix linting error

* Update regulated_pure_pursuit_controller.cpp

* fix a few outdated comments in smac planners (#3978)

* adding soft realtime prioritization for collision monitor and velocity smoother (#3979)

* adding soft realtime prioritization for collision monitor and velocity smoother

* refactor simple action server to use new utils API

* Update README.md

* Synchronize map size information during map initialization (#4015)

* Update costmap size configuration

This commit updates the costmap_2d.cpp file to fix a bug where the costmap size wasn't appropriately updated. Two new lines of code have been added to ensure the size of the costmap is correctly configured each time it's instantiated.

* Refactor costmap size assignment in Costmap2D class

The code refactor eliminates the direct mutation of the size_x_ and size_y_ attributes in the Costmap2D class. Instead, the class uses the size of cells provided during initialization and calculation from map coordinates for better encapsulation and clarity.

* check width&height params (#4017)

Co-authored-by: GoesM <GoesM@buaa.edu.cn>

* Fix SimpleActionServer nullprt callback (#4025)

* add check before calling completion_callback_

* Fix lint

* footprint checks (#4030)

* footprint checks

Signed-off-by: gg <josho.wallace@gmail.com>

* lint fix

Signed-off-by: gg <josho.wallace@gmail.com>

---------

Signed-off-by: gg <josho.wallace@gmail.com>

* Is path valid doc (#4032)

* docs

Signed-off-by: gg <josho.wallace@gmail.com>

* update

Signed-off-by: gg <josho.wallace@gmail.com>

---------

Signed-off-by: gg <josho.wallace@gmail.com>

* Update vision_opencv's branch for rolling

Signed-off-by: Steve Macenski <stevenmacenski@gmail.com>

* handle dynamically changes in parameters. (#4046)

Signed-off-by: Sebastian Solarte <johan.solarte@kiwibot.com>

* Add inflation_layer_name param (#4047)

Signed-off-by: Renan Salles <renan028@gmail.com>

* missing urdf dep (#4050)

Signed-off-by: Guillaume Doisy <guillaume@dexory.com>
Co-authored-by: Guillaume Doisy <guillaume@dexory.com>

* bump to 1.2.6 for release

---------

Signed-off-by: CihatAltiparmak <cihataltiparmak1@gmail.com>
Signed-off-by: Fabian König <fabiankoenig@gmail.com>
Signed-off-by: Anton Kesy <antonkesy@gmail.com>
Signed-off-by: kevin <kevin@floatic.io>
Signed-off-by: gg <josho.wallace@gmail.com>
Signed-off-by: Steve Macenski <stevenmacenski@gmail.com>
Signed-off-by: Sebastian Solarte <johan.solarte@kiwibot.com>
Signed-off-by: Renan Salles <renan028@gmail.com>
Signed-off-by: Guillaume Doisy <guillaume@dexory.com>
Co-authored-by: Tony Najjar <tony.najjar@logivations.com>
Co-authored-by: thandal <than@timbrel.org>
Co-authored-by: Anton Kesy <antonkesy@gmail.com>
Co-authored-by: CihatAltiparmak <cihataltiparmak1@gmail.com>
Co-authored-by: Anil Kumar Chavali <44644339+akchobby@users.noreply.github.com>
Co-authored-by: Plaqueoff <44152820+Plaqueoff@users.noreply.github.com>
Co-authored-by: Pekka Myller <pekka.myller@karelics.fi>
Co-authored-by: Fabian König <fabiankoenig@gmail.com>
Co-authored-by: 정찬희 <60467877+ladianchad@users.noreply.github.com>
Co-authored-by: kevin <kevin@floatic.io>
Co-authored-by: Guillaume Doisy <doisyg@users.noreply.github.com>
Co-authored-by: Guillaume Doisy <guillaume@dexory.com>
Co-authored-by: Abiel Fernandez <empoleom@gmail.com>
Co-authored-by: Michael Ferguson <mfergs7@gmail.com>
Co-authored-by: Hao-Li-Bachelorarbeit <141755843+Hao-Li-Bachelorarbeit@users.noreply.github.com>
Co-authored-by: GoesM <130988564+GoesM@users.noreply.github.com>
Co-authored-by: GoesM <GoesM@buaa.edu.cn>
Co-authored-by: BriceRenaudeau <48433002+BriceRenaudeau@users.noreply.github.com>
Co-authored-by: Joshua Wallace <josho.wallace@gmail.com>
Co-authored-by: Sebastian Solarte <89881453+Sunart24@users.noreply.github.com>
Co-authored-by: Renan Salles <renan028@gmail.com>
enricosutera pushed a commit to enricosutera/navigation2 that referenced this pull request May 19, 2024
…igation#3825)

* Rename PushRosNamespace to PushROSNamespace

* Fix min_points checking

* initial

* fix

* fix

* remove unrelated change

* reset

* fix format

* PR fixes

* Add test

* fix comments

* add to params

* publish only if enabled

* Add source dynamic enable/disable

* add enabled param to sources

* fix

* add same to collision detector

Signed-off-by: enricosutera <enricosutera@outlook.com>
Marc-Morcos pushed a commit to Marc-Morcos/navigation2 that referenced this pull request Jul 4, 2024
…igation#3825)

* Rename PushRosNamespace to PushROSNamespace

* Fix min_points checking

* initial

* fix

* fix

* remove unrelated change

* reset

* fix format

* PR fixes

* Add test

* fix comments

* add to params

* publish only if enabled

* Add source dynamic enable/disable

* add enabled param to sources

* fix

* add same to collision detector
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.

2 participants