Skip to content

Instantly share code, notes, and snippets.

@vrbadev
Last active June 21, 2024 05:31
Show Gist options
  • Save vrbadev/ec168a0940d45f523bf050011d7dff75 to your computer and use it in GitHub Desktop.
Save vrbadev/ec168a0940d45f523bf050011d7dff75 to your computer and use it in GitHub Desktop.
[TUTORIAL] How to install ROS Noetic on Debian 12 Bookworm

Tutorial: How to install ROS Noetic on Debian 12 Bookworm

This is a short tutorial on building ROS Noetic in the Debian 12 ("bookworm") fresh-install environment. There are several packages not available (yet) from the official apt repositories, which have to be either built from source or installed from older Debian 11 ("bullseye") repository DEB packages. Several packages also have to be downgraded to maintain compatibility.

Preparation

  1. Add ROS repository for older Debian 10 ("buster") to our apt sources list:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu buster main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update -y
sudo apt-get upgrade -y
  1. Install the needed packages using apt:
sudo apt install -y build-essential cmake curl python3-rosdep python3-rosinstall-generator python3-wstool python3-rosinstall python3-empy python3-pip python3-catkin python3-catkin-pkg python3-catkin-pkg-modules python3-catkin-tools
  1. Initialise rosdep:
sudo rosdep init
rosdep update
  1. Create a catkin workspace where we are going to build the ROS Noetic distribution and enter it:
mkdir -p ~/ros_catkin_ws && cd ~/ros_catkin_ws
  1. Create a directory for missing/broken apt packages and enter it:
mkdir apt_fix && cd apt_fix
  1. Fix: We have to build missing package hddtemp package from source, e.g., using the following commands:
sudo apt install -y packaging-dev debian-keyring devscripts equivs
dget -x http://deb.debian.org/debian/pool/main/h/hddtemp/hddtemp_0.3-beta15-54.dsc
cd hddtemp-0.3-beta15
sudo mk-build-deps --install --remove
dpkg-buildpackage -us -uc
sudo apt install -y ../hddtemp_*_*.deb
sudo apt purge -y hddtemp-build-deps
cd ..
  1. Fix: We will download and install the other missing packages from bullseye repo:
wget http://archive.ubuntu.com/ubuntu/pool/universe/g/geographiclib/libgeographic-dev_1.49-2_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/g/geographiclib/libgeographic17_1.49-2_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/o/orocos-kdl/liborocos-kdl1.4_1.4.0-7build2_amd64.deb
wget http://ftp.de.debian.org/debian/pool/main/o/ogre-1.9/libogre-1.9.0v5_1.9.0+dfsg1-12.1_amd64.deb
wget http://ftp.de.debian.org/debian/pool/main/o/ogre-1.9/libogre-1.9-dev_1.9.0+dfsg1-12.1_amd64.deb
wget http://ftp.de.debian.org/debian/pool/main/l/log4cxx/liblog4cxx11_0.11.0-2_amd64.deb
wget wget http://ftp.de.debian.org/debian/pool/main/l/log4cxx/liblog4cxx-dev_0.11.0-2_amd64.deb

sudo apt install -y ./libgeographic17_1.49-2_amd64.deb ./libgeographic-dev_1.49-2_amd64.deb ./liborocos-kdl1.4_1.4.0-7build2_amd64.deb ./libogre-1.9.0v5_1.9.0+dfsg1-12.1_amd64.deb ./libogre-1.9-dev_1.9.0+dfsg1-12.1_amd64.deb ./liblog4cxx11_0.11.0-2_amd64.deb ./liblog4cxx-dev_0.11.0-2_amd64.deb
  1. Fix: The bookworm repositories don't contain Python 2.7 anymore. Thus download and install pypy with Python 2.7 executable and create symlinks to the binaries, install pip2 and install the future package:
wget https://downloads.python.org/pypy/pypy2.7-v7.3.12-linux64.tar.bz2
tar xvf pypy2.7-v7.3.12-linux64.tar.bz2
sudo mv pypy2.7-v7.3.12-linux64 /opt/pypy2.7
sudo ln -s /opt/pypy2.7/bin/python2.7 /usr/bin/python2
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
sudo python2 get-pip.py
sudo ln -s /opt/pypy2.7/bin/pip2 /usr/bin/pip2
sudo pip2 install future
  1. Fetch ROS packages list of corresponding git repositories. Replace desktop with ros_comm for a minimal ROS installation.
cd ~/ros_catkin_ws
rosinstall_generator desktop --rosdistro noetic --deps --wet-only --tar | tee ./noetic.rosinstall

