The Ultimate Guide to the ROS 2 Navigation Stack – Foxy

4-launch-basic-mobile-robot-v5-2

In the tutorials below, we will cover the ROS 2 Navigation Stack (also known as Nav2) in detail, step-by-step. The ROS 2 Navigation Stack is a collection of software packages that you can use to help your mobile robot move from a starting location to a goal location safely. Here will be our final output:

Navigation in a known environment with a map
Navigation in an unknown environment without a map

Credit to Ramkumar Gandhinathan and Lentin Joseph’s awesome book ROS Robotics Projects Second Edition (Disclosure: As an Amazon Associate I earn from qualifying purchases) for the world file, which comes from their book’s public GitHub page.

Real-World Applications

The ROS 2 Navigation Stack can be used in a number of real-world robotic applications: 

  • Ground Delivery
  • Hospitals and Medical Centers
  • Hotels (Room Service)
  • Offices
  • Restaurants
  • Warehouses
  • And more…

In this project, we will work with a simulated robot in a simulated world. Roboticists like to simulate robots before building them in order to test out different algorithms. You can imagine the cost of making mistakes with a physical robot can be high (e.g. crashing a mobile robot into a wall at high speed means lost money).

Let’s get started!

Prerequisites

  • ROS 2 Foxy Fitzroy installed on Ubuntu Linux 20.04
    • If you are using another ROS 2 distribution, you will need to replace ‘foxy’ with the name of your distribution everywhere I mention ‘foxy’ in this tutorial. 
    • I highly recommend you get the newest version of ROS 2. If you are using a newer version of ROS 2, you can still follow most of the steps in this tutorial. I will point out the areas where you will need to do things differently.
  • You have already created a ROS 2 workspace. The name of our workspace is “dev_ws”, which stands for “development workspace.” 

For future reference, here is a complete package (named ‘two_wheeled_robot‘) I developed that uses both URDF and SDF robot model files with the ROS 2 Navigation Stack. You can use this as a template after you have gone through the tutorials below.

Directions

Complete the following five tutorials in order, step by step. When you are done, you will have a deep understanding of the ROS 2 Navigation Stack and will be ready to confidently use this package in your own robotics projects.

  1. How to Create a Simulated Mobile Robot in ROS 2 Using URDF
  2. Set Up the Odometry for a Simulated Mobile Robot in ROS 2
  3. Sensor Fusion Using the Robot Localization Package – ROS 2
  4. Set Up LIDAR for a Simulated Mobile Robot in ROS 2
  5. Navigation and SLAM Using the ROS 2 Navigation Stack

Enjoy!