-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix InflationLayer resource locking problem (#1931) #1936
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ | |
|
|
||
| #include <map> | ||
| #include <vector> | ||
| #include <mutex> | ||
|
|
||
| #include "rclcpp/rclcpp.hpp" | ||
| #include "nav2_costmap_2d/layer.hpp" | ||
|
|
@@ -77,7 +78,7 @@ class InflationLayer : public Layer | |
| public: | ||
| InflationLayer(); | ||
|
|
||
| ~InflationLayer() override = default; | ||
| ~InflationLayer(); | ||
|
|
||
| void onInitialize() override; | ||
| void updateBounds( | ||
|
|
@@ -115,6 +116,13 @@ class InflationLayer : public Layer | |
| return cost; | ||
| } | ||
|
|
||
| // Provide a typedef to ease future code maintenance | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need either the object or the method, its already provided for you since you derive from the costmap layer class which has a costmap2D in the inheritance tree https://github.com/ros-planning/navigation2/blob/aaa97902c1e1bb9a509c4ee0d88b880afb528f20/nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d.hpp#L314
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought so first, but actually So I needed to redefine them.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh got it, thanks. @AlexeyMerzlyakov maybe the costmap filter base class should just be a layer and not a costmap layer, then you won't have that pesky Thanks for that note, I hadn't recognized that subtly.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good point to have in BTW, from first sight it looks like Finally, this PR was merged, but I can not find any commit in the master/main branch related to. Am I wrong, or is it some merge problem?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need the locking in update functions for costmap filters necessarily. Inflation needs it because it has an async callback function editing a cache table that is also used by update (that could be called at the same time). I think how we've designed the costmap filters layer, there's no chance for that because we don't even allow it to update anything until after we've received something over the topic and set the variable. We should though look over it again and verify that is true. The update with XYZ doesn't need a lock because we're updating the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I've got your point. This indeed will be excessive. |
||
| typedef std::recursive_mutex mutex_t; | ||
| mutex_t * getMutex() | ||
| { | ||
| return access_; | ||
| } | ||
|
|
||
| protected: | ||
| void onFootprintChanged() override; | ||
|
|
||
|
|
@@ -184,6 +192,7 @@ class InflationLayer : public Layer | |
|
|
||
| // Indicates that the entire costmap should be reinflated next time around. | ||
| bool need_reinflation_; | ||
| mutex_t * access_; | ||
| }; | ||
|
|
||
| } // namespace nav2_costmap_2d | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.