There are three options available to install the software on the Raspberry Pi.

  1. You can flash the SD card with our most up to date SD card image. After the SD card has been flash and inserted in the Raspberry Pi, the system will be ready to fly.
  2. If you need more control, download the latest Raspbian image and run our install script. The image mentionned above is generated with the install script.
  3. Alternatively, install all packages manually. We do not actively support this method. Instructions might be outdated.

In all cases, you will need to install Etcher.io or another equivalent software to flash SD card images.

The shell script is self-documenting and an excellent way to replicate a development environment. If you plan to add software packages to your development environment on the Raspberry Pi, we strongly recommend that you add them to the shell script and rebuild the image. This way, your development environment is easily reproducible.

1. Install with SD Card Image (Recommended).

  1. (Optionnal) Format the SD card using SD Card Formatter. (SD Card Formatter can be downloaded from here)
  2. Download the RCbenchmark Otus Quadcopter image from here. (image coming soon).
  3. Download Etcher.io.
  4. Launch Etcher.io and select the RCbenchmark Otus Quadcopter image and the formatted SD card then click on Flash!
  5. Once the image is flashed on the SD card, insert the SD card into the Raspberry Pi and connect the Pi to a monitor and keyboard.

2. Install Necessary Software with a Shell Script (Alternative Option).

  1. (Optionnal) Format the SD card using SD Card Formatter. (SD Card Formatter can be downloaded from here)
  2. Download the stock Raspbian stretch image from here.
  3. Download Etcher.io.
  4. Launch Etcher.io and select the Raspbian image and the formatted SD card then click on Flash!.
  5. Once the image is flashed on the SD card, insert the SD card into the Raspberry Pi and connect the Pi to a monitor and keyboard.
  6. Follow the general setup procedure to setup Raspbian and connect to the Wifi.
  7. Open the terminal and enter the following command to clone the github repository.

git clone https://gitlab.com/TytoRobotics/Transport_Protocol.git

then, navigate to the branch Transport\_Protocol-V2 by entering the following command:

cd Transport_Protocol/

git checkout Transport_Protocol-V2

once on the branch, run the following command:

sh Quad_Environment/installer.sh

The installation of all the files will begin automatically. Some package like lxml, might take a bit longer to install.
After the installation is complete, the Pi will reboot automatically.

3. Install Packages Manually (Not Recommended, Legacy)

4.2 Raspiberry Pi setup

