Wednesday 6 July 2011

Robotics Operating System (ROS) Setup on Archlinux

ROS is a framework for facilitating communication between discrete processes/applications that control various aspects of a robot, as well as packaging and building such applications.

Since the installer is a python package, it can be installed using easy_install, which must be installed first.
sudo pacman -S python2-pip

To install ROS, install the ROS python installer using the correct easy_install version (not the easy_install associated with python3).

sudo easy_install-2.7 -U rosinstall

Various ROS modules use python2. In fact, the installer rosinstall
uses python2. However, the shebang line of the python scripts is:

#!/usr/bin/env python

This directive causes problems with running the correct version of python: python3 is not backwards compatibile with python2. On Archlinux, /usr/bin/python is linked to python3.

One work around is to make a symbolic link to python2 in /usr/local/bin, and temporarily prioritize /usr/local/bin. Alternatively, another directory can be used to minimize side-effects.

# install GNU compilers 4.5

mkdir /usr/local/bin/alt

ln -s /usr/bin/python2 /usr/local/bin/alt/python

export PATH=/usr/local/bin/alt:$PATH

Now, following the instructions at the ROS wiki to complete the installation.
If any packages are missing, install them with pacman.
ROS may not detect some packages may not be detected properly and thus issue warnings, which can be disregarded.

After installation, a setup.sh script is provided to set the environmental variables. Ideally, you would set its executable flag and copy it to /etc/profile.d/ for automatic setup. However, you need to promote use of python2 over python3 each time before using ROS. One way is simply keep all the setup code together and source it prior to running ROS.

First, create a copy of setup.sh for adding modifications. (Performing updates with rosinstall will erase changes to setup.sh.)

cd $ROS_ROOT/..
cp setup.sh my.setup.sh

Then, edit my.setup.sh. Append the following lines.

# Add command to promote python2
export PATH=/usr/local/bin:$PATH
# Source the rosbash script to enable use of roscd, rosls, etc.
source $ROS_ROOT/tools/rosbash/rosbash
# Add a working directory to the project search path
export ROS_PACKAGE_PATH=~/project/ros:$ROS_PACKAGE_PATH

Each time before using ROS, source the ROS setup script.

source $ROS_ROOT/../my.setup.sh

This must be done in every new terminal opened.

No comments:

Post a Comment