Skip to content

Multiple planner plugins server for contextual planning - #1269

Merged
SteveMacenski merged 17 commits into
ros-navigation:masterfrom
SteveMacenski:mult_plan
Nov 6, 2019
Merged

SteveMacenski merged 17 commits into
ros-navigation:masterfrom
SteveMacenski:mult_plan

Conversation

@SteveMacenski

@SteveMacenski SteveMacenski commented Oct 22, 2019 •

Copy link
Copy Markdown
Member

This is a draft currently addressing the discussion to allow for multiple planners and controller to be available in each.

Right now its just the planner server being able to host multiple planners, but I wanted to throw this out here early for comments if someone has an issue.

My plan:

  • BT navigator refactor/rename compute path to pose to a general planner, add a name field
  • test we're getting all the good stuff hooked up

If anyone has strong thoughts on plugins within BT at this time, maybe we start here

If anyone has a better name than ComputePlan as the map name for NavfnPlanner plugin, let me know, I'm not good at naming things

@SteveMacenski SteveMacenski changed the title Mult plan Multiple planner plugins server Oct 22, 2019
@codecov

codecov Bot commented Oct 23, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #1269 into master will decrease coverage by 1.04%.
The diff coverage is 25%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1269      +/-   ##
=========================================
- Coverage   38.75%   37.7%   -1.05%     
=========================================
  Files         244     244              
  Lines       11040   11064      +24     
  Branches     4570    4599      +29     
=========================================
- Hits         4278    4172     -106     
- Misses       3884    4054     +170     
+ Partials     2878    2838      -40
Flag Coverage Δ
#project 37.7% <25%> (-1.05%) ⬇️
Impacted Files Coverage Δ
...nav2_behavior_tree/compute_path_to_pose_action.hpp 43.75% <0%> (-6.25%) ⬇️
nav2_system_tests/src/planning/planner_tester.hpp 52% <0%> (ø) ⬆️
nav2_navfn_planner/src/navfn_planner.cpp 48.04% <0%> (ø) ⬆️
nav2_planner/src/planner_server.cpp 23.2% <30.23%> (-2.32%) ⬇️
nav2_core/include/nav2_core/exceptions.hpp 0% <0%> (-100%) ⬇️
...generator_cpp/nav2_msgs/msg/voxel_grid__struct.hpp 0% <0%> (-71.43%) ⬇️
...ontroller/dwb_core/include/dwb_core/exceptions.hpp 0% <0%> (-42.86%) ⬇️
nav2_map_server/src/main.cpp 18.18% <0%> (-36.37%) ⬇️
nav2_costmap_2d/plugins/voxel_layer.cpp 0.46% <0%> (-20.18%) ⬇️
..._dwb_controller/dwb_critics/src/rotate_to_goal.cpp 59.09% <0%> (-18.19%) ⬇️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49f0a12...65dab92. Read the comment docs.

@SteveMacenski
SteveMacenski marked this pull request as ready for review October 23, 2019 00:48
@SteveMacenski

SteveMacenski commented Oct 23, 2019 •

Copy link
Copy Markdown
Member Author

In CI, I'm seeing this error:

12: [bt_navigator-10] [ERROR] [bt_navigator]: Couldn't open input XML file: /opt/overlay_ws/install/nav2_bt_navigator/behavior_trees/navigate_w_replanning_and_recovery.xml

However it can load fine locally. I have other test failures locally on unrelated packages (amcl test, costmap test) that i don't see in the CircleCI CI. I think everything is fine -- but I do recall a recent PR to change the location the the behavior trees are installed.

It seems all PRs right now are failing on this. I'll start on this tomorrow afternoon if no one beats me to it

a8fece3 fixes the XML path issue, but remains the issue with multirobot test failing on finding the spawn_robot node, see #1283

@ghost

ghost commented Oct 24, 2019

Copy link
Copy Markdown

If anyone has a better name than ComputePlan as the map name for NavfnPlanner plugin, let me know, I'm not good at naming things

