- 1 Outcome
- 2 Introduction
- 3 Plan
- 4 Raspbian “wheezy”
- 5 Soft-float Debian “wheezy”
- 6 Building Ivy
- 7 Building Paparazzi
- 8 Trying it out
Our outcome of this exercise is to have the Paparazzi GCS running on a Raspberry Pi board
The Raspberry Pi is a small ARM-based computing platform. It is low power, lightweight and very inexpensive, and runs Linux. This makes it an attractive platform for advanced autonomy or payload functionality onboard a UAV, or as part of a compact portable ground control station. For more detailed information, see the Raspberry Pi website.
This page is a compilation of information related to running Paparazzi related items on the Raspberry Pi. For this frist attempt the GCS display will be handled by a development computer's screen over network from the Pi via X
First steps are to get the hardware and set it up.
- Get yourself A Raspberry Pi Model B with 512MB of RAM.
- Connections you need are micro USB power supply
- ethernet to a local network with internet connected through a router
- Teminal work to the Pi computer will be done over a SSH connection
Raspbian is a free operating system based on Debian optimized for the Raspberry Pi hardware. An operating system is the set of basic programs and utilities that make your Raspberry Pi run.
To run OCaml on the hardfloat Raspbian you need to build some libs from source. This is a bit more work than then soft-float version, but should run faster.
First install some dependencies:
$ sudo apt-get install bzip2 git-core make gcc g++ gnuplot glade imagemagick libpcre3-dev libusb-dev python-usb python-lxml python-wxgtk2.8 speech-dispatcher libgnomecanvas2-dev m4 libsdl1.2-dev
Once you have Raspbian installed, the byte-code ocamlc compiler will work, but the ocamlopt native code compiler doesnt work out of the box. This is due to differences in the ARMv6 and ARMv7 instruction sets.
Since we need ocamlopt: install Ocaml 4 from Raspberry Caml by adding to your /etc/apt/sources.list:
$ sudo nano /etc/apt/sources.list
and add thes lines:
deb http://www.cl.cam.ac.uk/~lpw25/ocaml-rpi/ wheezy main deb-src http://www.cl.cam.ac.uk/~lpw25/ocaml-rpi/ wheezy main
Save the file (CTRL+X)
Then update the repository data so it will find the new palce to look for thos libraries
$ sudo apt-get update
and install the libraries:
$ sudo apt-get install ocaml ocaml-native-compilers
The OPAM (OCaml Package Manager) is used to build some other ocaml libs for OCaml 4.0.
git clone https://github.com/OCamlPro/opam.git cd opam git checkout -b latest origin/latest ./configure && make sudo make install
opam init eval `opam config env`
Update your shell environment as per opam init's instructions. E.g. add to your ~/.profile:
eval `opam config env`
Install some dependencies to build lablgtk for ocaml:
sudo apt-get install libglade2-dev libgnomeui-dev libgnomecanvas2-dev librsvg2-dev libgtkspell-dev libcanberra-gtk-dev
Build and install needed OCaml libs for 4.0:
opam install ocamlfind xml-light pcre-ocaml opam install -v lablgtk opam install -v ocamlnet
Soft-float Debian “wheezy”
This attempt so far has proven fruitful. The soft-float version does not have hardware floating point support, and thus is slower. However, it tends to be more compatible.
So far, only the paparazzi-dev dependencies have been installed, and this means no airborne code for autopilots can be built. In addition, a number of extras for calibration, etc. have not yet been installed, so difficulty might be encountered in calibration scripts, etc. However, the goal so far is to run ground side programs such as server, messages, gcs, etc. This allows allows fast prototyping of additional autonomy features using the Ivy bus to make easy communication between programs on the RPi and the autopilot. It also allows for telemetry over wifi or a network, etc. Lots of room for exploration.
The following are rough notes on how to install. It could definitely be improved, but hopefully provides a decent starting point.
- First install the OS as per the Raspberry Pi wiki here
- Then boot it up and ssh in over your local network
- Then run: $ sudo raspi-config and change the timezone, password and expand root partition to fill sd card, and anything else. Exit and reboot.
$ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install vim
or your other favourite editor
- Install all the paparazzi-dev dependencies in one shot:
$ sudo apt-get install ocaml-findlib ocaml-native-compilers libxml-light-ocaml-dev liblablgtk2-ocaml-dev liblablgtk2-gnome-ocaml-dev \ libocamlnet-ocaml-dev libsdl-ocaml-dev libpcre-ocaml-dev gtk2-engines-pixbuf make gcc g++ libgsl0-dev gnuplot \ libgnomecanvas2-dev bzip2 git libusb-dev speech-dispatcher glade imagemagick libpcre3-dev libsdl1.2-dev
If you want to use the python tools as well:
$ sudo apt-get install python-lxml python-wxgtk2.8 python-usb python-yaml
Next, we should install libocamlgsl-ocaml-dev, but this doesn't work. This library won't build at all because of the following (from the README): "Architectures with double-word alignment for doubles are not supported"
However, this isn't a major problem, because this lib is currently not used for anything at all in Paparazzi (was going to be used for some yet unfinished features).
Clone the paparazzi-portability-support repo and install some tools to build debian packages:
$ git clone https://github.com/paparazzi/paparazzi-portability-support.git $ cd paparazzi-portability-support/linux $ sudo ./develenv.sh
Install some libs (need libxt-dev and tcl-dev to build ivy-c):
$ sudo apt-get install libxt-dev tcl-dev
Now we want to build and install ivy-c:
$ cd ~/paparazzi-portability-support/linux/ivy/ivy-c
Note: Before here you might have to:
$ git pull https://github.com/flixr/ivy-c.git (from ivy dir)
First check the build dependencies and if needed install any missing dependencies with apt-get.
Then build the package:
$ fakeroot debian/rules get-orig-source $ tar -xvzf ivy-c_3.12.1.orig.tar.gz $ cd ivy-c-3.12.1/ $ rm -rf debian/ $ cp -r ../debian . $ dpkg-buildpackage -rfakeroot -us -uc
- Now we can install ivy-c:
$ cd .. $ sudo dpkg -i ivy-c_3.12.1-1_arm**.deb ivy-c-dev_3.12.1-1_arm**.deb
- Here, ** is either hf for the hard-float raspian or el for the soft-float version
- Horray, now it is installed!
First build and install ivy-c as described above.
There are two ways to install ivy-ocaml:
- building and installing a Debian package (with ocaml3.12 available via apt on wheezy/softfloat)
- building and installing via OPAM (with ocaml libraries installed via OPAM on raspbian/hardfloat)
ivy-ocaml as Debian package
Install some prerequisites to build the ocaml debian package if you haven't already done so.
$ sudo apt-get install dh-ocaml
Now to build and install ivy-ocaml:
$ svn checkout http://svn.tls.cena.fr/svn/ivy/ivy-ocaml/trunk ivy-ocaml $ cd ivy-ocaml $ debuild -i -us -uc -b $ sudo dpkg -i ivy-ocaml_1.1-12_armel.deb
The .deb package may be named slightly differently. Adjust as required.
Let the git mirror be with you:
$ git clone https://github.com/flixr/ivy-ocaml.git $ make $ make install
ivy-ocaml via OPAM
ivy-ocaml will soon be added to the official opam-repository, in the meantime you can use a clone that already includes it:
$ opam repo add flixr git://github.com/flixr/opam-repository.git $ opam update $ opam install ivy-ocaml
Horray! Should now be installed.
Now to build and install ivy-python:
$ cd ~/paparazzi-portability-support/linux/ivy/ivy-python $ uscan --force-download $ dpkg-buildpackage -rfakeroot -us -uc $ sudo dpkg -i ivy-python_2.2-3~ppa1_all.deb
- Horray should be working now.
- Get the paparazzi source as per usual, using your desired method/setup as described in git, e.g.:
$ git clone https://github.com/paparazzi/paparazzi.git
- Now change to the paparazzi directory
$ cd paparazzi
- Set the PAPARAZZI_HOME and PAPARAZZI_SRC environment vars
$ git checkout master
- Build Paparazzi:
$ make ground_segment
- Build the native versions of the GCS and Server (which will run faster)
$ make ground_segment.opt
Trying it out
Rebooting is not a bad idea. There were some issues with GTK initialization, but they are intermittent, and ever since a reboot they seem to be better.
Running directly on the RPi
First test can be to run paparazzi center or messages with X11 forwarding. Start the ssh connection to the RPi using the -x option. Make sure ssh forwarding is enabled in the sshd config on the RPi. Google for instructions. Then:
- $ cd ~/paparazzi
- $ ./paparazzi
- After some waiting, you should see a window pop up on your local machine with paparazzi center.
- You can then launch a session as usual...
- To get some more speed, use the native version of the GCS and server by running sw/ground_segment/cockpit/gcs.opt and sw/ground_segment/tmtc/server.opt instead of the non-opt versions.
Next, one can try simulating on the local machine, and pushing the ivy bus messages across the local network and reading them with the programs on the RPi.
- Build and test an airframe you wish to simulate as usual on the local machine, and test it quickly by simulating
- Stop all the agents, and add the following option to the call: -b <local network broadcast ip> (for example 192.168.0.255)
- Before running programs on the RPi, it needs to know about the freshly compiled airframe. So, copy the conf/conf.xml file from the local machine to the RPi, and also the whole var/ folder intact, AFTER having compiled for simulation
- Restart the agents on the local machine with the ivy bus option, everything should be working as before
- Now start messages on the RPi as described above, but set the bus to the same IP as the local machine (you can also try out the GCS by running $ sw/ground_segment/cockpit/gcs -b <local network broadcast ip>)