Skip to content

3732 costmap raw update msgs#3948

Closed
emsko wants to merge 17 commits intoros-navigation:mainfrom
emsko:3732_costmap_raw_update_msgs
Closed

3732 costmap raw update msgs#3948
emsko wants to merge 17 commits intoros-navigation:mainfrom
emsko:3732_costmap_raw_update_msgs

Conversation

@emsko
Copy link
Contributor

@emsko emsko commented Nov 8, 2023


Basic Info

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

Description of contribution in a few bullet points

  • Adding new msg type CostmapUpdate.msg,
  • Adding CostmapUpdate publisher to Costmap2DPublisher class,
  • Re-implementation of the CostmapSubscriber class to support the CostmapUpdate msg.

Description of documentation updates required from your changes


Future work that may be required in bullet points

  • I see a lot of redundancy in Costmap2DPublisher class while creating the msgs, adding methods that are responsible for populating msgs and return the unique ptr to msgs might improve the code readability

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

}

void Costmap2DPublisher::publishCostmap()
std::unique_ptr<nav2_msgs::msg::CostmapUpdate> Costmap2DPublisher::get_raw_costmap_update_msg()
Copy link
Contributor

Choose a reason for hiding this comment

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

I was just wondering if you could kindly explain why you use std::unique_ptr for the return type.
Returning the variable with std::unique_ptr is unnecessary due to Return Value Optimization (RVO).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Publishing the std::unique_ptr instead of raw msg is a principle adopted in this project, so that is why I've decided to create msg in unique_ptr directly.
Change publishers to publish unique ptrs

I believe that the cause for that is related with Publisher class implementation.
When calling publish(const T & msg) additional copy of msg is made when using the intra-process communication
publisher.hpp:L278, and in the end you have a copy stored in the unique_ptr and pass the ownership further.
When using publish(std::unique_ptr<MessageT, MessageDeleter> msg) you are omitting this copy. Also please take a look at the comments describing each of the overloaded methods.

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.

Overall, very few notes, well done!

This does require some unit testing to make sure it works as expected 😄

