Robotics StackExchange | Archived questions

navigation2 switching planners and controllers dynamically

I need to switch in runtime between different planners and controllers. I used to do that in ROS1 navigation stack using the dynamic_reconfigure server.

Is this functionality available in navigation2. How could I do that?

Asked by Pablo IƱigo Blasco on 2020-11-11 17:29:58 UTC

Comments

Answers

Since planner and control servers are implemented with the use of actions in navigation2, you can specify the planner_id or controller_id to specify a particular one in run time by specifying related fields in action definition. for instance you will see a planner_id field, fill that programmatically on run time.

#goal definition
geometry_msgs/PoseStamped goal
geometry_msgs/PoseStamped start
string planner_id
bool use_start # If true, use current robot pose as path start, if false, use start above instead
---
#result definition
nav_msgs/Path path
builtin_interfaces/Duration planning_time
---
#feedback

Take a look at how to configure planners here, you will need to append the array of strings that refers to names of planner plugins

planner_server:
  ros__parameters:
    expected_planner_frequency: 20.0
    planner_plugins: ['GridBased1', 'GridBased2']
    GridBased1:
      plugin: 'nav2_navfn_planner/NavfnPlanner'

    GridBased2:
      plugin: 'some_planner/SomePlanner'

Then in the action call you would specify planner_id as one of ['GridBased1', 'GridBased2'] same should apply to the controllers.

Asked by Fetullah Atas on 2021-07-18 08:53:28 UTC

Comments