Install ROS 2 Jazzy and Zenoh on Ubuntu 24.04
This blog shows how to install ROS 2 on Ubuntu 24.04, and how we use Zenoh as the middleware for communication.
1. Set a UTF-8 locale
locale # if it already shows UTF-8, skip to step 2
sudo apt update && sudo apt install -y locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
2. Enable the Universe repo and add the ROS 2 apt source
sudo apt install -y software-properties-common curl
sudo add-apt-repository -y universe
export ROS_APT_SOURCE_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F\" '{print $4}')
echo "ros-apt-source version: '${ROS_APT_SOURCE_VERSION}'" # must not be empty (e.g. 1.3.0)
curl -fL -o /tmp/ros2-apt-source.deb \
"https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.$(. /etc/os-release && echo ${UBUNTU_CODENAME:-${VERSION_CODENAME}})_all.deb"
sudo dpkg -i /tmp/ros2-apt-source.deb
The ros2-apt-source package installs both the signing key and the repo entry.
It's the method the official docs currently recommend.
If dpkg fails with unexpected end of file in archive magic version number, the download was a 9-byte Not Found page, because ROS_APT_SOURCE_VERSION was empty (the GitHub API call failed or was rate-limited, or the variable was set in a different shell). Set the version by hand and download again:
export ROS_APT_SOURCE_VERSION=1.3.0
curl -fL -o /tmp/ros2-apt-source.deb \
"https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.noble_all.deb"
sudo dpkg -i /tmp/ros2-apt-source.deb
3. Install ROS 2 Jazzy and the dev tools
sudo apt update && sudo apt upgrade -y
sudo apt install -y ros-jazzy-desktop ros-dev-tools
ros-jazzy-desktop includes RViz and the demos. If you want something smaller, use ros-jazzy-ros-base instead. ros-dev-tools provides colcon, rosdep and vcstool.
4. Install Zenoh middleware
Zenoh is an alternative to the DDS middle layer. We will use it in the following sections.
sudo apt install -y ros-jazzy-rmw-zenoh-cpp
5. Set up rosdep and your shell
sudo rosdep init
rosdep update
echo "source /opt/ros/jazzy/setup.bash" >> ~/.bashrc
source ~/.bashrc
6. Verify the install
In two different terminals, run two nodes separately:
ros2 run demo_nodes_cpp talker
ros2 run demo_nodes_py listener
7. Use Zenoh
To test with Zenoh, start the router first, in one terminal, run:
ros2 run rmw_zenoh_cpp rmw_zenohd
Then, in another two terminals, run those commands with the Zenoh RMW separately:
export RMW_IMPLEMENTATION=rmw_zenoh_cpp ros2 run demo_nodes_cpp talker
export RMW_IMPLEMENTATION=rmw_zenoh_cpp ros2 run demo_nodes_py listener