Software
Here you will find information about the software used in the seminar. Specifically:
Some Machine Learning information is helpful.
Instalation procedure for player in Ubuntu Linux Desktop version 9.04 (Jaunty)
Install Ubuntu in you machine.
Setting up your system for compiling player.
Open a terminal and start typing the following commands:
sudo apt-get update
sudo apt-get install xstow autoconf pkg-config libtool automake build-essential libusb-dev swig python-dev libjpeg62-dev
mkdir local
mkdir local/DIR
mkdir local/src
mkdir local/src/player
mkdir local/src/phidgets
cd
gedit .bashrc
You have to add the following lines at the beginning of the file:
export PYTHON_VERSION=$(readlink $(which python))
export PATH=${HOME}/local/bin:${PATH}
export LD_LIBRARY_PATH=${HOME}/local/lib:${LD_LIBRARY_PATH}
export LIBRARY_PATH=${LD_LIBRARY_PATH}:${LIBRARY_PATH}
export CPATH=${HOME}/local/include:${CPATH}
export LDFLAGS="-L${HOME}/local/lib ${LDFLAGS}"
export PKG_CONFIG_PATH=${HOME}/local/lib/pkgconfig
export CMAKE_INCLUDE_PATH=${CPATH}
export CMAKE_LIBRARY_PATH=${LIBRARY_PATH}
export PYTHONPATH=${HOME}/local/src/yarp2/example/swig/build/:${HOME}/local/src/player/pypc-gen:${HOME}/local/lib/python/site-packages:${HOME}/local/lib/${PYTHON_VERSION}/site-packages:${PYTHONPATH}
export YARP_DIR=${HOME}/local/src/yarp2/build
Download the Phidgets driver from
here. A new version of this library is
here. Put this file into the /home/youruser/local/src/phidgets directory.
cd local/src/phidgets
tar -xzf phidget21_b.tar.gz (Change accordingly if you used the newer library)
cd phidget21/
autoreconf
./configure --prefix=${HOME}/local/DIR/phidgets
make
make install
cd
cd local/DIR
xstow phidgets
cd
Download
this file to your home directory and copy it to the /etc/udev/rules.d/ directory. (This gives permision to normal users to use the phidgets usb devices)
cd
sudo cp 030_phidgets.rules.txt /etc/udev/rules.d/030_phidgets.rules
sudo /etc/init.d/udev restart
sudo apt-get install libltdl3-dev libboost-thread-dev libboost-signals-dev libgtk2.0-dev swig python-dev libgeos-dev libgsl0-dev
Download the player source code. There are two possibilities here. One is to download the bleeding edge player subversion version with the following commands (ATTENTION: the svn version of player for 14.10.2009 doesn'f work together with the python bindings, use
this one instead):
cd local/src/player
svn co https://playerstage.svn.sourceforge.net/svnroot/playerstage/code/player/trunk player
cd
The other way is to download the player code from
here which is known to work. There is even an older version of player that is known to work
here, this version is only recommended under special circunstances. Put the file inside of the /home/youruser/local/src/player directory, and then do the following for decompressing the archive: (NEW!!: You can download a newer version of player that has support for the servo, advanced servo and motor control phidgets
here
cd local/src/player
tar -xzf player-svn-29.10.2008.tar.gz (Change accordingly if you used another player compressed file)
cd
cd local/src/player/player
mkdir build
cd build
ccmake ../
Here you get a menu-like interface for configuring the player compilation procedure
Press “c” to initialize the cmake environment. This searches for all necessary libraries and dependencies in your system, if something is missing you will get an error.
Configure the instalation directory changing the entry “CMAKE_INSTALL_PREFIX” to /home/youruser/local/DIR/player
Then you have to select what you want in your player server.
Please select the following drivers:
ENABLE_DRIVER_ACR120U=ON
ENABLE_DRIVER_PHIDGETACC=ON
ENABLE_DRIVER_PHIDGETIFK=ON
ENABLE_DRIVER_PHIDGETRFID=ON
ENABLE_DRIVER_READLOG=ON
ENABLE_DRIVER_WRITELOG=ON
Then press “c” wait some seconds and press “c” again to configure the new settings
Then press “g” to generate the compilation process recipes.
Execute the following commands:
make
make install
cd
cd local/DIR
xstow player
cd
sudo chmod -R o+rw /dev/bus/usb/*
player local/src/player/player/config/phidgetIFK.cfg
(Player should run without error messages)
cd local/src/player/player/build/client_libs/libplayerc++/test/
./playerc++_test --speech:0
The test program execute several checks. If you have connected the Phidgets interface kit you will see the message “Hellow world!” and the some numbers in the LCD screen of the phidget.
Setting up QT
cd
sudo apt-get install libqt4-dev kdevelop qt4-designer qt4-dev-tools python-qt4-dev pyqt4-dev-tools libtclap-dev
kdevelop
Setting up your proyect
Go to Proyect→New Proyect..
Choose C++→QMake→Basic Qt4 Application
In properties. Application name: yourproyectname, Location: /home/your_username/local/src/
Next
Fill in the Authors information and the type of license you want to use.
next→next→finish
Now you have your initial proyect code. This is only a “hello from QT 4!” program. You can compile it with Build→Build Proyect (The first time you do this you will be asked for running qmake, please do that)
You can run it with Build→Execute Main Program
Now we have to configure the proyect to use some libraries (like libplayer client libraries)
Open the lateral tab called “Qmake Manager”
Select the “src” directory and right click on it.
Select “Subproyect Settings”
Inside the “Configuration” Tab mark the Qt4 libraries:
GUI and QtAssistant. If you need something else just mark that also.
Inside the “Includes” Tab add the directories “${HOME}/local/include/player-2.2/” and “${HOME}/local/include/”
Inside the “Libraries” Tab add the external library dir “${HOME}/local/lib” and the following external libraries: “-lplayerc++” “-lplayererror”
Then the subproyect settings are ready. You can push the “OK” button to leave this window.
The skeleton phidget program
Now we are going to put into work the code from the workshop.
Copy
this file to the src directory inside of your kdevelop proyect directory. Then execute in a terminal inside of the “src” directory of the kdevelop proyect directory (“local/src/proyect_name/src)the following command:
tar -xzf skeleton.tar.gz
Add the main.h header file to the proyect. In the QMake Manager right click “HEADERS” then select “add existing files”. Then open “main.h”.
Add the “gui.ui” designer file to the proyect. In the QMake Manager right click “FORMS” then select “add existing files”. Then open “gui.ui”
Now you can compile your proyect again. (Press F8)
Start the player server. (look above)
Start the Qt4 application.
Connect a slider resistor to the 0 analog input of the phidgetIFK.
It should print “**Test* * X.XXV” where X.XX is the voltage measured by the phidgetIFK from the slider.
Also you should see the slider progress bar in the GUI changing according to the position of the slider.
Python applications
If you want to run Python clients you first need to get special bindings for player, the included python bindings for player are not recommended. Before starting this section, please update your ”.bashrc“ file with the current environmental variables described at the beggining of this page and restart your session.
cd local/src/player
git clone http://www9.in.tum.de/~kleinehe/pypc-gen.git
export IDIR=/home/user/local/src/player/player
cd pypc-gen
cat kludge.h $IDIR/libplayercore/player.h $IDIR/build/libplayercore/player_interfaces.h $IDIR/client_libs/libplayerc/playerc.h | ./pypc-gen > pyplayerc.py
apt-get install ipython
ipython
import pyplayerc as p
client=p.Client(None, "localhost", 6665)
client.connect()
client.set_replace_rule(-1,-1,-1,-1,True)
client.datamode(p.PLAYERC_DATAMODE_PULL)
aio=p.Aio(client,0)
aio.subscribe(p.PLAYERC_OPEN_MODE)
client.read()
aio.voltages_count
aio.voltages
Every time that you want an updated data from the phidget you have to do a client.read() command before you get the new data.
aio.voltages_count and aio.voltages contain the number of voltage inputs and the voltage values from those inputs.
aio.unsubscribe()
del aio
client.disconnect()
Python is very nice for prototyping, is similar to Matlab in the command line but you get access to real hardware much easier
There are QT bindings for python.
Data collection phidget program for Weka
Copy
this file to the src directory inside of your kdevelop proyect directory. Then execute in a terminal inside of the “src” directory of the kdevelop proyect directory (“local/src/proyect_name/src)the following command:
tar -xzf skeleton_data_collection.tar.gz
This will overwrite the original skeleton. You have to recompile.
When you have your training data files ready according to Weka specifications. You can run several testes to see the behavior of each of them.
Install weka. Look in there webpage. Weka may be in ubuntu already. You need a java runtime environment.
Execute weka:
java -jar weka.jar
Go to Application→Explorer
Open File. Select your data file.
Go to Classify tab. Choose a classifier and then press start.
You should look for the correctly classified Instances inside of the Stratified cross-validation.
Than value should be a good starting point to evaluate each learning algorithm.
Applying the learning algorithm inside of your program
Find a good usefull library that implements that specific algorithm.
Maybe you could run in the necessity of changing from one programming language to another for implementation.
Or you can try to implement one learning algorithm (if there are no libraries for it). Some times they are not difficult to implement.
Take a look in this code You need to install a package called libfann1-dev
YARP
Instalation
sudo apt-get install libace-dev libcv-dev libavdevice-dev ffmpeg
cd
cd local/src
svn co https://yarp0.svn.sourceforge.net/svnroot/yarp0/trunk/yarp2
cd yarp2
mkdir build
cd build
ccmake ../
Press “c”
Change the install prefix to /home/user/local/DIR/yarp2
Press “c”
Select the yarpmod_ffmpeg_graber and opencv_grabber (ON)
Press “c” twice and then “g”
make
make install
cd
cd local/DIR
xstow yarp2
cd locar/src/yarp2
cd example/swig
mkdir build
cd build
ccmake ../
Press “c”
If you get an error related to YARP_DIR, fix the entry for this value to /home/user/local/src/yarp2/build and try “c” again
Select the bindings for python and press “c” twice
Press “g”
make
cp _libpyyarp.so _yarp.so
Example Summer
We use python for this example
Open a console and run “yarp server”. Leave this console running
Type “ipython” in another console, then in the ipython interpreter, type the following:
import yarp as y
y.Network.init()
input=y.BufferedPortBottle()
output=y.BufferedPortBottle()
input.open("/summer/in")
output.open("/summer/out")
While True:
inputbottle=input.read(False)
if inputbottle:
outputnumber=inputbottle.get(0).asDouble()+inputbottle.get(1).asDouble()
outputbottle=output.prepare()
outputbottle.clear()
outputbottle.addDouble(outputnumber)
else:
y.Time.delay(0.001)
In this moment the python application is in an infinite loop waiting for data in the input port
Start two extra consoles
In the first new console execute: “yarp write … /summer/in”
In the second new console execute: “yarp read … /summer/out”
New in the first new console you can type “10 10” and you will see the result in the second new console.
Basically the summer module is processing the data that is writen in the /summer/in port and the results are published in the /summer/out
With this you can easily make small simple modules and test them without having the whole system in one single file. Also allows to segment work between colleges and to separate processing in different computers.
You can interface this system with player. You comunicate with the hardware using player and between your own processing modules using YARP.
fastdev/software.txt · Last modified: 2011/11/24 14:26 by
memeruiz · [
Old revisions]