This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
fastdev:software [2009/10/14 18:59] – memeruiz | fastdev:software [2011/11/24 14:26] (current) – [Software] memeruiz | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Software ====== | ||
+ | Here you will find information about the software used in the seminar. Specifically: | ||
+ | |||
+ | * The [[playerstage|Player/ | ||
+ | * [[qt|QT]] from Trolltech | ||
+ | * New demo is the light sensor trainer. | ||
+ | * Obsolete old demo application: | ||
+ | * YARP NEW!! | ||
+ | * [[phidget_yarp|Phidget software 11.2011]] | ||
+ | * [[python_signals| Python + filters + fft + gnuplot]] | ||
+ | * [[python_qt| Python + Qt]] | ||
+ | * Examples for I@C winter semester 2010: | ||
+ | * {{: | ||
+ | * {{: | ||
+ | * {{: | ||
+ | * {{: | ||
+ | |||
+ | Some [[ml|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/ | ||
+ | mkdir local/ | ||
+ | cd | ||
+ | |||
+ | * Setting up environment variables. It is necessary to edit the " | ||
+ | |||
+ | gedit .bashrc | ||
+ | |||
+ | You have to add the following lines at the beginning of the file: | ||
+ | |||
+ | export PYTHON_VERSION=$(readlink $(which python)) | ||
+ | export PATH=${HOME}/ | ||
+ | export LD_LIBRARY_PATH=${HOME}/ | ||
+ | export LIBRARY_PATH=${LD_LIBRARY_PATH}: | ||
+ | export CPATH=${HOME}/ | ||
+ | export LDFLAGS=" | ||
+ | export PKG_CONFIG_PATH=${HOME}/ | ||
+ | export CMAKE_INCLUDE_PATH=${CPATH} | ||
+ | export CMAKE_LIBRARY_PATH=${LIBRARY_PATH} | ||
+ | export PYTHONPATH=${HOME}/ | ||
+ | export YARP_DIR=${HOME}/ | ||
+ | |||
+ | |||
+ | * After this you have to reload your session. | ||
+ | |||
+ | * Download the Phidgets driver from {{fastdev: | ||
+ | |||
+ | cd local/ | ||
+ | tar -xzf phidget21_b.tar.gz | ||
+ | cd phidget21/ | ||
+ | autoreconf | ||
+ | ./configure --prefix=${HOME}/ | ||
+ | make | ||
+ | make install | ||
+ | cd | ||
+ | cd local/DIR | ||
+ | xstow phidgets | ||
+ | cd | ||
+ | |||
+ | * Download {{fastdev: | ||
+ | |||
+ | cd | ||
+ | sudo cp 030_phidgets.rules.txt / | ||
+ | sudo / | ||
+ | |||
+ | * Install package dependencies for playerstage: | ||
+ | |||
+ | 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' | ||
+ | |||
+ | cd local/ | ||
+ | svn co https:// | ||
+ | cd | ||
+ | |||
+ | * The other way is to download the player code from {{: | ||
+ | |||
+ | cd local/ | ||
+ | tar -xzf player-svn-29.10.2008.tar.gz (Change accordingly if you used another player compressed file) | ||
+ | cd | ||
+ | |||
+ | * Once you have the player source code decompress you can proceed to compile it: | ||
+ | * Compiling player: | ||
+ | |||
+ | cd local/ | ||
+ | mkdir build | ||
+ | cd build | ||
+ | ccmake ../ | ||
+ | |||
+ | * Here you get a menu-like interface for configuring the player compilation procedure | ||
+ | * Press " | ||
+ | * Configure the instalation directory changing the entry " | ||
+ | * 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 " | ||
+ | * Then press " | ||
+ | * Execute the following commands: | ||
+ | |||
+ | make | ||
+ | make install | ||
+ | cd | ||
+ | cd local/DIR | ||
+ | xstow player | ||
+ | cd | ||
+ | |||
+ | * Player is ready! | ||
+ | * Connect the phidget devices to the USB ports. | ||
+ | * Let's run the player server: | ||
+ | |||
+ | sudo chmod -R o+rw / | ||
+ | player local/ | ||
+ | |||
+ | (Player should run without error messages) | ||
+ | * Player keeps running in this terminal and it will print any error messages in there if something happens. | ||
+ | |||
+ | * Player includes an application for testing. Open another console and execute the following commands: | ||
+ | |||
+ | cd local/ | ||
+ | ./ | ||
+ | |||
+ | The test program execute several checks. If you have connected the Phidgets interface kit you will see the message " | ||
+ | |||
+ | ===== Setting up QT ===== | ||
+ | |||
+ | * Install the appropiate packages | ||
+ | |||
+ | cd | ||
+ | sudo apt-get install libqt4-dev kdevelop qt4-designer qt4-dev-tools python-qt4-dev pyqt4-dev-tools libtclap-dev | ||
+ | |||
+ | * Execute kdevelop | ||
+ | |||
+ | kdevelop | ||
+ | |||
+ | ==== Setting up your proyect ==== | ||
+ | |||
+ | * Go to Proyect-> | ||
+ | * Choose C++-> | ||
+ | * In properties. Application name: yourproyectname, | ||
+ | * Next | ||
+ | * Fill in the Authors information and the type of license you want to use. | ||
+ | * next-> | ||
+ | * Now you have your initial proyect code. This is only a "hello from QT 4!" | ||
+ | * You can run it with Build-> | ||
+ | |||
+ | * Now we have to configure the proyect to use some libraries (like libplayer client libraries) | ||
+ | * Open the lateral tab called "Qmake Manager" | ||
+ | * Select the " | ||
+ | * Select " | ||
+ | * Inside the " | ||
+ | * Inside the " | ||
+ | * Inside the " | ||
+ | * Then the subproyect settings are ready. You can push the " | ||
+ | |||
+ | ==== The skeleton phidget program ==== | ||
+ | |||
+ | Now we are going to put into work the code from the workshop. | ||
+ | |||
+ | * Copy {{fastdev: | ||
+ | |||
+ | tar -xzf skeleton.tar.gz | ||
+ | |||
+ | * Add the main.h header file to the proyect. In the QMake Manager right click " | ||
+ | * Add the " | ||
+ | * 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 " | ||
+ | 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 " | ||
+ | |||
+ | * To get the python bindings install the packages " | ||
+ | |||
+ | cd local/ | ||
+ | git clone http:// | ||
+ | export IDIR=/ | ||
+ | |||
+ | cd pypc-gen | ||
+ | cat kludge.h $IDIR/ | ||
+ | |||
+ | * Test: Install the package " | ||
+ | |||
+ | apt-get install ipython | ||
+ | ipython | ||
+ | |||
+ | * Then you get the ipython command line. You can start putting commands. Let's try to just connect to a player server. | ||
+ | |||
+ | import pyplayerc as p | ||
+ | client=p.Client(None, | ||
+ | client.connect() | ||
+ | client.set_replace_rule(-1, | ||
+ | client.datamode(p.PLAYERC_DATAMODE_PULL) | ||
+ | |||
+ | * Let's try to read data from a analog input from the phidgets | ||
+ | |||
+ | aio=p.Aio(client, | ||
+ | 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. | ||
+ | |||
+ | * For closing the program nicely | ||
+ | |||
+ | aio.unsubscribe() | ||
+ | del aio | ||
+ | client.disconnect() | ||
+ | |||
+ | * Python is very nice for prototyping, | ||
+ | * There are QT bindings for python. | ||
+ | |||
+ | |||
+ | ==== Data collection phidget program for Weka ==== | ||
+ | |||
+ | * Copy {{fastdev: | ||
+ | |||
+ | 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-> | ||
+ | * 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. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ==== YARP ==== | ||
+ | |||
+ | === Instalation === | ||
+ | |||
+ | sudo apt-get install libace-dev libcv-dev libavdevice-dev ffmpeg | ||
+ | cd | ||
+ | cd local/src | ||
+ | svn co https:// | ||
+ | cd yarp2 | ||
+ | mkdir build | ||
+ | cd build | ||
+ | ccmake ../ | ||
+ | |||
+ | * Press " | ||
+ | * Change the install prefix to / | ||
+ | * Press " | ||
+ | * Select the yarpmod_ffmpeg_graber and opencv_grabber (ON) | ||
+ | * Press " | ||
+ | |||
+ | |||
+ | |||
+ | make | ||
+ | make install | ||
+ | cd | ||
+ | cd local/DIR | ||
+ | xstow yarp2 | ||
+ | |||
+ | * For the python bindings: | ||
+ | |||
+ | cd locar/ | ||
+ | cd example/ | ||
+ | mkdir build | ||
+ | cd build | ||
+ | ccmake ../ | ||
+ | |||
+ | * Press " | ||
+ | * If you get an error related to YARP_DIR, fix the entry for this value to / | ||
+ | * Select the bindings for python and press " | ||
+ | * Press " | ||
+ | |||
+ | make | ||
+ | cp _libpyyarp.so _yarp.so | ||
+ | |||
+ | === Example Summer === | ||
+ | |||
+ | * We use python for this example | ||
+ | * Open a console and run "yarp server" | ||
+ | * Type " | ||
+ | |||
+ | import yarp as y | ||
+ | y.Network.init() | ||
+ | input=y.BufferedPortBottle() | ||
+ | output=y.BufferedPortBottle() | ||
+ | input.open("/ | ||
+ | output.open("/ | ||
+ | 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 ... / | ||
+ | * In the second new console execute: "yarp read ... / | ||
+ | * 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. |