ROS

From ArchWiki

ROS is an open-source, meta-operating system for your robot. It provides the services you would expect from an operating system, including hardware abstraction, low-level device control, implementation of commonly-used functionality, message-passing between processes, and package management.

Installation Instructions

You can install any of the ROS distributions below since they are fully released on AUR.

Noetic ros-noetic-desktop-fullAUR

Noetic is also available through an unofficial user repo:Unofficial user repositories#arch4edu

Melodic ros-melodic-desktop-fullAUR

catkin_make in Melodic

As specified by the ROS wiki, the first catkin_make command in a clean workspace should be:

catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3 -DBOOST_ROOT=/opt/boost1.69 -DBoost_NO_SYSTEM_PATHS=TRUE

Subsequent builds should be done with just

catkin_make

Using Catkin/ROS with an IDE

CLion

To make CLionAUR support ROS packages, you can change the Exec parameter of its desktop file ( ~/.local/share/applications/jetbrains-clion.desktop) as follows.

Exec=bash -i -c "source /home/[username]/catkin_ws/devel/setup.sh;/opt/clion/bin/clion.sh" %f

However, /home/[username]/catkin_ws must be exchanged with your Catkin workspace. You can now open a Catkin project without cmake complaining about missing packages, hopefully. If desired or needed you can use Python 3 by adding -DPYTHON_EXECUTABLE=/usr/bin/python3 to the CMake options which can be found in the settings.

catkin build in Melodic

For configuring the systems using the catkin build environment, one have to configure the catkin workspace as usual and issue a

catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DBOOST_ROOT=/opt/boost1.69 -DBoost_NO_SYSTEM_PATHS=TRUE

Afterwards, use catkin build as normal. Please remember to reconfigure your catkin whenever you delete the configuration files (i.e. the catkin_ws directory)

Rebuild when shared libraries are updated

When you update a library that ROS depends on (e.g. Boost), all packages that link to it must be rebuilt. Most AUR helpers will not detect this situation. The following script will generate a list of all packages that are linked to missing so files:

https://seangreenslade.com/h/snippets/ros-find-outofdate.py

(Note that the script requires pyalpm to be installed.)

ROS 2

Building using AUR

ros2-galacticAUR package aims to provide an easy way to install ROS 2 on Arch Linux. After installing the package, you need to configure your environment (i.e. source) in order to use ROS 2 — See #Usage Examples.

Building from source

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements. See Help:Style for reference.Tango-edit-clear.png

Reason: Do not cram an entire "PKGBUILD" into the section. This is incredibly hard to read and maintain (Discuss in Talk:ROS)

Build instructions are available at https://index.ros.org/doc/ros2/Installation/.

Install build dependencies.

Dependencies for Eloquent: (official packages in alphabetical order; AUR packages in an order in which you can sequentially install them without dependency errors)

The ros2-arch-depsAUR package attempts to address this, but will still require you to manually create the symbolic links as desribed below. If you want to install the dependencies yourself, the following packages are required:

asio cmake eigen glew git glu hdf5 libxaw opencv poco python python-cryptography python-lark-parser python-netifaces python-nose python-notify2 python-numpy python-pyqt5 python-setuptools python-sip4 python-yaml qt5-base sip tinyxml tinyxml2 vtk wget log4cxx python-empy python-pytest-repeat python-vcstoolAUR python-colcon-argcompleteAUR python-colcon-bashAUR python-catkin_pkgAUR python-colcon-cmakeAUR python-colcon-coreAUR python-colcon-defaultsAUR python-colcon-devtoolsAUR python-colcon-library-pathAUR python-colcon-metadataAUR python-colcon-notificationAUR python-colcon-outputAUR python-colcon-package-informationAUR python-colcon-package-selectionAUR python-colcon-pkg-configAUR python-colcon-parallel-executorAUR python-colcon-powershellAUR python-colcon-python-setup-pyAUR python-colcon-recursive-crawlAUR python-colcon-rosAUR python-colcon-test-resultAUR python-colcon-zshAUR python-colcon-common-extensionsAUR python-rospkgAUR python-rosdistroAUR python-rosdepAUR