If we're going to do it this way, well, seems like we should break out djikstra and A* as separate plugins. Then we'd have two ComputePlan plugins with fairly obvious names - "Dijkstra" and "A*". In the meantime, I'd just keep it as Navfn. Just my 2 bits. Take it or leave it.

@SteveMacenski

SteveMacenski commented Oct 24, 2019 •

Copy link
Copy Markdown
Member Author

Well conceptually you could actually load multiple instances of NavFn, one with A* the other with Dij!

But I'm not opposed to it, I can just make a wrapper plugin that sets the use_astar param on bringup. I think it's a little excessive to split them up personally since they accomplish the same class of task, but I dont have a strong opinion

@ghost ghost added the nav2_wg Request discussion in the nav2 working group label Oct 24, 2019
@SteveMacenski SteveMacenski changed the title Multiple planner plugins server Multiple planner plugins server for contextual planning Oct 24, 2019
@mkhansenbot

Copy link
Copy Markdown
Collaborator

I know we discussed this a couple months ago in the WG, but was a design issue ever opened so we could discuss this? I don't understand the use case that this is targeting and why it's an improvement.

I have a couple issues with this we should discuss in the Nav2 WG.

  1. I don't see value in changing the name to "ComputePlan", unless you're not going to pass a pose anymore as "ComputePathToPose" does. I also don't take this change lightly because we've already released a few times and now we're changing the ROS Action API. I would be inclined to either not change it, or support both for at least one release cycle before we deprecate the old way.
  2. I have some concern about the behavior tree node having to know the details of the plugins they want. The actions are currently an abstraction layer between the BT and the implementation, but this seems to remove that abstraction. I could be convinced this is OK I suppose, but I guess I don't really see what problem this is solving?

My thinking right now is that we can add "ComputePlan" but it shouldn't replace "ComputePathToPose".

@ghost

ghost commented Oct 24, 2019

Copy link
Copy Markdown

since they accomplish the same class of task

What do have in mind for this feature, if not that? Every plugin you instantiate takes a goal pose and computes a path. They are all the same class of task, aren't they?

@SteveMacenski

SteveMacenski commented Oct 24, 2019 •

Copy link
Copy Markdown
Member Author

Lets talk in the meeting but high level

I don't understand the use case that this is targeting and why it's an improvement.

This allows multiple plugins for a server, both to share resources (costmaps, tf buffers, etc) and to share action interfaces. There's a planning action with a parameter as to which of the high level primatives to use, right now that's just NavFn mapped to ComputePlan (I think changing the mapped name to ComputePathToPose again would be reasonable).

Conceptually now you can have really interesting behaviors with different types of planners called in the behavior tree at different times. For instance if you have a security robot, then you could have a coverage planner going and once a person is detected, change from a full-space sweeping planner to a compute path to a position planner. Those are two such classes of planners but the list is much larger including multirobot planners, switching planners from static environments to save power to a time-variant planner when its highly dynamic environments. As you suggested in our last conversation, I'm mapping the names of the specific plugins to their tasks to give a level of abstraction between similar coverage vs. time-variant vs. "normal" planners. Another example is a retail robot who's goal is to scan shelves but may be interrupted by a customer to make the robot show them to an aisle, switching planners to a human aware planner would allow that all to happen within the behavior tree structure and without creating unique resources for each planner.

In terms of design doc, that seems overkill. Its just a map of plugins & a string name for planner to use.

ComputePathToPose as the name mapped to NavFn makes sense, but that verbage is extremely restrictive. A planner is not just something to make a plan to a position, there can be other classes of planners. We are indeed changing the action msgs definition, and that's why its important this change goes in right before a new distribution.

I have some concern about the behavior tree node having to know the details of the plugins they want. The actions are currently an abstraction layer between the BT and the implementation, but this seems to remove that abstraction. I could be convinced this is OK I suppose, but I guess I don't really see what problem this is solving?

We also talked about this and agreed that as long as we weren't specifying a plugin but a task to complete (compute path to pose, compute coverage plan, compute short time horizon, etc) and then the server has mapped a plugin to accomplish that task that would be fine.