​4.2.1​ Install Raspbian onto Raspberry Pi

  1. Use a PC with a SD card slot (not raspberry pi)
  2. Insert the microSD card (#3) and confirm the minimum specification of 16GB+ (to ensure storage space) and Class 10 (to ensure speed and reliability)
  3. Download and install etcher.io
  4. Download Raspbian image (RASPBIAN STRETCH WITH DESKTOP). Unzip. Flash the .iso to the SD card using Etcher.io.
  5. Insert the SD card in the Raspberry Pi, connect it to a monitor using HDMI and then power it using the provided microUSB power adapter.

Note: You will receive the following screen if the OS is not bootable which can be caused by incompatible OS but also insufficient power to the raspberry PI or faulty micro SD card.

4.3 Enable Wifi

The raspberry pi b+ comes with the wifi disable. To enable the wifi, open up the terminal and enter the following command

sudo raspi-config

Under Network Options, select the N2 Wi-Fi, you will receive a prompt to enter the SSID and passphrase for the wifi. The operating system may also ask you to set your location/ timezone.

​4.4​ Activate SSH

SSH allow you to login to the computer remotely. This means that you can access the terminal of the Raspberry Pi from another computer on the same network (or even the internet). Enter the following codes of line into the terminal of the Raspberry Pi.

sudo apt-get update

sudo apt-get upgrade

If the unable to fetch some archives, you may have to run sudo apt-get update again before trying again to run apt-get upgrade. This may have to be repeated a couple times before a successful upgrade.

Enable ssh by entering the command

sudo raspi-config

then enable SSH under interfacing options.

Also deactivate serial login shell and activate hardware serial interface, under underinterface options.The hardware serial is used later for communicating with the Pixhawk.

3.1 RCbenchmark tracking software

Your virtual environment is now activated. Every package you install will only be available if execute the activate script with the command source activate. If you use a python development environment, you may be able to specify which virtualenv you are using.

Download the scripts to receive the position information from the RCbenchmark Tracking Lab.

git clone https://gitlab.com/TytoRobotics/Transport_Protocol.git

cd Transport_Protocol

git checkout development

If you install the scripts a while ago, there may be update. To download the most recent version, go the the Transport_Protocol folder in command line and type:

git pull

3.2 Dronekit

At this point, it is a good idea to learn how dronekit works. Check out their documentation. With Dronekit, you will be able to retrieve information from the Pixhawk autopilot such as

Attitude (Yaw, Pitch, Roll)

  • Position

  • Velocity

  • Ground velocity

  • Flight mode

  • Battery life

  • Autopilot software version and more….

Install Dronekit

sudo pip install dronekit

Install pyserial for serial communication

sudo pip install pyserial

Install Dronekit-sitl (Software in the loop) aka simulation

sudo pip install dronekit-sitl

Install screen, a terminal multiplexer

sudo apt-get install screen

Additional dependencies that Dronekit may require

sudo apt-get install python-pip python-dev python-numpy python-opencv python-serial python-pyparsing python-wxgtk2.8

Download Dronekit examples from

git clone http://github.com/dronekit/dronekit-python.git

Depending on the connection between the Pixhawk flight controller and the Raspberry Pi, we will need to edit the connection string in the example codes. Set the connection string to the following depending on the connection type. If you have already made the serial connection (section 3.5) than use the serial port connection string.

Connection type Connection string
Linux computer connected to the vehicle via USB /dev/ttyUSB0
Linux Raspberry pi computer connected to the vehicle via USB /dev/ttyACM0
Linux computer connected to the vehicle via Serial port (Raspberry Pi example) /dev/ttyS0 (also setbaud=921600)
SITL connected to the vehicle via UDP 127.0.0.1:14550
SITL connected to the vehicle via TCP tcp:127.0.0.1:5760
OSX computer connected to the vehicle via USB dev/cu.usbmodem1
Windows computer connected to the vehicle via USB (in this case on COM14) com14
Windows computer connected to the vehicle using a 3DR Telemetry Radio on COM14 com14 (also setbaud=57600)

For our serial connection, we will use the following line of code for the connection

vehicle = connect(‘/dev/ttyS0’, baud = 921600, wait_ready = None)

Otherwise, for a USB connection, use

vehicle = connect(‘/dev/ttyACM0’, baud = 921600, wait_ready = None)

Lets test out the connection, save the following file as test.py. To run the test.py example code, while in the directory of the code, type the following line of code into the terminal.

sudo python test.py

You should see similar results if successful.

3.3 MAVProxy

Now we want to allow the drone to communicate with QGroundControl software on the ground station. MAVProxy will be used to forward traffic. Install Mavproxy following these instructions for installation on a Debian based system. If the build wheel for the Mavproxy installation fails, run

sudo apt-get install libxml2-dev libxslt-dev

then try again, for in order to install some C-based dependencies on your Raspberry Pi.

Launch Mavproxy in on the Raspberry Pi, with the following commands, based on how your Pixhawk is connected to your Raspberry Pi.

For USB connection, use the command

mavproxy.py --master=/dev/ttyACM0 --out=udpbcast:192.168.1.255:14550

For serial connection, use the command

mavproxy.py --master=/dev/ttyS0 --out=udpbcast:192.168.1.255:14550 --baudrate=921600

then launch QgroundControl. In the Comm link section, click Add and choose UDP.

Now, in order to auto-launch the scripts in terminal on boot, you need to create a shell executable file.

If you want to automate the launch of the script at startup, create a filelaunch_mavlink.shon the desktop with the lines:

#!/bin/bash

screen -r -m -L ~/Desktop/mavproxy.log mavproxy --master=/dev/ttyS0 --out=udpbcast:192.168.1.255:14550 --baudrate=921600

save the file as launch_mavlink.sh

To make them executable, run the following command at Desktop (since both the files reside at the desktop)

cd Desktop
sudo chmod +x launch_mavlink.sh

Now that both the file is executable, you need to go to a folder called autostart. To do that enter the following commands.

cd ..
cd /.config
cd /autostart

This will take you to the autostart folder, you need to create a .desktop file so that the script runs in a terminal on launch. Create a file using the following commands:

sudo nano mavproxy.desktop

This should open up the nano editor, please enter the below displayed script.

[Desktop Entry]

Type=Application
Name=Mavproxy.sh
Comment=Autolaunch script
NoDisplay=true
Exec=lxterminal -e ~/Desktop/launch_mavlink.sh
NoShowin=GNOME;KDE;XFCE;

Save the file by pressing Ctl+X, then press Y and Enter. Now, reboot the Pi to ensure that the script auto-launches on boot.


  • You should now see mavproxy running (and position forward too, if you are using the Otus Tracker). Check QGroundControl on your ground station. A link to your vehicle should have been established, similar to the one through USB.

4.6​ Prepare to stream position information to the Quadcopter

  1. Check that the Raspberry Pi and the computer with the RCbenchmark Tracking Lab are on the same network
  2. Launch the RCbenchmark Tracking Lab. Verify that the Otus is tracking.
  3. Go in the Server tab. Type in the address of the Raspberry Pi (this can be found by inputting hostname -I in the terminal of the Raspberry Pi). The default port is 5400. However, you may have to set this port to 5401, as port 5400 on the Raspberry Pi may be occupied with the MAVproxy link
  4. Launch the server from the RCbenchmark Tracking lab.

​4.7​ Check that the position information is forwarded from the drone to the PX4

The next step is to forward the position from the Raspberry Pi to the PX4. To do this, you need to launch the script:

Transport_Protocol/UDP/Python/RCB_mavlink_forward_USB.py

In this script, you may have to change the address to which the position is sent. In the script, find the line:

vehicle = connect('/dev/ttyS0', wait_ready=True)

where ttyS0 is the serial port and ttyACM0 would be the USB port. Note that you may experience link timeouts when using these ports while mavproxy is running- this is because the connection is already in use by mavproxy, and you should instead connect to mavproxy instead of the pixhawk directly. 127.0.0.1:14551 is the localhost loopback address. Setwait_ready = None if you are experiencing issues with establishing a link.

Once you are connected with the Serial port and you launched the script RCB_mavlink_forward_USB.py, you can check that the position is correctly received with Qgroundcontrol. Check the axis orientation.

If you are having trouble connecting to the correct IP, instead try launching the script RCB_pose_forward.py. Then, in the RCBenchmark Tracking Lab, you can set the IP to192.168.1.255, as you will not need to send the datagram to a specific computer.

With mavproxy active in a separate terminal, you should see the altitude information in QGroundControl corresponding to the altitude of the vehicle.

4.7.1 Auto-launching position forwarding script

If you are using the Otus Tracker for motion capture, please create the a file called launch_poseforward.sh on the desktop with the following contents. (If you do not have an Otus Tracker, skip the part which deals with position forward)

while true
do
screen -L ~/Desktop/pose.log ~/TransportProtocol/UDP/Python/RCB_pose_forward.py
sleep 1
done

The above created file runs the script again incase the script is exited due to a connection timeout or any other error. This ensures that the on-board computer is always running position forwarding script.

Give the file execute permissions by entering the following command. Assuming that your working directory is currently Desktop.

sudo chmod +x launch_poseforward.sh

In order to run this auto-launch the script on boot, create another .desktop file in autostart folder as you have done for the mavproxy.sh with a new name and enter the appropriate location of the file under the Exec declaration.

4.8 Programing the LCD Display

Once the OLED/LCD display is connected to the Raspberry Pi, you need to do the following to ensure that the serial ports are open for connecting with the screen automatically

  1. Connect the Raspberry Pi to a monitor and keyboard.
  2. Open a terminal and type the following

    sudo raspi-config

  3. Use the down arrows and navigate to Interfacing Options then press enter. Navigate to P5 I2C, hit enter.

  4. Enable I2C and when given an option to reboot, hit yes.

  5. After the system boots up, run the following command to check if the i2c interface is enabled.

    ls /dev/*i2c*

  6. This should return /dev/i2c-1 which represents that the interface is activated.

  7. Now, you need to install the following package to Linux

    sudo apt-get install -y i2c-tools

  8. Now, we need to check the address of the device on the address bus, this can be returned by a method of the i2c-tools package installed. Enter the following command

    i2cdetect -y 1

  9. This give the following output, as depicted in the image below. Take a note of the address.

  10. We are currently using luma.oled, luma.core packages and Pillow packages to communicate with the LCD/OLED display. You can clone the repository from here and install setup,py to automatically install all the necessary packages and dependencies.

    • Or you can directly install these packages using the python package installer (pip) by entering the following commands:

    pip install luma.core

    pip install luma.oled

    pip install Pillow

  11. After you have installed all the necessary packages, make sure that you have the latest version of the RCbenchmarks repository.

    git clone https:https://gitlab.com/TytoRobotics/Transport_Protocol.git
    cd Transport_Protocol
    git checkout Transport___Protocol-V2

    This branch has the LCD.py script which is used to display error messages on the OLED/LCD display.

    In case you do not have git install, you could just download the zip file and extract the contents.

  12. To launch the script on launch, please create a .desktop file as you have created for mavproxy and position forwarding scripts in the steps above.

Now, the Raspberry Pi is equipped and linked with the screen to display error messages and user defined texts.

4.8.1 Displaying your message on the LCD screen

Currently the luma.oled library recreates the whole screen in order to display. To display your message on the screen please follow the steps below:

  1. Connect the Pi to a monitor,keyboard and mouse. Click on the file LCD on the desktop. OR
    SSH to your Raspberry pi and enter the following commands.

cd path to the LCD folder from cloned from Transport_protocol.git

sudo nano LCD.py

  1. Open the file LCD.py using any editor and go to line 38.

  2. Notice that the draw.text method has been commented in code using '#' symbol.

  3. Remove the '#' symbol and enter your message between the parentheses.

  4. Save the program and exit. ( if you have SSHed your way into the program then, press ctl + X and then press Y to save and exit)

  5. Reboot the pi, your message should be displayed on the LCD/OLED screen.

The LCD screen program uses simple logic for easy manipulation and flexibility. Feel free to make changes to the code according to your requirements to make use of the screen.

4.8.2 Deleting the old log files on launch

Since the LCD.py reads the log files for real time error reporting, it is necessary to delete the old files for the next consecutive launch.

For automating the delete operation of these files, please follow the following steps.

  1. Connect the Raspberry Pi to a monitor,keyboard and a mouse.
  2. Open LXterminal by pressing Cntl + Alt + T and type the following:
    1. cd /etc

  3. Once in etc folder edit the rc.local file by typing the following command:

    1. sudo nano rc.local

      rc.local is one of the programs which is run on boot up, this ensures that the old log files are deleted before the start of the position forwarding scripts.

  4. Now, add the following 2 lines just before exit 0 in the file.

    1. sudo rm /home/pi/Desktop/mavproxy.log &

      sudo rm /home/pi/Desktop/pose.log &

  5. Press Cntl + X, then Y to save and exit.

Now the Raspberry Pi is configured to delete the old logs on boot.

4.9 Steam, RCBenchmark Tracking lab + Otus tracker

Begin by installing the RCBenchmark Tracking Lab software for your main computer running Windows 10. Follow these instructions.

4.10 Backup the SD card

MicroSD cards have a tendency to become corrupt. You can create a image of the microSD card so you can restore a new sd card to the same state. Follow the procedure here. The (.img) should be around 14 - 16 GB in size.

results matching ""

    No results matching ""