Dependencies for Dashing: (please note that Dashing will not build out of the box, it requires patching)

wget python python-yaml python-setuptools sip python-sip4 python-pyqt5 git cmake asio tinyxml tinyxml2 eigen libxaw glu qt5-base opencv hdf5 vtk glew poco python-nose python-numpy python-lark-parser python-cryptography python-netifaces python-vcstoolAUR python-empy log4cxx python-colcon-common-extensionsAUR python-rosdepAUR

Fetch the sources:

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

Note: Replace "master" with whatever distribution is desired (e.g. "foxy"), master indicates rolling version.

The qt_gui_cpp package expects to find modules in /usr/share/sip by default. Arch ships the PyQt5 and sip modules in the Python site-packages directory. Make the the following symlinks to build successfully:

# mkdir -p /usr/share/sip
# ln -s /usr/lib/python3.9/site-packages/PyQt5 /usr/share/sip/.
# ln -s /usr/lib/python3.9/site-packages/PyQt5/bindings/* /usr/share/sip/PyQt5/.
Note: As of 2021-01-07, you have issues compiling the qt_gui_cpp package regarding /usr/bin/sip not being found. This can be solved by installing the sip4 package. It is expected that this should be fixed in a future release if this package switches to a newer version of SIP.

Now you can build and install ROS 2 to a specific directory by:

$ cd ~/ros2_ws
$ sudo mkdir /opt/ros2
$ sudo chown $USER /opt/ros2
$ colcon build --merge-install --install-base /opt/ros2/foxy

Change /opt/ros2/foxy to where you want to install ROS 2 packages. If you are using other version, change foxy to your version name.

Note: If you encounter warnings, just re-run the colcon build command as before until it returns successfully.

Besides, you can add --parallel-work=N behind the colcon command to improve building efficiency. Change N to a number, like 20 or 10.

If you do not want to keep the source files, you can remove whole ~/ros2_ws directory after compilation.

 $ rm ~/ros2_ws -rf
Note: Besides, if you want to build ros1_bridge, you must source ROS 1 before compiling ROS 2. Read https://github.com/ros2/ros1_bridge/blob/master/README.md#build-the-bridge-from-source regarding ROS 1 / ROS 2 interoperability.

Usage Examples

First source the workspace, or change the directory to where you installed as before.

If you are using zsh, change source /opt/ros2/foxy/setup.bash to source /opt/ros2/foxy/setup.zsh

$ source /opt/ros2/foxy/setup.bash

A tip to source workspace is adding a function like this your shell startup file, like .bashrc, .zshrc.

ros2_on(){
     export ROS_DOMAIN_ID=42
     export ROS_VERSION=2
     export ROS_PYTHON_VERSION=3
     export ROS_DISTRO=foxy
     source /opt/ros2/foxy/setup.bash
}

Remember to make any applicable changes, namely changing the ROS_DISTRO variable to the distrobution you've installed.

You can change ROS_DOMAIN_ID to your favourite number, or the number you're actually using.


Functionality comparable to roscore, rosnode, rostopic, rosmsg, rospack, rosrun and rosservice is available via ros2:

$ ros2 -h
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ... 

ros2 is an extensible command-line tool for ROS 2.

optional arguments:
  -h, --help            show this help message and exit

Commands:
  daemon    Various daemon related sub-commands
  msg       Various msg related sub-commands
  node      Various node related sub-commands
  pkg       Various package related sub-commands
  run       Run a package specific executable
  security  Various security related sub-commands
  service   Various service related sub-commands
  srv       Various srv related sub-commands
  topic     Various topic related sub-commands

  Call `ros2 <command> -h` for more detailed usage.

A typical "Hello World" example starts with running a publisher node:

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

Then, in another terminal, you can run a subscriber (Do not forget to source the workspace in every new terminal):

$ ros2 topic echo /chatter

List existing nodes:

$ ros2 node list
publisher_std_msgs_String

List topics:

$ ros2 topic list
/chatter

ROS 2's version of rviz is

$ rviz2