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
1 Like

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.

1 Like

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:

Thanks! I have ran into the previous pitfalls and your instructions helped me fix them.

However, I am running into this issue:
stderr: rosbag2_transport
In file included from /usr/include/python3.8/Python.h:8,
from /home/seedship/ros2_ws/src/ros2/rosbag2/rosbag2_transport/src/rosbag2_transport/rosbag2_transport_python.cpp:15:
/usr/include/python3.8/pyconfig.h:1608: error: ā€œ_XOPEN_SOURCEā€ redefined [-Werror]
1608 | #define _XOPEN_SOURCE 700
|
command-line: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/rosbag2_transport_py.dir/build.make:83: CMakeFiles/rosbag2_transport_py.dir/src/rosbag2_transport/rosbag2_transport_python.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:217: CMakeFiles/rosbag2_transport_py.dir/all] Error 2
make[1]: *** Waiting for unfinished jobsā€¦
make: *** [Makefile:161: all] Error 2

Failed <<< rosbag2_transport [ Exited with code 2 ]

Do you know what to do? I am trying to get rid of all warnings being treated as errors, but I donā€™t know where to change the build settings. I have previously used ROS and build ROS workspaces by setting the python executable to python3.

I also had the _XOPEN_SOURCE redefinition problem. I circumvented it by simply #undef _XOPEN_SOURCE before the #include <Python.h>. This is more of a hack but it at least makes it compile successfully for me. The only issue Iā€™m having now is that my layered workspace does not find the message headers for some reason, but that may be a faulty CMakeLists.txt that for some reason works on my Ubuntu.

1 Like

Hey guys just want to pipe in since I totally forgot this post existed.
With the recent announcement of a rolling ROS distribution, we are waiting on the name decision before we start aggressively packaging ROS2 on Arch Linux.

superflore is something to definitely look into. Right now we have our own set of scripts that generate PKGBUILDs from package.xmls, Contributing this to/Integrating with the superflore repo would be nice.

As for the rosdep keys, Arch Linux has historically struggled to get them added/updated. See: https://github.com/ros-infrastructure/rosdep/pull/559#issuecomment-631443014 and https://github.com/ros-noetic-arch/ros-noetic-desktop-full/issues/4

@crystaldust I was wondering if you could update this post with the latest Foxy release, maybe you wouldnā€™t have to do python2 installation and the binbutils package might also not be a problem anymore. Also if you could get around to it, maintaining and updating the colcon packages on the AUR would be a great first step in being part of the ROS2 packaging process. All of this will also decrease the number of pitalls encountered when installing ROS2 on Arch Linux. Although who knows maybe there will be some other pitflalls with the latest Foxy release.

Thanks for the suggestions @Thomas_Moulard!
And thank you for your hard work @crystaldust!

Iā€™ll look into this and see what should be updated. Thanks for the great work on Arch. Iā€™ll also take a look at superflow/bloom and related release tools, itā€™s also a part of my work, cheers!

1 Like

My only complain is the AURā€™s colcon package are abandoned and outdated. Is there any way to overtake the package and update it for everyone? I am new to Arch Linux.

Take a look at the ArchWiki on the AUR: https://wiki.archlinux.org/index.php/Arch_User_Repository

Specifically: https://wiki.archlinux.org/index.php/Arch_User_Repository#Flagging_packages_out-of-date

Why donā€™t the ros2-arch-dep just contain non-python package. All python package can be installed via virtual environment and thus less work on maintaining ros2-arch-dep.

ros2-arch-dep itself is a convenience/temporary package that wonā€™t be used once ROS2 is properly packaged on Arch.

If you need python packages as deps for a system level package, then that python package must be packaged properly on Arch as well, since pacman is unaware of pip installs.

I have adopt and update python-colcon ROS2 dependencies packages in AUR. Everyone is invited to test it.

1 Like

Want to loop in the post by @vial, who tried to get Foxy working on Arch Linux.

I am interested on making AUR package for ros2 foxy, ia that feasible? Any tips or caution?

Hey guys. I needed to install ROS 2 and noticed that there was no AUR package, so I just went ahead and made one (actually two: ros2-foxy for Foxy, ros2-git for Rolling Distro). Iā€™d love to get your feedback although I know the packages are currently far from perfect. I also made GitHub pages for them (Foxy, Rolling) so that we can work together more easily. In the github pages you can also find Dockerfiles that Iā€™ve made for easy reproduction & testing.

2 Likes

MAybe the best way is to use chroot, and install whatever version of ROS 2 we want. If anyone interested , for future reference, on how to do it this is the tutorial I followed and everything work like a charm.