My thinking right now is that we can add "ComputePlan" but it shouldn't replace "ComputePathToPose".

ComputePathToPose isn't really want the planner server is doing, its what the NavFn plugin happens to be doing, that name really needs to go. It can be remapped to the NavFn-like task of computing a path from start to goal, and I can change the mapped name + BT name for the mapped NavFn planner to that, but the task needs to be more general. ComputePlan or ComputePath and similar is more generic for all uses

Without allowing for contextual planners and controllers, I don't see the point in the behavior tree, so I view this as really critical to getting the advanced behavior and really unlocking the good work you all did on the behavior tree orchestrator

@SteveMacenski

SteveMacenski commented Oct 24, 2019 •

Copy link
Copy Markdown
Member Author

Action items

  • rename ComputePlan back to ComputePathToPose
  • if only 1 planner is in the server and request was empty, use it
  • give a one time warning that none was specified
  • 3 above for controller server too

@SteveMacenski

SteveMacenski commented Oct 25, 2019 •

Copy link
Copy Markdown
Member Author

@mkhansen-intel revisiting this with the reduced scope of: only planners for going to pose are intended, backward compatible if only 1 planner plugin loaded, and renaming the action server "topic" the same...

Is there an issue with leaving the message name as ComputePlan rather than ComputePathToPose to have greater re-usability since the items defined in the message are useful for other planning types? I plan to change all other references to ComputePlan back. If you don't like it, that's fine and I'll change that back too, just verifying your thoughts.

@SteveMacenski SteveMacenski removed the nav2_wg Request discussion in the nav2 working group label Oct 25, 2019
@mkhansenbot

Copy link
Copy Markdown
Collaborator

@mkhansen-intel revisiting this with the reduced scope of: only planners for going to pose are intended, backward compatible if only 1 planner plugin loaded, and renaming the action server "topic" the same...

Yes. Backward compatible meaning the BT doesn't have to include the plugin type. One thing I forgot to mention yesterday was that part of the reason we have an abstract action interface is so that people can implement their own planners in different languages such as Python if they want. Please make sure we don't break that requirement.

Is there an issue with leaving the message name as ComputePlan rather than ComputePathToPose

I'd prefer you didn't, as that will mean the action name and message name are different, that seems confusing.

Again, as I said yesterday in the WG. If you want ComputePlan, you could add it as a new action type, just don't replace the existing ComputePathToPose. This would allow for the BT designer to use either one. The "simple" interface is the same - ComputePathToPose and they don't have to know any details about the implementation, maintaining the abstraction. Or if they want finer granularity control, they can use ComputePlan with the plugin(s) in mind. I think this would be a "best of both worlds" scenario and we could support it long term.

However, it seems you don't want both, so I think the compromise here is what we agreed to. You are basically adding an optional field to the ComputePathToPose action interface that is useful when more than one plugin is used. I'm good with this as I think that since the field is optional we still get to maintain the abstraction by default, and only go under the hood when we want to. Essentially we have exposed some of the underlying details, but made them optional.

@SteveMacenski

SteveMacenski commented Oct 25, 2019 •

Copy link
Copy Markdown
Member Author

Ok. I’ll change the name of the message as well.

I resist the idea of having multiple action servers accomplishing the same task since that will add layers of confusion to a typical user when to use each when both will provide identical behavior in a typical application. This is acceptable for high level operations with GoToPose where we have an action and a topic but for internal structure I think that makes poor design and opens the gate for adding arbitrary number of additional nuanced servers. I believe that an algorithm developer creating a plugin should not have to deal with anything else in the navigation stack to enable their application since this is a ‘pro-user’ feature.

The interface Nav1 used was called GetPlan https://github.com/ros/common_msgs/blob/jade-devel/nav_msgs/srv/GetPlan.srv with mostly the same content and that was not specifying that its a shortest-path planner. There are examples of ros planner plugins using the planner plugin to do coverage and other tasks and fit inside this general interface. It seems to me adding the specification to shortest path planning only is restrictive when it provides adequately the information required for many planning styles that the nav stack in ROS1 did support without an issue. Nav2 will also support if someone ignores the names of everything involved, which encourages off-design uses, or we just name things to be sufficiently general. If the action server name is specific, thats fine it can be remapped, but the message type used shouldn’t tell a user what it can and cannot do in my opinion.

Having the name ComputePathToPose everywhere reinforces the idea that the navigation stack can only support moving a robot from point A to B and that’s incorrect and I do not want people walking away with that impression. This is a configurable navigation solution that is as powerful as the algorithm plugins you can write.

I fundamentally don’t see the harm in using general terms when the interfaces will work for the general case. You and I can both come up with a short list of other planners that don’t fit in this general title, and they wouldnt have in ROS1 either (and they used GetPlan), and that’s when hosting your own server is reasonable when you’re up to something very very niche. The the edges cases shouldn’t affect everything else for defining the general usecase that are good for everyone else. We have a sensor_msgs/PointCloud2, works for 90% of what we need pointcloud datatypes for, but for very very niche things I’ve had to create my own. This is no different as I can see it.

Rabble rabble rabble. I’ll change the message back to. We can continue this spirited inquiry at another point. This will enable what I’m looking for but wouldn’t be clear to outside users that you can do those things.

@orduno

orduno commented Oct 25, 2019

Copy link
Copy Markdown
Contributor

I got a few comments on the PR but I'd like to start with clarifying the action description because the rest depends on this.

The interface Nav1 used was called GetPlan https://github.com/ros/common_msgs/blob/jade-devel/nav_msgs/srv/GetPlan.srv with mostly the same content and that was not specifying that its a shortest-path planner. There are examples of ros planner plugins using the planner plugin to do coverage and other tasks and fit inside this general interface. It seems to me adding the specification to shortest path planning only is restrictive when it provides adequately the information required for many planning styles that the nav stack in ROS1 did support...

I'm ok with adding a field to the message that specifies the type of planning to do (but not the planner to use) for example Shortest, Longest, FastestComputable, Safest. If I understand correctly, that would solve part of the problem you describe.

#goal definition
geometry_msgs/PoseStamped pose
plan_type type
---
#result definition
nav_msgs/Path path
---
#feedback

Other types of plans require more information than a single point, for example, (as you mention above) coverage. For that, I would consider creating a different action.

@mkhansen-intel @crdelsey I have similar comments on the PR for the controller #1292 (comment)

@SteveMacenski

SteveMacenski commented Oct 25, 2019 •

Copy link
Copy Markdown
Member Author

I am summarizing my position, I'm making the changes as requested but mentioning the fact that this interface was taken from ROS1 with a more general name and was used by people to implement other types of planners. I for one already do use that interface for a global coverage plugin.

I don't want to continue beating this with a stick. planner_name is exactly the field you describe. Things are getting renamed to ComputePathToPose

@orduno

orduno commented Oct 25, 2019

Copy link
Copy Markdown
Contributor

...planner_name is exactly the field you describe.

OK, I got confused with the naming. Do you think plan_type would be better?

@SteveMacenski

Copy link
Copy Markdown
Member Author

@orduno see comments in the controller, type and name are meaningful in pluginlib so:

<library path="nav2_navfn_planner">
	<class name="nav2_navfn_planner/NavfnPlanner" type="nav2_navfn_planner::NavfnPlanner" base_class_type="nav2_core::GlobalPlanner">
	  <description></description>
	</class>
</library>

the name is the map-able name for the plugin which can be anything. The type and base-type are the actual classes of the plugin implementations, as specific as you can get. With this notation, we have to make then the parameters name / type as well since the pluginlib authors are going to be the ones adding those configs to the config file after registering their plugin.

So up the chain to the action file definition, we could I suppose flip definitions, but that's pretty un-ideal. I think name is a good suffix, or at least anything that isn't type. We could even make it just planner planner_to_use planning_task ...

@SteveMacenski

Copy link
Copy Markdown
Member Author

If the tag is ComputePathToPose do you think in context we could just use plainly: name, ei

<ComputePathToPose ... ... name="ComputePath"/>

