Install PSG

Introduction

There are several reasons why one would want to go through the hassle of setting up a simulation environment. The most obvious one is that simulation drastically improves and speeds up development. Work can commence without having physical hardware to play with. The cost of prototyping ideas is also significantly less (in terms of money spent on hardware and time invested). Testing can also be performed anywhere. It is also beneficial to use a simulator that is open-source, particularly if you envisage requiring customisation beyond the norm.

During the course of my masters, I evaluated a handful of robotics frameworks. In the end, I used The Player Project for the main framework that I built upon. Unfortunately, large open-source projects (such as robotics simulators) are notorious for being difficult to get going on your own computer. There are many existing documents on the web about how to build and install Player from source. This webpage lists down steps which I found to get Player and its simulation environments (Stage and Gazebo) working on my computer (Ubuntu 10.04 x64).

Please note that these instructions are intended to aid installation. You are probably going to encouter errors particular to your setup, which will require you to 'fill in the blanks' and look beyond the help I've provided here. 

Preamble

You'll need to create a folder on your Linux machine to hold the source and built files. On my machine (Ubuntu 10.04 x64), I like to store these files in a folder called 'dev' under my home directory:

mkdir ~/dev

There are also some packages you'll need to need to install on your system (if you dont have them already). Not all of these are strictly required, but are good to have:

sudo apt-get install build-essential apt-file git-core subversion cmake automake python2.6

You also need to setup your system's environment variables. Do so by editing your bashrc script (i.e., run 'gedit ~/.bashrc'), and add the following lines to the end of the file:

export PATH=$PATH:/usr/local/bin
export CPATH=$CPATH:/usr/local/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib64/pkgconfig

Install OpenCV

sudo apt-get install build-essential automake libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev
# download the src
cd ~/dev
wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.1/OpenCV-2.1.0.tar.bz2/download
tar -xvf OpenCV-2.1.0.tar.bz2
cd OpenCV-2.1.0/
cmake ../
make
sudo make install
sudo echo "/usr/local/lib" | sudo tee -a /etc/ld.so.conf.d/opencv.conf
sudo ldconfig

The Player Project makes use of several of other open-source libraries. One of these is OpenCV, a well known and used library in computer vision groups. Player makes use of OpenCV for some of its drivers, such as the blobfinder vision tracking module. You could install it from the pre-built files (see these instructions), but I recon its better having built it from source.

There are two options for building OpenCV from source. The first one is build it from the 'bleeding edge' code (see these instructions). Alternatively (and probably more suitable if your main objective is not developing computer vision algorithms), you could build it from a stable release like I did:

sudo apt-get install libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev libswscale-dev libjasper-dev
cd ~/dev
wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.1/OpenCV-2.1.0.tar.bz2/download
tar -xvf OpenCV-2.1.0.tar.bz2
cd OpenCV-2.1.0/
mkdir build && cd build
cmake ../
make
sudo make install

Install GearBox

Some of Player's drivers that communicate to hardware such as laser rangefinders. Thus, if you have a Hokuyo URG-04 and want to use it with Player, you'll need to install the GearBox libraries prior to building Player. Otherwise, you need not bother installing GearBox on your system.

In my masters project, it was a while between the time that I started working with Player and required drivers for the URG-04 scanner. In between that time, I had developed drivers for the then current version of Player. However, a few architectural changes had been made in Player, and I was too lazy to update to the current Player and modify my custom drivers. As a result, the 'current' version of GearBox was too new for my version of Player. To overcome this, I just installed GearBox from an older release:

sudo apt-get install libboost-python1.40-dev
cd /usr/lib
sudo ln -s libboost_python-mt-py26.so libboost_python-mt.so
cd ~/dev
wget http://sourceforge.net/projects/gearbox/files/gearbox/9.11/gearbox-9.11.tar.gz/download
tar -xvf gearbox-9.11.tar.gz
cd gearbox-9.11
mkdir build && cd build
cmake ../
make
sudo make install

Install Player

