Install
This page takes a Linux machine to one that builds nano-ros, in about 15
minutes. You install a few host packages, install the nros command, and let
nros setup fetch the toolchains for your board. There is no nano-ros
checkout and no system-wide install: everything lands under ~/.nros.
Before you start
- A Linux host. The book’s steps are tested on Ubuntu 22.04 and 24.04, and the host packages below also cover Fedora and Arch. macOS is not supported.
- ROS 2 with its Zenoh middleware, installed before step 1, as Install ROS 2 first shows.
- A network connection for this install. To install on a machine with no network, see Install options.
Install ROS 2 first
The edition follows your Ubuntu release: Humble on 22.04, Jazzy on 24.04 (Humble has no 24.04 packages). If ROS 2 is already installed, skip to Add the Zenoh middleware.
Follow the official ROS 2 guide for your edition: Humble or Jazzy. Where it offers a choice, take these two:
- The desktop install (
ros-<distro>-desktop). It has everything else this book uses: the message packages nano-ros generates your bindings from, theros2command the Tutorial watches your nodes with, the Cyclone DDS middleware,example_interfacesfor the services chapter, anddemo_nodes_cpp, a ROS 2 talker and listener to test a board against. - The development tools (
ros-dev-tools). They bringcolcon, which the Tutorial uses to build a message package for the ROS 2 side.
Do this before step 1 on Ubuntu, so that step 1’s python3-catkin-pkg
comes from the ROS 2 repository. Taken from Ubuntu’s own archive first, it
blocks ROS’s catkin package, and the ROS install fails with
trying to overwrite '/usr/lib/python3/dist-packages/catkin_pkg/__init__.py'.
If that already happened, sudo apt remove python3-catkin-pkg and run the
ROS 2 install again.
Add the Zenoh middleware
Neither ROS 2 install includes the Zenoh middleware, which nano-ros uses by default. Add it:
# Ubuntu 24.04 (Jazzy); on 22.04, write humble for jazzy
sudo apt-get install -y ros-jazzy-rmw-zenoh-cpp
You source ROS 2 before your first build; the Tutorial shows where.
If adding the ROS 2 repository fails
The official guide looks up the newest ros2-apt-source release through
GitHub’s API. On a network where many machines share one address, such as a
lab, that lookup can answer API rate limit exceeded, and its dpkg -i then
fails on an empty file. These lines add the same repository from a pinned
release, 1.3.0, and ask GitHub for nothing but the file:
sudo apt-get update
sudo apt-get install -y curl ca-certificates software-properties-common
sudo add-apt-repository -y universe
codename="$(. /etc/os-release && echo "$VERSION_CODENAME")"
base=https://github.com/ros-infrastructure/ros-apt-source/releases/download
curl -fL -o /tmp/ros2-apt-source.deb \
"$base/1.3.0/ros2-apt-source_1.3.0.${codename}_all.deb"
sudo dpkg -i /tmp/ros2-apt-source.deb
sudo apt-get update
A newer release works the same way: replace both 1.3.0s with its number.
Then go back to the official guide’s install step.
Optional: a minimal install
For a headless machine, a container or a lab image, the smaller ros-base
install is enough, with two packages it lacks: the Zenoh middleware and
example_interfaces. It has no rviz2, no rqt and no demo nodes.
# Ubuntu 24.04 (Jazzy); on 22.04, write humble for jazzy
sudo apt-get install -y \
ros-jazzy-ros-base \
ros-jazzy-rmw-zenoh-cpp \
ros-jazzy-example-interfaces \
ros-dev-tools
For a lab of many seats, prepare one machine or image with this page and
the first board’s nros setup done, then copy it to each seat. Thirty seats
then download nothing in class, and none of them depends on the network that
day.
Steps
1. Install the host packages
The host needs git, curl, a C toolchain, CMake, Python 3, zstd, and the
Python packages that ROS message generation uses. Run the line for your
distribution.
Debian or Ubuntu:
sudo apt-get update
sudo apt-get install -y git curl ca-certificates build-essential \
cmake clang pkg-config python3 python3-dev zstd \
python3-catkin-pkg python3-empy python3-lark python3-yaml
clang lets each build check a C image’s stack against the size it was
measured to need. Without it the build still succeeds, and says the check
could not run.
Fedora:
sudo dnf install -y git curl ca-certificates gcc gcc-c++ make \
cmake pkgconf-pkg-config python3 python3-devel python3-pip zstd
pip install --user catkin_pkg 'empy==3.3.4' lark PyYAML
Arch:
sudo pacman -S --needed git curl base-devel cmake python python-pip zstd
pip install --user --break-system-packages catkin_pkg 'empy==3.3.4' lark PyYAML
Fedora and Arch ship no packages for the Python side, so the last line installs it with pip, into your home directory. The command finishes with no error, and a package that is already installed is left as it is. Host packages says what each package is for, and how to use a virtual environment instead.
2. Install the nros command
curl -fsSL https://raw.githubusercontent.com/NEWSLabNTU/nano-ros/main/scripts/install.sh | sh
export PATH="$HOME/.nros/bin:$PATH" # install.sh prints this line too
The installer downloads the newest release for your host, checks its checksum, and ends with lines like these:
nros-install: installed 0.6.0-nros8
nros-install: /home/you/.nros/sdk/nros/0.6.0-nros8
nros-install: /home/you/.nros/bin/nros -> /home/you/.nros/sdk/nros/0.6.0-nros8/bin/nros
nros-install: next → nros setup <board> (e.g. `nros setup linux`)
Add the export PATH=… line to your shell’s startup file, such as
~/.bashrc, so that nros is on your PATH in every new terminal.
3. Check the install
nros version
It prints the version of the command, of the code it generates, and of the libraries it was built with:
nros 0.6.0-nros8
codegen version 18
play_launch d9b79f2bf4505a04b5351c83e916aefaadaf805e
ros-launch-manifest v0.2.0
Your numbers are those of the release you installed. The first line is the
release, suffix included: the same 0.6.0-nros8 the installer printed and a
project’s pin names. A nros built from a source checkout has no release, so
it prints 0.6.0 (checkout build, no release version; …) instead.
4. Provision your board
nros setup fetches what a board needs: the cross-compiler, the emulator,
the middleware’s host tools and the board’s sources, plus a Rust toolchain if
the host has none. You do not install a cross-compiler yourself.
nros setup <board> --rmw <zenoh|xrce|cyclonedds>
Replace <board> and the middleware with the ones you run first:
- For the first Tutorial chapter, the emulated Cortex-M3 board:
mps2-an385-freertoswithzenoh. The chapter runs this step for you. - For a talker on this machine:
linuxwithcyclonedds. Cyclone DDS runs inside your process, so it needs no router and no agent. - For any other board, its name from
nros board list.
When the board is ready, the last line names it:
nros setup: linux ready; locked in /home/you/.nros/nros-sdk.lock
A board whose packages are already present prints
nros setup: linux — all packages already present instead.
nros-sdk.lock records which version of each tool and source the store
holds, so another machine can install the same set. Run outside a project,
as here, nros setup writes the store’s own lock, ~/.nros/nros-sdk.lock.
Run inside a project (a directory with a system.toml, a workspace, or a
pinned nros-toolchain.toml), it writes the project’s lock beside them
instead, and that is the one to commit. The nearest project up the path wins.
To move a version a project’s lock records, run nros update.
5. Turn on completion
With completion on, <Tab> completes nros verbs and flags, and the names
they take: nros board show <Tab> lists the board keys, and nros rmw show <Tab> the RMWs. Ask nros for the line your shell needs, naming the shell:
nros completions bash
It prints the line, and the file to add it to:
# Turn on `nros` completion: add this line to ~/.bashrc
source <(COMPLETE=bash nros)
Add that line to the file it names, then open a new terminal. For another
shell, name it instead: nros completions zsh, fish or powershell. With
no name, nros completions uses the shell $SHELL names. In zsh, the line
goes after compinit. The installer and the first nros setup print the
same line.
Inside a workspace, nros interface show std_msgs/msg/St<Tab> completes to
std_msgs/msg/String: the interface types the workspace reaches. It lists
them once nros configure has run there.
If it doesn’t work
nros: command not found. This shell does not have~/.nros/binon itsPATH. Run theexport PATH=…line from step 2, and add it to your shell’s startup file.- The installer stops with a checksum error. The download was cut short
or changed. Run the
curlline again. The installer never installs a release whose checksum it cannot check. nros setupsays it is building from source. The release has no prebuilt package for your host, sonros setupbuilds it. That is normal and takes several minutes.nros setup <board> --dry-runshows the plan before anything is fetched.- Something else.
nros doctorchecks the install: the command, the store under~/.nros, and the version a project pins. It names what is wrong and the command that fixes it.
Troubleshooting covers what goes wrong in the first build and run, such as an unsourced ROS 2 shell.
Next
- Choose your path: the route through the book for your work.
- Run a talker on an emulated board: the first Tutorial chapter.
- Nucleo-F767ZI: a board’s first run, in its emulated twin and then on the board.
- Install options: a specific release, pinning a project, working offline, what each package is for, and ROS 2’s role in detail.