@SteveMacenski

SteveMacenski commented Oct 26, 2019 •

Copy link
Copy Markdown
Member Author

@orduno @mkhansen-intel @crdelsey take a look things have been renamed.

Only place that the word computePlan appears in is the nav2_planner_server callback method: computePlan() since the planner_server computing a plan seems like a reasonable renaming

@SteveMacenski
SteveMacenski force-pushed the mult_plan branch 2 times, most recently from f9416a2 to 1b99a08 Compare October 28, 2019 00:12
<Fallback>
<GoalReached/>
<ComputePathToPose goal="{goal}"/>
<ComputePathToPose goal="{goal}" planner_name="ComputePathToPose"/>

@orduno orduno Oct 29, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not blocking if you really think this is the correct way to go. However, I see the duplication of ComputePathToPose as an indication that something is not quite right.

I understand your intention that this planner_name field will map to some plugin (planner_type) that will actually compute that path. But I think we haven't clarified what is the meaning of the key in that mapping.

I see the following options:

  1. Action name is ComputePathToPose, but now planner_name="nav2_navfn_planner/NavfnPlanner" and remove the mapping altogether from the server. No contextual planning in this case; a user designing a navigation behavior should be familiar with the characteristics of the plan computed by Navfn.
  2. Action name is ComputePathToPose, keep mapping in the server and clarify what is the meaning of the planner_name key. This action is always computing a path to a pose, so does this field refers to some property of the resulting path? e.g. "ShortestPath", "LongestPath", etc. Is so, then planner_name is not the correct name. We start to add some context here.
  3. Change the action name to ComputePath, now the key should provide info if we're computing to a pose, covering some area, going to and back, etc.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'd think the planner name should be the algorithm name which implements the ComputePathToPose action, so here it would be planner_name="Navfn".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

3 was the original thing we discussed in the meeting and was shot down- so I wouldn’t like to revert that unless some critical mass of changes in people’s opinions.

On the name, agreed, any other suggestion, maybe ComputeGridPath since its a grid based wavefront planner?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Optionally, I can just add no xml key. No key & 1 plugin in server will default to the given plugin. Though this feature loses all self-documentation

@orduno orduno Oct 30, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here's option 2.1:

<ComputePathToPose goal="{goal}" path_property="GridBased"/>

Path property could mean anything: lenght/optimality, what representation is used to compute, computation time, etc. but we require the property to plugin mapping to be specified on the nav2_params.yaml:

planner_server:
  ros__parameters:
    path_properties: ["ShortestPath", "FastestComputation", "GridBased", "Safest"]
    path_property_plugin: ["some_package/MPC", "nav2_navfn_planner/NavfnPlanner", ...]

Here the path_property_plugins match the plugin types, but we could use some other name and allow us to set multiple properties to the same plugin type but with different settings:

planner_server:
  ros__parameters:
    path_properties: ["FastestComputation", "GridBased",]
    path_property_plugin: ["NavfnAstar", "NavfnDijkstra"]
    plugin_types: ["nav2_navfn_planner/NavfnPlanner", "nav2_navfn_planner/NavfnPlanner"]
    NavfnDijkstra:
        use_astar: false
    NavfnAstart:
        use_astar: true

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I could live with path_property. Do you think GridBased is a good name to replace ComputePathToPose? Are these 2 names exclusive decisions or do you want them both paired.

@orduno orduno Oct 31, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess GridBased is good enough for now.

I could live with path_property

another option is path_type

Are these 2 names exclusive decisions or do you want them both paired.

I'm not sure what you mean here. Could you elaborate?

@SteveMacenski

Copy link
Copy Markdown
Member Author

@orduno changed names. Merging on CI

@SteveMacenski
SteveMacenski merged commit 48dc74b into ros-navigation:master Nov 6, 2019
savalena pushed a commit to savalena/navigation2 that referenced this pull request Jul 5, 2024
Multiple planner plugins server for contextual planning
Forsyth-Creations pushed a commit to Forsyth-Creations/navigation2 that referenced this pull request Feb 19, 2025
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.

4 participants