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

Refactor/observation buffer #4890

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kfabian
Copy link
Contributor

@kfabian kfabian commented Jan 31, 2025


Basic Info

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

Description of contribution in a few bullet points

  • Changed the Observation class to store the value of the point cloud instead of a ptr to it, which simplified the class because there is no need for user implemented destructor and copy constructor anymore.
  • Changed the ObservationBuffer to store a shared_ptrs of the Observations so that no deep copies of the point clouds are made when querying the buffer

Description of documentation updates required from your changes

Description of how this change was tested

  • Existing tests for costmap
  • Added basic unit test for ObservationBuffer

Future work that may be required in bullet points

  • The ObservationBuffer has lock and unlock member functions. In my opinion this error prone, the ObservationBuffer should either be thread safe on its own (by not exposing the mutex, but locking it in the implementation when needed) or it should not have the mutex member at all and the calling code would be responsible.

For Maintainers:

  • Check that any new parameters added are updated in docs.nav2.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

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

Signed-off-by: Fabian König <fabiankoenig@gmail.com>
observation_list_.erase(std::next(observation_list_.begin()), observation_list_.end());
} else {
// otherwise remove all observations that are older then the keep time
observation_list_.remove_if([now = clock_->now(), this](const auto observation){
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous implementation was assuming that the observation_list_ was ordered, but I think that is not guaranteed.

Copy link

codecov bot commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
...costmap_2d/include/nav2_costmap_2d/observation.hpp 100.00% <100.00%> (+37.50%) ⬆️
..._2d/include/nav2_costmap_2d/observation_buffer.hpp 100.00% <ø> (ø)
...tmap_2d/include/nav2_costmap_2d/obstacle_layer.hpp 100.00% <ø> (ø)
...tmap_2d/plugins/costmap_filters/costmap_filter.cpp 89.33% <100.00%> (ø)
nav2_costmap_2d/plugins/obstacle_layer.cpp 82.05% <100.00%> (-0.12%) ⬇️
nav2_costmap_2d/plugins/voxel_layer.cpp 94.82% <100.00%> (ø)
nav2_costmap_2d/src/observation_buffer.cpp 98.59% <100.00%> (+8.05%) ⬆️

... and 2 files with indirect coverage changes

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.

1 participant