costmap_update_pub_->publish(std::move(update));
}
if (costmap_raw_update_pub_->get_subscription_count() > 0) {
costmap_raw_update_pub_->publish(createRawCostmapUpdateMsg());
Copy link
Member

Choose a reason for hiding this comment

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

Always do std::move() on unique pointers when publishing for explicit ownership semantics. It helps with topic jitter, especially for larger topics like this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, I believe that using std::move() explicitly might cause an unnecessary call to the move constructor of unique_ptr.
I have run a toy example which showed that due to RVO/NRVO optimization, no additional call to the constructor was made. However, when calling std::move() I triggered the move constructor.
When I turned off the optimization I also had a call to move constructor.

So to sum up, we are ending up with the move constructor call in the worst-case scenario, but when calling move, it is more likely, because it seems like it blocks RVO.

emsko and others added 2 commits November 9, 2023 19:35
Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>
@SteveMacenski
Copy link
Member

@emsko please don't hit "resolve" on things that haven't been pushed / completed yet. I went through and unresolved a number of items that haven't been addressed yet. It helps with my tracking of status 😄

@SteveMacenski
Copy link
Member

SteveMacenski commented Nov 15, 2023

Try rebasing and pushing a new PR with a new branch. Something is not quite right here the fact that some of your commits are not appearing on github's diff UX. Everytime that's happened in the past and I overlooked it as a quirk of github messing something up, there ended up being real issues that bit us in the butt later.

I agree the commits you link to in the github review comments appear to fix it, but the fact that I can't see that points to something being a little fishy which I want to make sure is resolved.

@emsko
Copy link
Contributor Author

emsko commented Nov 15, 2023

@SteveMacenski I have opened a new PR with rebased changes as you asked: #3965 , so hopefully the issues with Github are resolved now.
Shall we close this PR and move with the review to the new one?
I am still working on tests so there are going to be a couple more commits.

@SteveMacenski
Copy link
Member

Yes, sounds good! I see things properly now in the new PR

SteveMacenski added a commit that referenced this pull request Nov 27, 2023
…) (#3965)

* Adding CostmapUpdate msg

* CostmapRawUpdate Publisher

* remove test logs and typos

* change data type to uint8

* pass unique ptr to raw costmap update publisher

* adding subsriber for updates

* -Werror=type-limits for update lower bounds checking

* copy update msg

* change code formatting

* adding lock guards on costmap in footprint_collision_checker.cpp

* adding lock guards for costmap subscriber clients

* review suggestions implementation

* fixing gtests errors

* changes after second round of review

* Update nav2_msgs/msg/CostmapUpdate.msg

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Integration test for costmap subscriber draft

* Change the current grid parameters in separate method

* WIP int test

* adding method in PublisherCostmap2D for OccupancyGridUpdate population

* test full costmap and updates while generating results

* Integration tests for subscribers

* Expected number of msgs related to number of mapchanges in tests

* next round of reviews

* refactor names of Costmap2DPublisher

* remove unnecessary costmap_received_ flag form CostmapSubscriber

---------

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>
jwallace42 pushed a commit to jwallace42/navigation2 that referenced this pull request Jan 3, 2024
…-navigation#3948) (ros-navigation#3965)

* Adding CostmapUpdate msg

* CostmapRawUpdate Publisher

* remove test logs and typos

* change data type to uint8

* pass unique ptr to raw costmap update publisher

* adding subsriber for updates

* -Werror=type-limits for update lower bounds checking

* copy update msg

* change code formatting

* adding lock guards on costmap in footprint_collision_checker.cpp

* adding lock guards for costmap subscriber clients

* review suggestions implementation

* fixing gtests errors

* changes after second round of review

* Update nav2_msgs/msg/CostmapUpdate.msg

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Integration test for costmap subscriber draft

* Change the current grid parameters in separate method

* WIP int test

* adding method in PublisherCostmap2D for OccupancyGridUpdate population

* test full costmap and updates while generating results

* Integration tests for subscribers

* Expected number of msgs related to number of mapchanges in tests

* next round of reviews

* refactor names of Costmap2DPublisher

* remove unnecessary costmap_received_ flag form CostmapSubscriber

---------

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>
Signed-off-by: gg <josho.wallace@gmail.com>
enricosutera pushed a commit to enricosutera/navigation2 that referenced this pull request May 19, 2024
…-navigation#3948) (ros-navigation#3965)

* Adding CostmapUpdate msg

* CostmapRawUpdate Publisher

* remove test logs and typos

* change data type to uint8

* pass unique ptr to raw costmap update publisher

* adding subsriber for updates

* -Werror=type-limits for update lower bounds checking

* copy update msg

* change code formatting

* adding lock guards on costmap in footprint_collision_checker.cpp

* adding lock guards for costmap subscriber clients

* review suggestions implementation

* fixing gtests errors

* changes after second round of review

* Update nav2_msgs/msg/CostmapUpdate.msg

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Integration test for costmap subscriber draft

* Change the current grid parameters in separate method

* WIP int test

* adding method in PublisherCostmap2D for OccupancyGridUpdate population

* test full costmap and updates while generating results

* Integration tests for subscribers

* Expected number of msgs related to number of mapchanges in tests

* next round of reviews

* refactor names of Costmap2DPublisher

* remove unnecessary costmap_received_ flag form CostmapSubscriber

---------

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>
Signed-off-by: enricosutera <enricosutera@outlook.com>
Marc-Morcos pushed a commit to Marc-Morcos/navigation2 that referenced this pull request Jul 4, 2024
…-navigation#3948) (ros-navigation#3965)

* Adding CostmapUpdate msg

* CostmapRawUpdate Publisher

* remove test logs and typos

* change data type to uint8

* pass unique ptr to raw costmap update publisher

* adding subsriber for updates

* -Werror=type-limits for update lower bounds checking

* copy update msg

* change code formatting

* adding lock guards on costmap in footprint_collision_checker.cpp

* adding lock guards for costmap subscriber clients

* review suggestions implementation

* fixing gtests errors

* changes after second round of review

* Update nav2_msgs/msg/CostmapUpdate.msg

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Integration test for costmap subscriber draft

* Change the current grid parameters in separate method

* WIP int test

* adding method in PublisherCostmap2D for OccupancyGridUpdate population

* test full costmap and updates while generating results

* Integration tests for subscribers

* Expected number of msgs related to number of mapchanges in tests

* next round of reviews

* refactor names of Costmap2DPublisher

* remove unnecessary costmap_received_ flag form CostmapSubscriber

---------

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>
Marc-Morcos pushed a commit to Marc-Morcos/navigation2 that referenced this pull request Jul 4, 2024
…-navigation#3948) (ros-navigation#3965)

* Adding CostmapUpdate msg

* CostmapRawUpdate Publisher

* remove test logs and typos

* change data type to uint8

* pass unique ptr to raw costmap update publisher

* adding subsriber for updates

* -Werror=type-limits for update lower bounds checking

* copy update msg

* change code formatting

* adding lock guards on costmap in footprint_collision_checker.cpp

* adding lock guards for costmap subscriber clients

* review suggestions implementation

* fixing gtests errors

* changes after second round of review

* Update nav2_msgs/msg/CostmapUpdate.msg

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Integration test for costmap subscriber draft

* Change the current grid parameters in separate method

* WIP int test

* adding method in PublisherCostmap2D for OccupancyGridUpdate population

* test full costmap and updates while generating results

* Integration tests for subscribers

* Expected number of msgs related to number of mapchanges in tests

* next round of reviews

* refactor names of Costmap2DPublisher

* remove unnecessary costmap_received_ flag form CostmapSubscriber

---------

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>
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.

3 participants