ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org

Get ROS2 working on ArchLinux

About Arch Linux

Arch Linux might be one of the most radical(or just the most?) Linux distributions, with a rolling update strategy, Arch makes everything latest. So we can enjoy the new versions of every package, while at the same time, annoyed by the version compatibilities. But for ROS2, Arch is a great distribution to think about. For Linux distributions beside Ubuntu, the only way getting ROS2 work is to build it from the source code, so a flexible and friendly package manager is really NEEDED to make all dependencies collaborate. That is what pacman(Arch’s package manager) is really good at.

ROS2

For now ROS2 doesn’t have a explicit package grouping like ROS1, I mean, something like ros-core, ros-desktop and ros-desktop-full. (Maybe I’m wrong on this point, if there are, let me know and I would be very glad to maintain AURs for ros2 on Arch). So what we get in the post is a full version of ROS2, as you may see, there will be some UI & visualization dependencies like qt5 and rviz.

ROS2 Version in this post

Just like Arch Linux, let’s be radical:) We will use the latest Eloquent in this post, the .repos file is from the eloquent branch on github:

https://index.ros.org/doc/ros2/Installation/Eloquent/

Get started

The installation guide on ROS2 will lead you to the Arch wiki on ROS2 here:

https://wiki.archlinux.org/index.php/ROS#ROS_2

For Arch, there is already an AUR package to install ROS2 dependencies: ros2-arch-deps. While it is already outdated, we can still get the basic deps from its installation. So first step, is to install the deps with an AUR package manger(I use yaourt here, you can definitely choose your favorite):

$ yaourt --noconfirm ros2-arch-deps

After that, we install some of the essential deps from official sources, with pacman:

# Some of the packages may already be covered by ros2-arch-deps AUR package
$ pacman -S asio cmake eigen glew git glu hdf5 libxaw opencv poco python python-cryptography python-lark-parser python-netifaces python-nose python-numpy python-pyqt5 python-setuptools python-sip python-yaml qt5-base sip tinyxml tinyxml2 vtk wget log4cxx

Before moving on, let me first show you some hair scratching troubles that you may have when building ROS2 by your own. Relax, I’ve already scratched my hair and detected all the mines. It would be easy for you to get them over.

Pitfall 1: Downgrade binutils

OK, here comes the first pitfall, the package osrf/osrc_testing_tools_cpp relies on bombela/backward-cpp, which refers to binutils, and binutils interfaces change in the latest 2.34. Since Arch by default keeps everything latest, we have to downgrade the binutils package to version 2.32. Thanks to the design of pacman, this can be easily done with the command:

# Note: if the URL fails with 404, try find archive backups at archive.org:
# https://archive.org/details/archlinuxarchive
$ pacman -U https://archive.archlinux.org/packages/b/binutils/binutils-2.32-1-x86_64.pkg.tar.xz

Pitfall 2: Install the latest colcon packages

colcon is used to build ROS2, according to the Arch wiki, the ros2-arch-deps will install colcon related AUR packages, but these package are not maintained up to date, when building ROS2 with the outdated colcon package, an error complaining “variable ‘done’ is assigned before declare” will occur. We can fix this by installing the latest colcon related packages with pip command:

# install the package with sudo, so all the paths will be handled
# you can absolutely build ROS2 in a virtual env
$ sudo pip install -U colcon-common-extensions colcon-core colcon-argcomplete
$ sudo pip install -U pytest-runner # pytest-runner is needed by colcon-core

Pitfall 3: Install xorg-xrandr

The package rviz_orge_vendor will need some display environment, under Linux, the xrandr package is needed, but not listed explicitly above, so install it manually:

$ sudo pacman -S xorg-xrandr

Pitfall 4 and tricks: Install python2-pyqt5

The qt_gui_cpp module will need a qt SIP binding for python, we have installed the qt5 bindings above, while the binding also needs a configuration in path /usr/share/sip/PyQt5/. The latest package python-pyqt5 does not provide the configs after an architectural change, while the package for python2 still provides it. So here is a trick to make python-pyqt5 work for ROS2:

$ sudo pacman -S python2-pyqt5

After the installation, make sure the path /usr/share/sip/PyQt5/ is there.

Build ROS2

We’ve get everything ready for installation, we can now follow the Arch Wiki guide to prepare local environment and get code:

$ mkdir -p ~/ros2_ws/src
$ cd ~/ros2_ws
$ wget https://raw.githubusercontent.com/ros2/ros2/eloquent/ros2.repos
$ vcs import src < ros2.repos

Then build the project with colcon:

$ cd ~/ros2_ws
$ COLCON_LOG_LEVEL=warn colcon build --symlink-install

Validate the installation

Follow the Arch Wiki, let’s run a topic pub/sub example:

# Update the environment so we can access the just built ros in ~/ros2_ws
# ros2 -h may complain 'lxml' package not found, just install it with pip
$ . ~/ros2_ws/install/local_setup.bash
$ ros2 -h

# publish a topic
$ ros2 topic pub /chatter 'std_msgs/String' "data: 'Hello World'"

Open a new ssh session and sub the toplic, the message ‘data: Hello World’ should be printed on the screen:

$ . ~/ros2_ws/install/local_setup.bash
$ ros2 topic echo /chatter

Next steps

Something I didn’t mention in the post above, is that some packages are not fully built since the missing of some features, some might give you warnings. That’s OK, that’s what we should think about in the next steps. There are some points I can come up with for the future.

  1. Make the ros2-arch-deps AUR package updated
  2. Split the ros2 project into groups(ros2-core, ros2-desktop, ros2-desktop-full, just like ROS1)
  3. Possibilities on other distributions(like CentOS) outside ROS2’s support list
  4. Try ros2 on Raspberry Pi Arch Linux, we will need ROS2 on the Arch powered edge devices

I believe there are, see: REP-2001: ROS Bouncy and Newer Variants.

Aha, thanks @gavanderhoorn that’s really helpful. I’ll try to build them separately and see if there are issues to fix. @acxz So at least we can have ros2_base, ros2_core, and ros2_desktop to maintain.

1 Like

If you start working on improving support for a new distribution, consider:

  • Add Arch Linux support to superflore. Given the sheer number of packages in ROS, doing it by hand is not really an option, unless you are determined to only ever support a small number of core ROS/ROS2 packages. superflore, like Bloom, rely on ROS internal packaging information (package.xml) to generate a package for a target distro. The suggestion here is to add Arch as a target. Given the nature of Arch packages, it is likely to be do-able. It is tricky if you’re targeting official inclusion, but that definitely should do the trick for AUR.

  • Add/update/maintain rosdep keys for everything arch related. base.yaml is used by rosdep to generate the commands required to install system deps for any package (pacman/yaourt ...) on the target distro.
    It is likely that Arch rosdep support could use some help, so adding the keys, and making sure rosdep is using whatever makes the most sense on Arch would be a very valuable contribution.

Hi, Thomas, thanks for the great advices, I’ll look into that, hope we can make Arch a good choice for ROS fans.

I seem to remember some earlier interest in this and work towards implementing it (ie: superflore support for Arch).

May be good to first try and find it @crystaldust.

@gavanderhoorn Thanks, I’ll first have a look :grinning: