Tuesday, 12 July 2011

Compiling ROS stack openni_kinect/openni_tracker

While compiling openni_tracker, the compiler cannot find the OpenNI headers.

Append the following line to openni_tracker's CMakeLists.txt


ROS kdl patch failure

While compiling kdl, *make* tries to apply total.patch. However, it is already patched.

  Makefile:61: warning: overriding recipe for target `clean'
  /usr/local/opt/ros/ros/core/mk/cmake.mk:24: warning: ignoring old recipe for target `clean'
  cd build/kdl-tar && patch -p0 < ../../total.patch
  patching file src/bindings/python/CMakeLists.txt
  Reversed (or previously applied) patch detected!  Assume -R? [n] 
  Apply anyway? [n] 
  Skipping patch.
  1 out of 1 hunk ignored -- saving rejects to file src/bindings/python/CMakeLists.txt.rej
  patching file src/tree.cpp
  Reversed (or previously applied) patch detected!  Assume -R? [n] 
  Apply anyway? [n] 
  Skipping patch.
  1 out of 1 hunk ignored -- saving rejects to file src/tree.cpp.rej
  patching file tests/kinfamtest.cpp
  Reversed (or previously applied) patch detected!  Assume -R? [n] 
  Apply anyway? [n] 
  Skipping patch.
  1 out of 1 hunk ignored -- saving rejects to file tests/kinfamtest.cpp.rej
Comment out the following line in *Makefile*. Like so:
#cd $(SOURCE_DIR) && patch -p0 < ../../$(PATCH)

Then kdl should compile.

ROS pcl_ros fails to compile with GCC 4.6

/usr/local/opt/ros/perception_pcl/pcl/include/pcl/ros/conversions.h:284:9: error: taking address of temporary [-fpermissive]

Code fix:
First assign the temporary variable to a local variable. Then reference the address of the local variable. However, this is more complicated with arrays being copied with memcpy. One way is to use a for-loop to replace memcpy.
See patch for a similar error in another library.

Since the change is somewhat drastic, I compiled pcl_ros with gcc-4.5 instead.

# install gcc-4.5
yaourt -S gcc45

Edit perception_pcl/pcl_ros/CMakeLists.txt.
Add the following lines (prefixed with +) near the top, *after* the rosbuild directives.


+set (CMAKE_C_COMPILER gcc-4.5)
+set (CMAKE_CXX_COMPILER g++-4.5)

(If the compilers are set before the rosbuild directives, cmake will enter an infinite loop during configuration!)

Then pcl_ros should compile.

Compiling ROS pcl package

The pcl package depends on libhdf5_cpp.so.
However, Archlinux hdf5 does not include libhdf5_cpp.so. See reason.

Therefore, you will need to download and compile hdf5 with the --enable-cxx configure flag.

Download hdf5 source package.

tar -xjf hdf5-1.8.7.tar.bz2
cd hdf5-1.8.7
./configure --prefix=/usr/local --enable-cxx
make install

A number of other patches are also necessary when compiling with GCC 4.6.

Saturday, 9 July 2011

Compiling ROS pluginlib with boost 1.4.6

pluginlib cannot be compiled with boost 1.4.6, due to changes in API.
Patch can be found at ros-pkg ticket.

Automatic patching will fail, due to later changes to boost_fs_wrapper.cpp.
Apply the patch manually.

Wednesday, 6 July 2011

Installing irobot_create

The driver is available from the Brown University brown-ros-pkg site.

Download, extract, and compile using ROS.
You should work in a user ROS project directory (such as ~/projects/ros), which as been added to $ROS_PACKAGE_PATH.

cd [ROS project directory]
wget http://brown-ros-pkg.googlecode.com/files/irobot_create_2_1.tar.bz2
tar -xjf irobot_create_2_1.tar.bz2
rosmake irobot_create_2_1

Plug iRobot Create through USB, which should show up as /dev/ttyUSB0
Make ensure you have access to /dev/ttyUSB0.

sudo chmod 666 /dev/ttyUSB0

To test, start roscore and run irobot_create/driver.py

rosrun irobot_create_2_1 driver.py

In a separate terminal,

# Examine the service
rosservice type tank | rossrv show
# Publish to the service; make the robot spin
rosservice call tank -- 0 -10 10

The last command will instruct the robot to drive the left wheel at -10 mm/s and the right wheel at 10 mm/s, which causes the robot to spin.

Installing ROS bullet

The bullet library does not compile out of the box with GCC 4.6.
The patch is available at:

Download zero_initialize.patch to $ROS_ROOT/../geometry/bullet/
Apply patch and compile.

cd $ROS_ROOT/../geometry/bullet
patch build/bullet_svn/src/BulletSoftBody/btSoftBodyInternals.h -i zero_initialize.patch
rosmake bullet

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

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.