Installation/RaspberryPi

From PaparazziUAV
Jump to: navigation, search

This page only describes the installation on Raspberry Pi 1. If you are running Ubuntu on the Raspberry Pi 2, follow the normal Installation/Linux instructions.

Outcome

Our outcome of this exercise is to have the Paparazzi GCS running on a Raspberry Pi board

Introduction

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 first attempt the GCS display will be handled by a development computer's screen over network from the Pi via X

If you run into trouble, this page explaining how to get things running on a gumstix board may help: GettingTheGCSRunningonAGumstixBoard

Plan

First steps are to get the hardware and set it up.

  1. Get yourself A Raspberry Pi Model B with 512MB of RAM.
  2. Connections you need are micro USB power supply
  3. ethernet to a local network with internet connected through a router
  4. Teminal work to the Pi computer will be done over a SSH connection

Raspbian “jessie”

The potentially easy plan first. The ocaml packages in wheezy are not version 4 and you definitely want those. The highest complexity in getting paparazzi to run on raspberry Pi is getting the packages, doing the building, etc. I think it's great not to have to manually compile a lot and with more official support, your apt-get upgrades will keep everything in sync and buildable.

Upgrading to jessie does take a lot of time, about 4-5 hours in total for the upgrade process, so you do not gain time. It is a smaller number of steps though and most supporting software is installed straight from the repository. If you go with the jessie approach, you also get hard floats.

Download the raspbian image from the Raspberry Pi website. If that's already jessie, then continue installing the packages. Otherwise, continue from here:

$ sudo nano /etc/apt/sources.list 

In that file, change this line:

deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi

to:

deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi

Then first we need to upgrade from wheezy to jessie as follows. These steps will probably take 4-5 hours in total:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Now install the packages:

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 bc
sudo apt-get install ocaml ocaml-native-compilers ocaml-findlib libpcre-ocaml libxml-light-ocaml libxml-light-ocaml-dev libpcre-ocaml-dev liblablgtk2-ocaml liblablgtk2-ocaml-dev 
sudo apt-get install liblablgtk2-gnome-ocaml liblablgtk2-gnome-ocaml-dev libocamlnet-ocaml-dev libocamlnet-ocaml

Now you can continue from the paragraph "Building Ivy" already and skip all the ocaml and opam building inbetween.

Raspbian “wheezy”

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 bc

OCaml 4

Once you have Raspbian installed, the byte-code ocamlc compiler will work, but the ocamlopt native code compiler doesn't work out of the box. This is due to differences in the ARMv6 and ARMv7 instruction sets and is fixed with ocaml 4.00.2.

Do verify if version 4 of Ocaml hasn't been added to the repository. You can verify this with:

apt-cache policy ocaml

which should output version 4. If it's there, you won't need to the other steps, but you can install everything from the repo.

Until then:

  • either install ocaml from Debian testing/jessie, using apt pinning
  • install OCaml 4 from a third party repo and build needed things from source:

install Ocaml 4 from Raspberry OCaml 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 place to look for those libraries

$ sudo apt-get update

and install the libraries:

$ sudo apt-get install ocaml ocaml-native-compilers

OPAM

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 1.2
./configure
make lib-ext
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
opam install -v lablgtk.2.16.0
opam install -v ocamlnet

Note: version lablgtk.2.18.x or above are not compatible, it is also recommended to run `opam pin lablgtk.2.16.0` to avoid unwanted upgrade;

Note: If your ocamlfind command cannot find lablgtk2.glade , you can install conf-glade package with;

opam install -v conf-glade

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

Building Ivy

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/debian

Run the script to install some needed packages:

$ sudo ./develenv.sh

or install the packages needed to for building:

$ sudo apt-get install devscripts debhelper quilt fakeroot dh-ocaml automake git subversion lsb-release

Install some libs (need libxt-dev and tk-dev to build ivy-c):

$ sudo apt-get install libxt-dev tk-dev

Ivy-C

Now we want to build and install ivy-c:

See also paparazzi-portability-support/debian/ivy/ivy-c/README.md

First check out the ivy-c code:

$ svn checkout https://svn.tls.cena.fr/svn/ivy/ivy-c/trunk ivy-c
$ cd ivy-c

Then check the build dependencies and if needed install any missing dependencies with apt-get.

$ dpkg-checkbuilddeps

Then build the (unsigned) binary package:

$ debuild -i -uc -us -b

or if you don't have debuild:

$ dpkg-buildpackage -rfakeroot -us -uc

If you have trouble building the latest ivy-c trunk version, revision 3589 is known to build even with gcc 4.4.5

  • 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 raspbian or el for the soft-float version
  • Horray, now it is installed!

Ivy-ocaml

First build and install ivy-c as described above.

There are two ways to install ivy-ocaml:

  1. building and installing a Debian package (with ocaml3.12 available via apt on wheezy/softfloat)
  2. 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 https://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.

OR

Let the git mirror be with you:

$ git clone https://github.com/flixr/ivy-ocaml.git
$ make
$ make install

ivy-ocaml via OPAM

While the debian package is named ivy-ocaml, in OPAM it is only named ivy (since it is obviously for OCaml).

$ opam update
$ opam install ivy

Horray! Should now be installed.

Ivy-python

To build and install ivy-python, you can either use a python installer (like pip or easy_install) or build a Debian package.

ivy-python via pip

$ sudo apt-get install python-pip
$ pip install ivy-python

ivy-python via Debian package

$ cd ~/paparazzi-portability-support/debian/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.

Building Paparazzi

  • 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.

Remote GCS/Messages

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>)