Optional: Add mavros ROS packages to the build:

rosinstall_generator --rosdistro kinetic mavlink | tee -a ./noetic.rosinstall
rosinstall_generator --rosdistro noetic --upstream mavros | tee -a ./noetic.rosinstall
  1. Fix: wstool would probably throw the following error: load() missing 1 required positional argument: 'Loader' for each of the packages. This can be simply fixed by replacing yaml.load function with yaml.safe_load in the corresponding vcstools script:
sudo sed -i 's/yaml.load/yaml.safe_load/g' /usr/lib/python3/dist-packages/vcstools/tar.py
  1. Initialize the source directory using the list:
wstool init src ./noetic.rosinstall
  1. Enter the src directory and add/replace the following git repos (because they the clone is incomplete), you can also add next ROS packages (and their dependency ROS packages) as you wish:
cd src
# git clone -b master https://github.com/ros/roslint.git
# git clone -b noetic-devel https://github.com/ros/diagnostics.git
rm -rf common_msgs && git clone -b noetic-devel https://github.com/ros/common_msgs.git # incomplete
# git clone -b master https://github.com/ros/angles.git
# git clone -b noetic-devel https://github.com/ros/geometry.git
rm -rf geometry2 && git clone -b noetic-devel https://github.com/ros/geometry2.git # missing tf2_eigen
# git clone -b noetic-devel https://github.com/ros/actionlib.git
# git clone -b kinetic-devel https://github.com/ros/rosconsole_bridge.git
# git clone -b melodic-devel https://github.com/ros/urdf.git
# git clone -b noetic-devel https://github.com/ros/dynamic_reconfigure.git
# git clone -b noetic-devel https://github.com/ros/nodelet_core.git
# git clone -b kinetic-devel https://github.com/ros/bond_core.git
# git clone -b noetic-devel https://github.com/ros-perception/image_common.git
git clone -b noetic-devel https://github.com/ros-perception/pcl_msgs.git
git clone -b melodic-devel https://github.com/ros-perception/perception_pcl.git
git clone -b master https://github.com/ros-geographic-info/unique_identifier.git
git clone -b master https://github.com/ros-geographic-info/geographic_info.git
git clone -b noetic-devel https://github.com/clearpathrobotics/robot_upstart.git
git clone -b kinetic-devel https://github.com/ros-controls/control_msgs.git
# git clone -b noetic-devel https://github.com/ros-controls/control_toolbox.git
git clone -b noetic-devel https://github.com/ros-controls/realtime_tools.git
# rm -rf mavlink && git clone https://github.com/mavlink/mavlink.git # if version from generator causes compilation errors
cd ..
  1. Install remaining dependencies using rosdep:
rosdep install -y --from-paths src --ignore-src --rosdistro noetic --os=debian:buster -r
  1. By now, everything should be ready so we build all the ROS packages and install them into /opt/ros/noetic directory:
sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/noetic
  1. Source the ROS distro on each bash terminal startup:
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

Enjoy ROS Noetic on Debian 12!

Note: If you follow this guide including all optional steps, 211 ROS packages will be built and installed in total.

@MoatazAsem
Copy link

I tried to do it on raspi5, but when i ran roscore i got this error (ModuleNotFoundError: No module named 'rosgraph_msgs')

@vrbadev
Copy link
Author

vrbadev commented May 19, 2024

I tried to do it on raspi5, but when i ran roscore i got this error (ModuleNotFoundError: No module named 'rosgraph_msgs')

The module is probably missing from the workspace for some reason. You can clone it manually to the source folder from github.com/ros/ros_comm_msgs, which should solve your problem.

@BrysonSmith15
Copy link

I am on step 14. After a minute or two, I get the error:

make[1]: *** [CMakeFiles/Makefile2:368: CMakeFiles/rosconsole_log4cxx.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
<== Failed to process package 'rosconsole':
  Command '['/opt/ros/noetic/env.sh', 'make', '-j16', '-l16']' returned non-zero exit status 2.

Reproduce this error by running:
==> cd /home/bryson/ros_catkin_ws/build_isolated/rosconsole && /opt/ros/noetic/env.sh make -j16 -l16

Command failed, exiting.

The full command output can be found here: Pastebin (https://pastebin.com/bRmEijq5)
Thank you for any help you can provide!

@khanhne28
Copy link

I'm on step 7, and I'm a little confused. I'm using raspi4 model B that has a ARM64 arch. From what I see, you are installing missing packages from bullseye repo for the AMD64 architecture. My question is should i continue to install those packages if i use raspi4 model B that has a ARM64 arch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment