Build and Install — Nav2 1.0.0 documentation (original) (raw)

Install

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

For Iron and Older

source /opt/ros//setup.bash sudo apt install
ros-$ROS_DISTRO-navigation2
ros-$ROS_DISTRO-nav2-bringup
ros-$ROS_DISTRO-turtlebot3*

For Jazzy and Newer

source /opt/ros//setup.bash sudo apt install
ros-$ROS_DISTRO-navigation2
ros-$ROS_DISTRO-nav2-bringup
ros-$ROS_DISTRO-nav2-minimal-tb*

Build

There are a few ways to build Nav2 using:

Tip

For a repeatable, reproducible and streamlined development experience, check the Nav2 documentation on using Dev Containers!

Released Distribution Binaries

To build Nav2, you’ll first need to build or install ROS 2 and related development tools, including: colcon, rosdep and vcstool.

Once your environment is setup, clone the repo, install all dependencies, and build the workspace:

Attention

The branch naming schema for Nav2 is organized by ROS distro, while the default branch for Rolling is main.

source /opt/ros//setup.bash mkdir -p ~/nav2_ws/src && cd ~/nav2_ws git clone https://github.com/ros-navigation/navigation2.git --branch $ROS_DISTRO ./src/navigation2 rosdep install -y
--from-paths ./src
--ignore-src colcon build
--symlink-install

You can then source ~/nav2_ws/install/setup.bash to get ready for demonstrations!

Hint

For more examples on building Nav2 from released distribution binaries, checkout distro.Dockerfile.

Rolling Development Source

Building Nav2 using rolling development source is similar to building Nav2 from released distribution binaries, where instead you build dependencies from source using the main development branches for all ROS based packages. Nav2 does not currently release binaries on rolling, so it must be build from source.

Once your environment is setup, clone the repo and build the workspace:

source /install/setup.bash mkdir -p ~/nav2_ws/src && cd ~/nav2_ws git clone https://github.com/ros-navigation/navigation2.git --branch main ./src/navigation2 git clone https://github.com/ros-navigation/nav2_minimal_turtlebot_simulation.git --branch main ./src/nav2_minimal_turtlebot_simulation rosdep install -r -y
--from-paths ./src
--ignore-src colcon build
--symlink-install

You can then source ~/nav2_ws/install/setup.bash to get ready for demonstrations! It is safe to ignore the rosdep error of from the missing slam_toolbox key.

Hint

If you are using rmw_zenoh_cpp and want to run tests without a Zenoh router, you can enable isolated tests by building with:

colcon build --symlink-install
--cmake-args -DUSE_ISOLATED_TESTS=ON

Hint

For more examples on building Nav2 from rolling development source, checkout source.Dockerfile.

Docker Container Images

Building Nav2 using Docker container images provides a repeatable and reproducible environment to automate and self document the entire setup process. Instead of manually invoking the development tools as documented above, you can leverage the project’s Dockerfiles to build and install Nav2 for various distributions.

Once your system is setup, you can build the Nav2 Dockerfile from the root of the repo:

export ROS_DISTRO=rolling git clone https://github.com/ros-navigation/navigation2.git --branch main docker build --tag navigation2:$ROS_DISTRO
--build-arg FROM_IMAGE=ros:$ROS_DISTRO
--build-arg OVERLAY_MIXINS="release ccache lld"
--cache-from ghcr.io/ros-navigation/navigation2:main
./navigation2

The docker build command above creates a tagged image using the Dockerfile from the context specified using the path to the repo, where build-time variables are set using additional arguments, e.g. passing a set of colcon mixins to configure the workspace build. Check the ARG directives in the Dockerfile to discover all build-time variables available. The command also specifies an external cache source to pull the latest cached image from Nav2’s Container Registry to speed up the build process.

Tip

The images cached from above are used for Nav2 CI, but can also be used with Nav2 Dev Containers!


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.