For the complete documentation index, see llms.txt. This page is also available as Markdown.

Global Planning

In this tutorial, we will learn how to configure the global planner in a static environment (i.e. no moving obstacles).

The global planner is the algorithm that takes a start location and goal location and calculates a path between the two locations that does not collide with obstacles.

Global Planner Demo

To demonstrate how the global planner works, we will be using an offline interactive demonstration that uses neither the real robot or the simulator. All you need is the location of the map you created in the previous tutorial.

ros2 launch stretch_nav2 global_plan_demo.launch.py map_yaml:=/PATH/TO/MAP.yaml

This should launch RViz with only your map initially displayed.

base

At the top of the RViz window, there are two tools:

  • 2D Pose Estimate

  • 2D Goal Pose

These tools are used to specify the start and goal positions.

  1. Click 2D Pose Estimate and select a starting pose on the map.

  2. Click 2D Goal Pose and select a goal pose.

  3. Once both poses are specified, a red path should appear connecting them, assuming a valid path exists.

base

Taking Up Space

However, note that the calculated path (at least in this example) travels very close to the walls. The path travels only through unoccupied cells of the map, but it also assumes that the robot takes up no space. There are multiple ways to work around this, but for computational efficiency, we keep the planner the same and change the map that planning is performed on.

To do that, we are going to edit the global costmap configuration. The global costmap is used for the global planner. For purposes of this demo, the file is located at stretch_nav2/config/planner_demo.yaml. Once you make changes to this file, you may need to recompile for your changes to take effect.

For now, simply comment out the line that reads plugins: [static_layer] and uncomment the line that reads plugins: [static_layer, inflation_layer]. When you rerun the demo, you should see something similar to this:

base

The global planning algorithm will now stay at least 0.22 meters away from any obstacle. By enabling the inflation layer, we "inflated" each obstacle so that there was impassible space for 0.22 meters around each obstacle.

If we wanted to increase that space so that the robot absolutely could not move any closer to obstacles, we could simply increase the robot_radius and inflation_radius parameters in the parameter file. Try increasing both values to 0.7 and you get this:

base

Note that now there is more blocked space around each obstacle, but that also includes making it so that the doorways cannot be drive through anymore.

To give the planning algorithm a preference for staying away from obstacles, but not blocking that space entirely if needed, we can set the inflation radius to have a larger value than the robot radius, for example, robot_radius=0.22 and inflation_radius=0.7.

base

Note: setting the inflation radius to be less than the robot radius generally does not make sense, and will have equivalent behavior to setting the robot radius to be equal to the inflation radius.

We will learn more about configuring the costmaps in a later tutorial.

Configuring the Planner

The default planner is NavFn, a standard grid-based planner. You can also experiment with different planners by changing the planner_plugins parameter in planner_demo.yaml. This demo will visualize the planned paths for all of the plugins specified.

base

Last updated

Was this helpful?