4. Software setup

Note: Throughout this document, components will be numbered corresponding to the order list. This is to help you identify the component or part that you are working with.

4.1.​ QGroundControl setup

QGroundControl is a program that provides flight control and mission planning for any MAVLink enabled drone. It provides configuration for ArduPilot andPX4 Propowered vehicles. QGroundControl is very easy to use.

4.1.1 Install Qgroundcontrol

Install QGroundControl for your operating system. This software is not to be installed on the on-board computer (Raspberry Pi B+) but rather a main computer. It would be prefered that your main computer was running Windows 10as the RCBenchmark Tracking lab software is only available for Windows 10.

4.1.2 Update PixHawk Firmware

We are currently using EKF2 for position estimation. Please flash the firmware to the latest version.

Note: You can check for other firmware versions here. It should not be necessary in general

​4.1.3​ Calibrating the Pixhawk flight controller

Note: The Pixhawk does not need to be installed to the drone frame in order to calibrate. This videomay help in the calibration process.

The calibration setup of the Quadcopter will provide information to the Pixhawk so that the drone flies as expected. In the Vehicle setuppage of QGroundControl, there are tabs for Frame, Sensors, Radio, Flight Modes, Power, Safety and more. The calibration is straight forward, just follow the onscreen instructions on QGroundControl. During the calibration, the program will ask you to restart the Pixhawk multiple times.

You must have a USB connection between your computer and the Pixhawk. You will be required to disconnect and then reconnect the cable many times throughout the calibration.TIP: There is a reboot option available under the Parameters tab > Tools (top left) > Reboot vehicle.

Throughout the calibration, QGroundControl will ask you for the orientation of the flight controller (Pixhawk) relative to the front of the drone. If you followed our procedure setup, the orientation angle should be 0 degrees. Refer to the following diagram if different.

4.1.3.1 Frame

Select theGeneric 250 quad frameas seen in the following screenshot. This can differ if using a different drone frame than the one we recommended.

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.

4.5 Installing necessary scripts/ software

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

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.

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.

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

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

Check that the Raspberry Pi and the computer with the RCbenchmark Tracking Lab are on the same network

Launch the RCbenchmark Tracking Lab. Verify that the Otus is tracking.

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

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)

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

Connect the Raspberry Pi to a monitor and keyboard.

Open a terminal and type the following

sudo raspi-config

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

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

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

ls /dev/*i2c*

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

Now, you need to install the following package to Linux

sudo apt-get install -y i2c-tools

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

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

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

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

4.9 Steam, RCBenchmark Tracking lab + Otus tracker

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.