Build and Install


Nav2 and its dependencies are released as binaries. You may install it via the following to get the latest stable released version:

sudo apt install ros-<distro>-navigation2 ros-<distro>-nav2-bringup ros-<distro>-turtlebot3*

(For Ubuntu 20.04 use this command as the parsing of wildcards have been changed:

sudo apt install ros-<distro>-navigation2 ros-<distro>-nav2-bringup '~ros-<distro>-turtlebot3-.*'


There are 3 ways to build Nav2. Building for a specific released distribution (e.g. eloquent, foxy), build Nav2 on main branch using a quickstart setup script, or building main branch manually.

Build Nav2 For Released Distribution

Install ROS

Please install ROS 2 via the usual build instructions for your desired distribution.

Build Nav2

We’re going to create a new workspace, nav2_ws, clone our Nav2 branch into it, and build. rosdep will be used to get the dependency binaries for Nav2 in your specific distribution.

mkdir -p ~/nav2_ws/src
cd ~/nav2_ws/src
git clone --branch <ros2-distro>-devel
cd ~/nav2_ws
rosdep install -y -r -q --from-paths src --ignore-src --rosdistro <ros2-distro>
colcon build --symlink-install

Note: You need to change --rosdistro to the selected ROS 2 distribution name (e.g eloquent, foxy).

Quickstart Build Main


Install all ROS 2 dependencies from the ROS 2 Installation page. Ensure there are no ROS environment variables set in your terminal or .bashrc file before taking the steps below.*

mkdir <directory_for_workspaces>
cd <directory_for_workspaces>
chmod a+x

Summary of what’s being done

The script downloads three ROS workspaces and then builds them in the correct order. The three workspaces are:

  • ROS 2 release: This is the latest ROS 2 release as defined by the repos file found here
  • ROS 2 dependencies: This is a set of ROS 2 packages that aren’t included in the ROS 2 release yet. However, you need them to be able to build Nav2. This also includes packages that are part of the ROS 2 release where Nav2 uses a different version.
  • Nav2: This repository.

After all the workspaces are downloaded, run the navigation2/tools/ script. builds each repo in the order listed above using the colcon build –symlink-install command.


The accepts the following options:

  • --no-ros2 This skips downloading and building the ROS 2 release. Instead it uses the binary packages and installed in /opt/ros/<ros2-distro>
  • --download-only This skips the build steps

Manually Build Main

Build ROS 2 Main


When building ROS 2 from source, make sure that the ros2.repos file is from the main branch.

Build ROS 2 main using the build instructions provided in the ROS 2 documentation.

Build Nav2 Dependencies

Since we’re not building for a released distribution, we must build the dependencies ourselves rather than using binaries. First, source the setup.bash file in the ROS 2 build workspace.

source ~/ros2_ws/install/setup.bash

Next, we’re going to get the underlay.repos file from Nav2. Then, use vcs to clone the repos and versions in it into a workspace.

source ros2_ws/install/setup.bash
mkdir -p ~/nav2_depend_ws/src
cd ~/nav2_depend_ws
vcs import src < underlay.repos
rosdep install -y -r -q --from-paths src --ignore-src --rosdistro <ros2-distro>
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release

Build Nav2 Main

Finally, now that we have ROS 2 main and the necessary dependencies, we can now build Nav2 main itself. We’ll source the nav2_depend_ws, which will also source the ROS 2 main build workspace packages, to build with dependencies. The rest of this should look familiar.

source ~/nav2_depend_ws/install/setup.bash
mkdir -p ~/nav2_ws/src
cd ~/nav2_ws/src
git clone --branch main
cd ~/nav2_ws
rosdep install -y -r -q --from-paths src --ignore-src --rosdistro <ros2-distro>
colcon build --symlink-install


The official Dockerhub entries are primarily for use in the Nav2 CI, but they may also be used for development. It is useful to have a docker image that tracks Nav2 main branch. The Dockerfile in the root of the repository is recommended for production use, set to your distribution of choice.

It is though generally recomended to install Nav2 releases from the apt repository inside a container if you’d like to use our released binaries.

Building Docker Container

To build an image from the Dockerfile in the Nav2 folder: First, clone the repo to your local system (or see Building the source above)

sudo docker build -t nav2/latest .

If proxies are needed:

sudo docker build -t nav2/latest --build-arg http_proxy= --build-arg https_proxy= .

Note: You may also need to configure your docker for DNS to work. See article here for details:

If you would like to build from dockerhub cache to speed up the build

sudo docker pull rosplanning/navigation2:main
sudo docker build -t nav2/latest --cache-from rosplanning/navigation2:main .

Using DockerHub Container

We allow for you to pull the latest docker image from the main branch at any time. As new releases and tags are made, docker containers on docker hub will be versioned as well to chose from. This docker image will not contain a built overlay, and you must build the overlay Nav2 workspace yourself (see Build Nav2 Main up above).

sudo docker pull rosplanning/navigation2:main

Generate Doxygen

Run doxygen in the root of the Nav2 repository. It will generate a /doc/* directory containing the documentation. The documentation entrypoint in a browser is index.html.