After installing several dependency packages and projects, finally my PC was ready to have Player installed on it. Initially I tried installing it from the 'stable' tarball release (player-3.0.1.tar.gz). Installation went smoothly, but when running Player I encoutered numerious difficulties. I concluded that the features I wanted to use were not actually stable in the release, and decided to build Player from the SVN repository. Note that the head revision of Player at the time was 8921. To ensure that my custom drivers would work on another system, I decided to check out and build Player from the same revision (i.e., 8921). You might want to build from the current revision of Player, but otherwise to download and build revision 8921:

sudo apt-get install libtool saidar libgnomecanvasmm-2.6-dev
cd ~/dev
svn co -r 8921 https://playerstage.svn.sourceforge.net/svnroot/playerstage/code/player/trunk player-svn
cd player-svn && mkdir build && cd build
cmake -DBUILD_PLAYERCC=ON -DBUILD_PLAYERCC_BOOST=ON -DBUILD_PYTHONC_BINDINGS=ON -DBUILD_PYTHONCPP_BINDINGS=ON -DBoost_USE_MULTITHREAD=ON -DENABLE_DRIVER_GBXGARMINACFR=OFF ../
make
sudo make install

When running make, I encountered the build error: '/usr/bin/ld: cannot find -lboost_thread-mt'. You could google it (don't forget to remove the leading '-' character(s) in the search!), but I suggest you use apt-file to track down dependencies in Ubuntu. Running 'apt-file search boost_thread' returns a bunch of entries, but the most suitable package to install is 'libboost-thread1.40-dev'. Player also requires 'libboost-signals1.40dev', thus run 'sudo apt-get install libboost-thread1.40dev libboost-signals1.40dev', and re-run the cmake, make and install steps.

If you have managed to build and install Player, congratulations! It would be prudent to check to see if things are working. One simple test is to run Player, viz: 'player'. Note that to do this, 'player' needs to be located in one of the directories that your $PATH variable points to (this is why we added some lines to the bashrc file). If things are honky dory, running 'player' is much the same as running 'player -help'. In either case, Player starts up and prints out help text, along with displaying the installed drivers, then quits because we haven't given it a configuration file. If you see this, odds are you have successfully installed Player! But defer celebrations as this success does not infer that all of the Player drivers are working!

Install Stage

Stage is a 2-D simulator for Player. It was designed as a plugin driver, and when used, provides a simulation environment and a virtual robot. The simulator also provides a limited set of drivers that replace ones that would have Player would have otherwise used to interface to robot hardware. I installed Stage from a stable release, and it seemed to work fine. The commands I ran to get Stage on my PC were:

sudo apt-get install freeglut3 freeglut3-dev libfltk1.1 libfltk1.1-dev libgtk2.0-dev libltdl7 libltdl7-dev libpng12-0 libpng12-0-dev
cd ~/dev
wget http://sourceforge.net/projects/playerstage/files/Stage/3.2.2/Stage-3.2.2-Source.tar.gz/download
tar -xzvf Stage-3.2.2-Source.tar.gz
cd Stage-3.2.2-Source && mkdir build && cd build
cmake ../
make
sudo make install

Note that if you encouter build errors such as the following: '/usr/lib/libGL.so, needed by libstage/libstage.so.3.2.2', it is probably due to your graphics card drivers. This is obviously particular to your computer's hardware, and I'll leave it up to the reader to resolve this issue should it arise.

At this point, you can test both Stage and Player. Change into Stage's example directory ('cd ~/dev/Stage-3.2.2-Source/world'), then run 'player simple.cfg'. If things are working, a window opens similar to the following:

If you want to control the robot yourself, edit 'simple.world' and comment out the line 'ctrl "wander"'. Save the file, and restart Stage. In another terminal, type in 'playerv'. In this GUI, check 'Subscribe' and also 'Command' under the menu: Devices -> position2d:0 (stage). A red circle appears in the box in the centre of the GUI. Dragging this circle sends velocity commands to the robot which makes it move!

Install Gazebo

Another simulator for Player is Gazebo, and unlike Stage, the virtual environment is 3-D and also simulates rigid body kinematics. Unfortunately, installation of Gazebo can be quite tricky as it has a lot more dependencies than Stage. Gazebo is also more resource intensive. Older computers might struggle to run Gazebo and your Player client application at the same time.

The main motivation in my masters for wanting to run Gazebo was that it could simulate a virtual video feed - useful for developing computer vision based obstacle avoidance routines. However, I found that the textures generated by the virtual environment were too repetitive and unrealistic to be useful for vision processing tasks. Thus I ended up seldomly using Gazebo. Below are instructions for installing the dependency projects, followed by Gazebo. Note that as I have only installed Gazebo a couple of times (and don't use it offen enough), the install guides are likely to be incomplete. 

Another thing to note is that installation of Gazebo would be significantly easier without building the dependency projects from source. Many of the these projects (OGRE, GDAL, Bullet, etc) are probably available through Ubuntu's apt-get package manager.

Install ODE

cd ~/dev
wget http://sourceforge.net/projects/opende/files/ODE/0.11.1/ode-0.11.1.tar.bz2/download
tar -xvf ode-0.11.1.tar.bz2
cd ode-0.11.1
./configure CXXFLAGS=-fPIC CFLAGS=-fPIC CPPFLAGS=-fPIC 
make
sudo make install

Install GDAL

cd ~/dev
wget http://download.osgeo.org/gdal/gdal-1.7.2.tar.gz
tar -xvf gdal-1.7.2.tar.gz
cd gdal-1.7.2
./configure
make
sudo make install

Install Freeimage

cd ~/dev
wget http://sourceforge.net/projects/freeimage/files/Source%20Distribution/3.13.1/FreeImage3131.zip/download
unzip FreeImage3131.zip
cd FreeImage
make
sudo make install

Install OGRE

sudo apt-get install zlib-bin libfreeimage-dev libzzip-dev libcg libpoco-dev doxygen libois-dev libcppunit-dev libtbb-dev libxf86vm-dev libxxf86vm-dev
cd ~/dev
wget http://sourceforge.net/projects/ogre/files/ogre/1.7/ogre_src_v1-7-1.tar.bz2/download
tar -xvf ogre_src_v1-7-1.tar.bz2
cd ogre_src_v1-7-1 && mkdir build && cd build
cmake ../
make
sudo make install

Install Bullet

cd ~/dev
wget http://bullet.googlecode.com/files/bullet-2.76.tgz
tar -xvf bullet-2.76.tgz
cd bullet-2.76
rm bullet.pc.cmake
wget http://bullet.googlecode.com/svn-history/r2079/trunk/bullet.pc.cmake
rm CMakeLists.txt
wget http://bullet.googlecode.com/svn-history/r2079/trunk/CMakeLists.txt
echo "SET(CMAKE_C_FLAGS "-fPIC")" >> CMakeLists.txt
echo "SET(CMAKE_CXX_FLAGS "-fPIC")" >> CMakeLists.txt
echo "ADD_DEFINITIONS( -DBT_USE_DOUBLE_PRECISION)" >> CMakeLists.txt
mkdir build && cd build
cmake ../
make
sudo make install

Finally, install Gazebo

Initially I tried to install Gazebo from a release tarball (gazebo-0.10.0.tar.bz2). However, I ran into issues that I couldn't resolve. Instead, I was able to get Gazebo going using the code from the repository:

sudo apt-get purge yaml-mode
sudo apt-get install libxml2-dev libopenal-dev websimba libboost-dev libboost-thread1.40-dev libboost-signals1.40 libboost-signals-dev libboost-regex1.40-dev yaml-mode libyaml-dev
cd ~/dev
mkdir gazebo-svn && cd gazebo-svn
svn co https://playerstage.svn.sourceforge.net/playerstage/code/gazebo/trunk
cd trunk
mkdir build && cd build
cmake ../
make
sudo make install

If you have managed to successfully install Gazebo (in addition to Player and Stage), well done! Give yourself a huge pat on the back. I remember installing Gazebo to be a little painful! Have fun with Player along with its simulation environments. You may want to have a look at some of the custom Player plugins that I have developed.

Share |