Repository navigation
Add AsymmetricInflationLayer costmap plugin for path-aware lane-keeping - #6118
SteveMacenski merged 45 commits into
Conversation
669704c to
6265c9c
Compare
SteveMacenski
left a comment
There was a problem hiding this comment.
Quick initial architectural review:
Out of curiosity, does this share many of the same methods as the legacy layer? If so, can this derive from that layer to make use of the same implementations of those methods?
Does this do incremental updates like the inflation layer? The needs_reinflation_ implies so but I thought you mentioned it does it clean each iteration instead.
Yes, this does indeed share some of the same methods with the legacy layer:
I'm not sure though if the additional coupling outweighs the inherited methods.
When I opened the feature request it didn't do incremental updates yet, because when I tried to implement it a month ago, I was having issues with artifacts in the costmap. Yesterday when I was making performance improvements to the updateCosts() and computeObstacleSide() functions, I reimplemented the incremental updates as well and saw now artifacts this time. Maybe I did an error when I tried to implement the iterative updates a month ago. |
|
I've created a PR for docs.nav2.org, adding a basic description of the layer and it's parameters. |
315e30d to
0480c7b
Compare
|
Rebase/pull in main to get CI to turn over |
|
@tonynajjar please review since this relates to some of your recent work on this style of new inflation layer |
I'm a bit overwhelmed with other tasks currently to thoroughly review such an algorithm-heavy PR that we are not of immediate need for :/ |
c0430dd to
c3e500d
Compare
|
Please pull in main / rebase to have CI turn over. I need to see the coverage metrics for the unit tests |
There was a problem hiding this comment.
Pull request overview
Adds a new AsymmetricInflationLayer costmap plugin that biases inflation relative to the global path to encourage lane-keeping behavior, along with unit, integration, and benchmark coverage.
Changes:
- Adds the asymmetric inflation plugin implementation, header, build registration, and pluginlib metadata.
- Adds unit and integration tests for LUT generation, side classification, and basic layer behavior.
- Adds benchmark coverage comparing asymmetric inflation against existing inflation implementations.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
nav2_costmap_2d/CMakeLists.txt |
Builds the new asymmetric inflation plugin source into the layers library. |
nav2_costmap_2d/costmap_plugins.xml |
Registers AsymmetricInflationLayer as a costmap plugin. |
nav2_costmap_2d/include/nav2_costmap_2d/asymmetric_inflation_layer.hpp |
Declares the new path-aware asymmetric inflation layer API and state. |
nav2_costmap_2d/plugins/asymmetric_inflation_layer.cpp |
Implements path subscription, side classification, asymmetric distance transform, and dynamic parameters. |
nav2_costmap_2d/test/unit/CMakeLists.txt |
Adds the asymmetric inflation unit test target. |
nav2_costmap_2d/test/unit/asymmetric_inflation_layer_test.cpp |
Tests disfavored LUT construction and obstacle side classification. |
nav2_costmap_2d/test/integration/CMakeLists.txt |
Adds the asymmetric inflation integration test target and launch registration. |
nav2_costmap_2d/test/integration/asymmetric_inflation_tests.cpp |
Tests standalone layer behavior with and without paths and interface conformance. |
nav2_costmap_2d/test/benchmark/CMakeLists.txt |
Adds the asymmetric inflation benchmark target. |
nav2_costmap_2d/test/benchmark/asymmetric_layer_updatecosts_benchmark.cpp |
Adds full-map and incremental benchmarks for asymmetric, current, and legacy inflation layers. |
Comments suppressed due to low confidence (3)
nav2_costmap_2d/test/benchmark/asymmetric_layer_updatecosts_benchmark.cpp:864
- These registered benchmark cases allocate extremely large costmaps (up to 25,600 × 25,600 cells) and the update path also creates float distance maps, which can require multiple gigabytes of RAM per case and make the benchmark OOM on typical developer or CI machines. Please gate the extreme cases behind an opt-in flag or reduce the default registered sizes so the benchmark target remains runnable by default.
->Args({25600, 25600, 100, 0}) // 1280×1280 m map, ~5 m patch, full diagonal path
->Args({25600, 25600, 200, 0}) // 1280×1280 m map, ~10 m patch, full diagonal path
->Args({800, 800, 100, 20}) // 40×40 m map, ~5 m patch, fixed 20 m path
->Args({1600, 1600, 100, 20}) // 80×80 m map, ~5 m patch, fixed 20 m path
->Args({3200, 3200, 100, 20}) // 160×160 m map, ~5 m patch, fixed 20 m path
->Args({6400, 6400, 100, 20}) // 320×320 m map, ~5 m patch, fixed 20 m path
->Args({12800, 12800, 100, 20}) // 640×640 m map, ~5 m patch, fixed 20 m path
->Args({25600, 25600, 100, 20}) // 1280×1280 m map, ~5 m patch, fixed 20 m path
->Iterations(50)
nav2_costmap_2d/test/benchmark/asymmetric_layer_updatecosts_benchmark.cpp:480
- The asymmetric full-map benchmark registers the same 12,800 × 12,800 default case, but this fixture runs both the inherited inflation pass and the asymmetric overlay, multiplying the memory pressure from full-size distance maps. Please keep such extreme sizes behind an explicit opt-in instead of registering them by default.
->Args({3200, 3200}) // 160x160 m
->Args({6400, 6400}) // 320x320 m
->Args({12800, 12800}) // 640x640 m
->Iterations(50)
nav2_costmap_2d/test/benchmark/asymmetric_layer_updatecosts_benchmark.cpp:586
- The incremental baseline registrations include 25,600 × 25,600 maps by default. Even with a small update window, fixture setup allocates and pre-warms the full costmap, which can consume gigabytes and make the benchmark unusable without a very large machine; please make these stress cases opt-in.
->Args({12800, 12800, 100}) // 640×640 m map, ~5 m patch
->Args({12800, 12800, 200}) // 640×640 m map, ~10 m patch
->Args({25600, 25600, 100}) // 1280×1280 m map, ~5 m patch
->Args({25600, 25600, 200}) // 1280×1280 m map, ~10 m patch
->Iterations(50)
|
Something to double check: we do things like this for optimized collision checking: https://github.com/ros-navigation/navigation2/blob/855ba78e14c69839cb7a798ce2634293d5150dc0/nav2_mppi_controller/src/critics/cost_critic.cpp#L114C31-L114C42 does this return the most conservative cost at all times for the L/R scale factor parameters? |
jwallace42
left a comment
There was a problem hiding this comment.
Do you have any visuals of the inflation in a narrow aisle (i.e when the asymmetric inflation would overlap the symmetric inflation)? I might be missing something but I think you could get end up with discrete jumps in cost in these scenarios.
Nice job btw :) Wicked cool.
|
Thank you very much for the reviews! Sorry for not addressing your reviews earlier. I'm currently overworked, but have time this weekend to address it. |
12153f7 to
e9465c5
Compare
Codecov Report❌ Patch coverage is
... and 16 files with indirect coverage changes 🚀 New features to boost your workflow:
|
I uploaded a video of the robot driving through our office a few weeks ago in issue 6109 Inflation jumps happen the same way as in the standard inflation_layer. -> Wherever two inflation waves meet, they'll have the same cost at the boundary, though the derivative at that point will be not continious. |
It should, yes. |
073d11f to
606fd46
Compare
|
@SteveMacenski @jwallace42 After rebasing the circleci release_test now fails for the nav2_system_test package. I do think this is unrelated to my changes though, because the nav2_system_test package isn't using the proposed asymmetric_inflation_layer Is there anything else I should change? |
jwallace42
left a comment
There was a problem hiding this comment.
Updated a few comments. Feel free to request a review in the future if you need me to take another look. Otherwise I assume you are still working :).
Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
…d be uninitialized Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
…ment explaining it Signed-off-by: mbloechli <[email protected]>
…adability Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
…rom parent class Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
Signed-off-by: mbloechli <[email protected]>
…ame -> costmap_frame tf Signed-off-by: mbloechli <[email protected]>
Signed-off-by: Marc Blöchlinger <[email protected]>
74e14ad to
328da2e
Compare
Backport of ros-navigation#6118. Upstream builds the layer on the distance transform InflationLayer from ros-navigation#5933, which Jazzy does not have, so the layer is ported onto Jazzy's InflationLayer instead: * Pass 1 uses Jazzy's InflationLayer::updateCosts for the symmetric baseline. Pass 2 matches upstream and uses distance_transform.hpp, taken unchanged from ros-navigation#5933. Nothing else from ros-navigation#5933 is backported, so Jazzy's InflationLayer keeps its implementation and class layout. * Parameters are declared with Layer::declareParameter, and a single on-set callback validates and applies them, as in Jazzy's other layers. * num_threads and the OpenMP loop are dropped, since Jazzy builds the layers without OpenMP. * plan_topic is resolved in the costmap's parent namespace inside the layer, because Jazzy's Layer has no joinWithParentNamespace. * Includes the null check on the first path message from ros-navigation#6281. * The benchmark is dropped, as Jazzy has no costmap benchmark suite. The tests follow the same changes: nav2_util::LifecycleNode, no activate, deactivate or num_threads cases, and a new case for rejecting negative parameters. (cherry picked from commit 6a8161e) Signed-off-by: mbloechli <[email protected]>
Backport of ros-navigation#6118. Upstream builds the layer on the distance transform InflationLayer from ros-navigation#5933, which Kilted does not have, so the layer is ported onto Kilted's InflationLayer instead, as in the Jazzy backport: * Pass 1 uses Kilted's InflationLayer::updateCosts for the symmetric baseline. Pass 2 matches upstream and uses distance_transform.hpp, taken unchanged from ros-navigation#5933. Nothing else from ros-navigation#5933 is backported, so Kilted's InflationLayer keeps its implementation and class layout. * distance_transform.hpp needs Eigen, so Eigen3 is added as a dependency of the layers library and exported, as ros-navigation#5933 does upstream. * Parameters are declared with Layer::declareParameter, and a single on-set callback validates and applies them, as in Kilted's other layers. * num_threads and the OpenMP loop are dropped, since Kilted builds the layers without OpenMP. * Includes the null check on the first path message from ros-navigation#6281. * The benchmark is dropped, as Kilted has no costmap benchmark suite. The tests follow the same changes: nav2_util::LifecycleNode, no activate, deactivate or num_threads cases, a new case for rejecting negative parameters and one for resolving plan_topic. (cherry picked from commit 6a8161e) Signed-off-by: mbloechli <[email protected]>
…-aware lane-keeping (backport #6118 & #6487) (#6688) * feat(nav2_costmap_2d): backport AsymmetricInflationLayer to Jazzy Backport of #6118. Upstream builds the layer on the distance transform InflationLayer from #5933, which Jazzy does not have, so the layer is ported onto Jazzy's InflationLayer instead: * Pass 1 uses Jazzy's InflationLayer::updateCosts for the symmetric baseline. Pass 2 matches upstream and uses distance_transform.hpp, taken unchanged from #5933. Nothing else from #5933 is backported, so Jazzy's InflationLayer keeps its implementation and class layout. * Parameters are declared with Layer::declareParameter, and a single on-set callback validates and applies them, as in Jazzy's other layers. * num_threads and the OpenMP loop are dropped, since Jazzy builds the layers without OpenMP. * plan_topic is resolved in the costmap's parent namespace inside the layer, because Jazzy's Layer has no joinWithParentNamespace. * Includes the null check on the first path message from #6281. * The benchmark is dropped, as Jazzy has no costmap benchmark suite. The tests follow the same changes: nav2_util::LifecycleNode, no activate, deactivate or num_threads cases, and a new case for rejecting negative parameters. (cherry picked from commit 6a8161e) Signed-off-by: mbloechli <[email protected]> * test(nav2_costmap_2d): clean up rclcpp in asymmetric inflation tests Backport of #6487. The integration tests initialised and shut down rclcpp from a global fixture, which ran at process exit and hung under Zenoh. main() now owns rclcpp::init and rclcpp::shutdown, and the fixture's TearDown releases the layer, costmap, TF buffer and node first. Resolved against Jazzy's nav2_util::LifecycleNode and tf2_ros::Buffer members. (cherry picked from commit f31c7f4) Signed-off-by: mbloechli <[email protected]> --------- Signed-off-by: mbloechli <[email protected]> Co-authored-by: Tony Najjar <[email protected]>
…-aware lane-keeping (backport #6118 & #6487) (#6689) * feat(nav2_costmap_2d): backport AsymmetricInflationLayer to Kilted Backport of #6118. Upstream builds the layer on the distance transform InflationLayer from #5933, which Kilted does not have, so the layer is ported onto Kilted's InflationLayer instead, as in the Jazzy backport: * Pass 1 uses Kilted's InflationLayer::updateCosts for the symmetric baseline. Pass 2 matches upstream and uses distance_transform.hpp, taken unchanged from #5933. Nothing else from #5933 is backported, so Kilted's InflationLayer keeps its implementation and class layout. * distance_transform.hpp needs Eigen, so Eigen3 is added as a dependency of the layers library and exported, as #5933 does upstream. * Parameters are declared with Layer::declareParameter, and a single on-set callback validates and applies them, as in Kilted's other layers. * num_threads and the OpenMP loop are dropped, since Kilted builds the layers without OpenMP. * Includes the null check on the first path message from #6281. * The benchmark is dropped, as Kilted has no costmap benchmark suite. The tests follow the same changes: nav2_util::LifecycleNode, no activate, deactivate or num_threads cases, a new case for rejecting negative parameters and one for resolving plan_topic. (cherry picked from commit 6a8161e) Signed-off-by: mbloechli <[email protected]> * test(nav2_costmap_2d): clean up rclcpp in asymmetric inflation tests Backport of #6487. The integration tests initialised and shut down rclcpp from a global fixture, which ran at process exit and hung under Zenoh. main() now owns rclcpp::init and rclcpp::shutdown, and the fixture's TearDown releases the layer, costmap, TF buffer and node first. Resolved against Kilted's nav2_util::LifecycleNode and tf2_ros::Buffer members. (cherry picked from commit f31c7f4) Signed-off-by: mbloechli <[email protected]> --------- Signed-off-by: mbloechli <[email protected]> Co-authored-by: Tony Najjar <[email protected]>
…-aware lane-keeping (backport ros-navigation#6118 & ros-navigation#6487) (ros-navigation#6688) * feat(nav2_costmap_2d): backport AsymmetricInflationLayer to Jazzy Backport of ros-navigation#6118. Upstream builds the layer on the distance transform InflationLayer from ros-navigation#5933, which Jazzy does not have, so the layer is ported onto Jazzy's InflationLayer instead: * Pass 1 uses Jazzy's InflationLayer::updateCosts for the symmetric baseline. Pass 2 matches upstream and uses distance_transform.hpp, taken unchanged from ros-navigation#5933. Nothing else from ros-navigation#5933 is backported, so Jazzy's InflationLayer keeps its implementation and class layout. * Parameters are declared with Layer::declareParameter, and a single on-set callback validates and applies them, as in Jazzy's other layers. * num_threads and the OpenMP loop are dropped, since Jazzy builds the layers without OpenMP. * plan_topic is resolved in the costmap's parent namespace inside the layer, because Jazzy's Layer has no joinWithParentNamespace. * Includes the null check on the first path message from ros-navigation#6281. * The benchmark is dropped, as Jazzy has no costmap benchmark suite. The tests follow the same changes: nav2_util::LifecycleNode, no activate, deactivate or num_threads cases, and a new case for rejecting negative parameters. (cherry picked from commit 6a8161e) Signed-off-by: mbloechli <[email protected]> * test(nav2_costmap_2d): clean up rclcpp in asymmetric inflation tests Backport of ros-navigation#6487. The integration tests initialised and shut down rclcpp from a global fixture, which ran at process exit and hung under Zenoh. main() now owns rclcpp::init and rclcpp::shutdown, and the fixture's TearDown releases the layer, costmap, TF buffer and node first. Resolved against Jazzy's nav2_util::LifecycleNode and tf2_ros::Buffer members. (cherry picked from commit f31c7f4) Signed-off-by: mbloechli <[email protected]> --------- Signed-off-by: mbloechli <[email protected]> Co-authored-by: Tony Najjar <[email protected]>
Basic Info
Description of contribution in a few bullet points
This contribution adds an Asymmetric Inflation Layer, that encourages lane-keeping behaviour without requiring routing. This works by subscribing to the plan topic -> classifying each lethal obstacle as left or right of the global path, then using asymmetric effective distances to bias the BFS priority queue.
Description of documentation updates required from your changes
The layer will need to be documented along the other layers on the nav2 wiki.
Description of how this change was tested
Future work that may be required in bullet points
For Maintainers:
backport-*.