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.
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:
The installation guide on ROS2 will lead you to the Arch wiki on ROS2 here:
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 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
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
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.
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
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.
- Make the ros2-arch-deps AUR package updated
- Split the ros2 project into groups(ros2-core, ros2-desktop, ros2-desktop-full, just like ROS1)
- Possibilities on other distributions(like CentOS) outside ROS2’s support list
- Try ros2 on Raspberry Pi Arch Linux, we will need ROS2 on the Arch powered edge devices