Nav2 - ROS2 Navigation Stack¶
Nav2 is the navigation stack for mobile robots designed for ROS2. This package is considered both in research and as well as in industrial applications because of the modularity and the wide range of algorithms that it provides to the user. Nav2 is still considered as an evolving project and new features can be expected every fortnight.
In this tutorial, we just explain on how Nav2 is used in our robots. We encourage the users to check out the detailed official Nav2 documentation page for understanding the concepts surronding it.
In this tutorial for the sake of generality, we will be using neo_m(?)_(?)00. Please fill in with your own robot. For the case of simulation use neo_simulation.
Map is one of the essential component representing the environment based on which the planning algorithm will be able to plan the path for the robot.
For creating a map, we use the slam_toolbox.
Depending on your requirement you can also change the parameters for the mapping under
- Start creating the map, use the following command
ros2 launch neo_m(?)_(?)00 mapping.launch.py parameters:=~/$your_workspace/src/configs/navigation/mapping.yaml
Do not close the launch until saving the map.
- After starting the mapping, you can see the stripes of the maps as shown in the image below.
- Move the robot along your map using teleoperation package.
- After you done creating the map, it will be something like as shown below
To save the map, use the following command
ros2 run nav2_map_server map_saver_cli -f to_your_workspace/src/neo_m(?)_(?)00/configs/navigation/maps/your_map_name
- In the map folder, you can see two files created
In order for the robot to autonomously navigate, we require three important components:
We have a single launch file and a single config file that brings up all the above necessary components.
ros2 launch neo_m(?)_(?)00 navigation.launch.py
ros2 launch neo_nav2_bringup rviz_launch.py
Localize the robot¶
By default we use neo_localization for localization. In order to localize the robot press the “2D Pose Estimate” button and select the robot location on the map.
Sending goal(s) for the robot¶
In order the robot to start navigating autonomous a goal position needs to be defined. Assuming the goal position is given, Nav2 uses the planner to find an optimal path for the robot to the goal location. A controller is deployed by Nav2 for the robot to follow the path.
There are different ways to give the goals for the robot, here we will just explain some of them to get started:
Sending a single goal¶
In order to send just a single goal, press the “Nav2 goal” button and select the desired goal location on the map, as shown in the GIF below:
Sending multiple goals¶
For the people who are interested in sending multiple goals to the robot, No problem! Navigation2 provides a waypoint-following plugin, which would allow us to select multiple goals. For the ease of the user, we have already configured this plugin and ready for use.
In order to select the multiple goals. First, press the “Waypoint / Nav Through Poses Mode” button. The again as same as selecting a single goal, press the “Nav2 goal” button to select your goal location.
Note that, before selecting each goal, it is required to press the “Nav2 goal” button.
Waypoint follower plug-in is a direct replacement for the neo_goal_sequence driver, which our ROS-1 users are familiar with.
Change parameters and algorithms¶
There are different algorithms and corresponding parameters as part of the Navigation2 stack. These parameters can be found under
|Controller||neo_local_planner||TEB and DWB local planner|
All the home-brewed algorithms are explained in the section packages.
Behavior tree is one of the key core concepts that have been adapted into the Navigation-2 stack. Behavior trees in the Nav-2 stack provides the user to easily develop and customize various behaviors that the robot should exhibit. Each behaviors are developed as an individual component and then is integrated into the behavior tree. Thus the behavior tree, provides us with a flexible development environment for solving a particular problem at hand.
By default, all our robot packages carry behavior trees, that you can customize upon your need and application. In order to customize it, you simply need to navigate to
~/your_workspace/src/neo_mp(?)_(?)00/config/navigation/behavior_trees. There you can find behavior trees for
navigating_through_poses . Depending on your application, you can bring about different functionality changes for the task that you want to achieve with your robot.