AQ QGC 1.7 Beta 1 Linux - Building it on Raspberry Pi 3

Ground Stations and utilities for Windows, Linux, Android, & others

AQ QGC 1.7 Beta 1 Linux - Building it on Raspberry Pi 3

Postby aBUGSworstnightmare » Wed Mar 30, 2016 2:15 pm

THIS IS WORK IN PROGRESS! HINTS/TIPS etc. ARE MORE THAN WELCOME!

This tutorial will show you how to compile QGC for Autoquad on a Raspberry 3.
This will allow you to fully configure your Autoquad Flight controller. With some additional hardware this unit can also be configured as a Ground Control Station (GCS) for FPV, displaying live telemetry and video from the craft.

Min Requirements:
- Raspberry 3
this is preferred since it has integrated Bluetooth and Wifi capability which might come handy in your new GCS
- min. 16GB uSD card, class 10
- keyboard and mouse
- display solution/monitor with HDMI interface

Optional items:
- wireless (preferrably Bluetooth) keyboard/mouse
- custom add-on board for display interface
this is what I'm using here
- USB2.0 Frame Grabber
will be used to capture the live video from the craft. Also requires remaining FPV equipment (camera/video TX/RX, etc)

Hardware used for this tutorial:
- Raspberry 3
- Samsung Evo Class 10 uSD card, 16GB, 8GB card for 'startover image' (see text)

- custom display adapter with and Sharp 10.1in WXGA LQ101K1LY05 module
- Basetech USB 2.0 Video Grabber (https://www.conrad.de/de/basetech-usb-2 ... 68633.html)

Once everything is done you will end-up with something like this:

https://youtu.be/Bn4qsIh4eKI

But: FIRST COMES THE PAIN!

Preparation:
- download the Raspbian Jessie (latest is 2016-03-18 at the time of writing) image from https://www.raspberrypi.org/downloads/raspbian/
- download SD Card Formatter 4.0 from https://www.sdcard.org/downloads/formatter_4/
Use the tool to format your 'uSD card
- download Win32DiskImager from https://sourceforge.net/projects/win32diskimager/
Use Win32Diskimager to install the image file on your uSD card.
Details on this process are available here https://www.raspberrypi.org/documentati ... windows.md

NOTE: There is the risk that you need to start from scratch because something went wrong or you want to try a different approch. That's why I'm using TWO uSD cards, a small 8GB for making a 'start-over' installation - inclusing all the basic bit's and pieces - and a larger one for working/testing.
You can read and write images with Win32Image writer tool; restarting with a fresh image is much faster then doing all from sratch agein!

Format the (startover) uSD card using SD card formatter and install the Raspbian image by using Win32DiskImager.

Insert the (startover) uSD card in your RPi3 and boot the system for the first time.

Now we need to configure some things:
Code: Select all
sudo raspi-config

1.png
Expand the filesystem
1.png (28.26 KiB) Viewed 7414 times

Under Boot options select the desired login sheme
2.png
Select autologin (optional)
2.png (19.44 KiB) Viewed 7414 times

Some more settings under Advanced options
3.png
3.png (29.13 KiB) Viewed 7414 times

2_1.png
Under ADVANCE select MEMORY-SPLIT
2_1.png (28.91 KiB) Viewed 7344 times

2_2.png
Increas avaalable memory to the GPU
2_2.png (12.45 KiB) Viewed 7344 times

4.png
4.png (29.66 KiB) Viewed 7414 times

5.png
5.png (28.75 KiB) Viewed 7414 times

6.png
6.png (13.1 KiB) Viewed 7414 times

You will be prompted to reboot the system

df -h /
Tip: This command will display partition size


Execute below commands one after another. You need to reboot at the end.
Code: Select all
sudo apt-get update
sudo apt-get upgrade
sudo rpi-update
sudo reboot


Make some additional installations next:
Install a VNC server. Will come handy later.
Code: Select all
sudo apt-get install tightvncserver

Install the device tree compiler and get the Raspberry device tree sources from git.
Note: Git is part of the Raspbian distribution, so need need to install the packages.
Code: Select all
sudo apt-get install device-tree-compiler
wget https://raw.githubusercontent.com/raspberrypi/firmware/master/extra/dt-blob.dts


EDIT:Prevent Raspberry from 'screen blackening'
Install 'set' tools
Code: Select all
sudo apt-get install x11-xserver-utils


Note: You will use 'nano' editor for doing some of the following settings. In 'nano' you will have to push [STRG]+O to write (save) the file and [STRG]+X for closing nano when you're done


Disable screen blanking on console by editing the file '/etc/kbd/config'
Code: Select all
sudo nano /etc/kbd/config

and change the relevant lines like this
Code: Select all
BLANK_TIME=0
BLANK_DPMS=off
POWERDOWN_TIME=0


Edit X-power saving settings in the autostart file
Code: Select all
sudo nano /etc/xdg/lxsession/LXDE/autostart

Search for the 'xscreensaver' settings and commend them out (adding # at the beginning of the line)
Code: Select all
@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
#@xscreensaver -no-splash
@xset s noblank
@xset s off
@xset -dpms


Code: Select all
sudo nano /etc/lightdm/lightdm.conf

Update the /etc/lightdm/lightdm.conf file by adding the following command in the [SeatDefaults] section
Code: Select all
[SeatDefaults]
...
xserver-command=X -s 0 -dpms
...


Install/check gcc, SDL1.2, udev.
Code: Select all
sudo apt-get install build-essential libsdl1.2-dev libudev-dev

Install bluetooth tools
Code: Select all
sudo apt-get install bluetooth bluez blueman

Install 'mplayer' audio/movie player
Code: Select all
sudo apt-get install mplayer2

Install DFU-utils, needed for FW flashing
Code: Select all
sudo apt-get install dfu-util

Clone the Autoquad Ground Control Repository
As already pointed out, Git is already installed on a Raspberry Pi! To clone (checkout) the QGC repository, run the following commands (in the directory that you want the qgroundcontrol_aq folder to be created):
Code: Select all
git clone https://github.com/AutoQuad/qgroundcontrol_aq.git
cd qgroundcontrol_aq
git submodule update --init

Install additional libraries for text-to-speech support (festival)
Code: Select all
sudo apt-get install festival-dev festival

Connect an active speaker/headphone to the 3.5mm jack and test speach output
Code: Select all
echo "Testing speach synthesis on the F-Pi-V - Ground control Station for Autoquad." | festival --tts


Main task for this tutorial is installing/configuring QT on the Raspberry Pi for building AQ QGC.

EDIT 31/03/2016:
- Added note to 'startover' uSD image
Your (startover) uSD card is finished here. Now it's a good idea to generate an image file from your uSD and store it on your PC.
I'm using a 8GB card for this, so it's easy to transfer the image to a 16GB or larger card. If you want to use a larger card fto proceed with the next steps (QT installation etc) make sure to expand the filsystem again after you've booted the larger card for the first time.

- Added missing pictures on GPU Memory Split and how to disable screensaver

EDIT 05/04/2016:
- Since xscreensaver shows up an annoying massage after each boot I've changed the instructions on how to disable screen blanking
Last edited by aBUGSworstnightmare on Tue Apr 05, 2016 7:00 pm, edited 8 times in total.
aBUGSworstnightmare
 
Posts: 1460
Joined: Fri Jun 22, 2012 5:24 pm

Installing/Configuring QT5

Postby aBUGSworstnightmare » Wed Mar 30, 2016 2:49 pm

Installing/Configuring QT5
Install Qt5 (copy the whole block below at once and paste it into the command line, not by line!)
Code: Select all
sudo apt-get install qtcreator qttools5-dev qtbase5-dev qt5-default qtdeclarative5-dev libqt5svg5-dev libqt5webkit5-dev libsdl1.2-dev build-essential libudev-dev qtmultimedia5-dev


Open Qt creator, make required changes to project and build it
7.png
Open Qt creator

8.png
Open the qgroundcontrol_aq project file

9.png

10.png
Click on CONFIGURE PROJECT

11.png
Click PROJECTS

13.png
Change build configuration to RELEASE

14.png
Click on MANAGE KITS

15.png

16.png
In COMPILERS TAB click ADD and select GCC from the menu

17.png

18.png
Click the BROWSE button

19.png

20.png

21.png

22.png
Click APPLY and OK to finish this


25.png
Click on DETAILS and add '-j4' as option for the new make step.
NOTE: Each compilation unit (source to object) is single threaded, but "make" includes a powerful multi-threading system. All you need to do
is tell it how many concurrent jobs to allow using the -j parameter.
One job per core is reasonable - hence -j4

26.png
Your project is now fully configured. Click the green PLAY button to start the compilation process. -j4 option will bump your CPU load to 100% (all 4 cores active), build should be completed after roughly 15min


Autoquad Ground Control should automatically be sterated after build was finished.
27.png


EDIT 05/04/2016:
You can also build qgroundcontrol_aq from the command line:
Code: Select all
cd qgroundcontrol_aq
qmake qgroundcontrol_aq.pro
make -j4
Last edited by aBUGSworstnightmare on Tue Apr 05, 2016 7:02 pm, edited 2 times in total.
aBUGSworstnightmare
 
Posts: 1460
Joined: Fri Jun 22, 2012 5:24 pm

Additional steps and first test

Postby aBUGSworstnightmare » Wed Mar 30, 2016 3:00 pm

Close QT and the QGC application now. Before you can use it some additional steps are required.

UDEV Rules (source: README-Linux.txt)
----------
On many Linux installations, access to USB devices is limited to the root user by default. This is controlled by the "udev" service.
If you want to be able to run QGC as a non-root user, you will very likely need to install some udev rules.
There are three rule files included with QGC, found in the `files/etc` subfolder. These should work for common serial adapters
from FTDI and Silicone Labs (CP2102), as well as the USB devices provided by the AutoQuad M4 board (STM32-based devices from ST Micro).

To install these rules copy them to your `/etc/udev/rules.d` directory. For example, run the following command,
replacing `[path_to_QGC]` with the actual QGC installation folder:

sudo cp [path_to_QGC]/files/etc/*.rules /etc/udev/rules.d/
----------
Code: Select all
sudo cp qgroundcontrol_aq/files/etc/*.rules /etc/udev/rules.d/


Some files needs to be copied into the application folder. It is the content of 'qgroundcontrol_aq/aq'
27-1.png

NOTE: I would prefer a more elegant process here using the terminal. So your input is more than welcome!

28.png
Copy 'aq' folder to the 'bin' folder of your build location

29.png

30.png
Mixes folder is fine

31.png
In case of the bin file you need to copy the content of the 'aq_unix_all' folder


Now we can start the new application for the first time. Initial test is to see if we're able to flash a new firmeware to an Autoquad Flight Controller. I'm using a M4r6 for this test.
32.png
Select your firmware file, change FC type to M4 USB and click FLASH FIRMWARE

33.png
Process should start! --> FISRT GOAL REACHED!

35.png
Power cycle the flight controller
aBUGSworstnightmare
 
Posts: 1460
Joined: Fri Jun 22, 2012 5:24 pm

Re: AQ QGC 1.7 Beta 1 Linux - Building it on Raspberry 3

Postby aBUGSworstnightmare » Wed Mar 30, 2016 3:21 pm

Connecting via Bluetooth
Since the RPi3 has an integrated BT interface I'm focusing on this connetion method here. Serial connection via USB needs to be evaluated later.
Click the BT icon in the upper right corner of your screen and then click DEVICES
37_1.png
Click on SEARCH -> your module should show up in the list

37_2.png
Click the KEY symbol to create a pairing with the device. It will (usally) ask for a pairing key (i.e. 0000 or 1234).
Input the propper PIN and click Ok
Click on the yellow star symbol to THRUST this device. This will lead the RPi3 to automatically reconnect to the device in case the connection got interrupted.

38.png
Your BT module is configured now. You need to assign it to a COM channel next


Scan for available BT devices
Code: Select all
hcitool scan

This gives me two results in this example, were 'NAZE32_0r5' is the BT module I'm looking for. Remember it's address; you will need it later ( here 00:19:5D:E0:30:4A)
Now we can bind it to an RF interface
Code: Select all
sudo rfcomm bind 0 00:19:5D:E0:30:4A 1

With '0' is the RF COM channel number and next is the BT address.
Next we can list available COM devices
Code: Select all
ls /dev/rfcomm*

39.png
39.png (18.49 KiB) Viewed 7409 times

We will cerate a desktop link later for this task but now let's try to connect with the AQ FC via BT.
40.png
Add a new communication link - select rfcomm0 and cllick connect
40.png (22.85 KiB) Viewed 7409 times

42.png
You should be connected to the FC via BT now! You can change settings, parameters etc.


NOTE: there is an usolved problem with the QuatosTool at the momemt. That's why you cant process .xml-files!
I'm looking for a solution and hope somebody is able to help/guide me.

43.png
Remaining problem with QuatosTool - still unsolved!
aBUGSworstnightmare
 
Posts: 1460
Joined: Fri Jun 22, 2012 5:24 pm

Re: AQ QGC 1.7 Beta 1 Linux - Building it on Raspberry Pi 3

Postby JussiH » Wed Mar 30, 2016 6:58 pm

Joerg,

Very comprehensive guide. Thanks!

I have a Pi3 is in the mail and I will try this next week, when it gets here.

I was wondering why you went to the trouble of designing your own LVDS expander for the Pi3. I was under the impression that the "Display" connector on the Pi was LVDS?

Have you made a current reading on your Pi3 yet? DS states up to 2.5A at 5V, but I was hoping to get away with a 1.5A recom...
JussiH
 
Posts: 2103
Joined: Thu Jun 21, 2012 9:25 pm

Re: AQ QGC 1.7 Beta 1 Linux - Building it on Raspberry Pi 3

Postby aBUGSworstnightmare » Thu Mar 31, 2016 8:26 am

JussiH wrote:I was wondering why you went to the trouble of designing your own LVDS expander for the Pi3. I was under the impression that the "Display" connector on the Pi was LVDS?...

Hi Jussi,

yes and no!
Yes, the RPi has a LVDS interface (LVDS = Low Volrage Differential Signaling) which is according to MIPI standard (https://en.wikipedia.org/wiki/Display_Serial_Interface), usually referred to as DSI = Display Serial Interface.

What I'm using is a LVDS interface according to FDP-Link (Flat Panel Display Link) standard (https://en.wikipedia.org/wiki/FPD-Link).

MIPI is quite common for mobile equipment (handys, tablets, etc) were FDP-Link is still the standard interface for industrial applications i.e. (although more and more module were intruduced which have an eDP interface).

Developing the board was one of my business tasks; believe me it's not that complex to do it once you've figured out what the host gives you.

JussiH wrote:Have you made a current reading on your Pi3 yet? DS states up to 2.5A at 5V, but I was hoping to get away with a 1.5A recom...

This is still on my to-do list! But: I'm using a 1.5A RECOM too and had no issues so far.

EDIT: Here you go:
roughly 7.2W (12V x 0.6A) incl. display module
rougly 3W for RPi3 + display logic part
WP_20160331_15_14_19_Smart.jpg
Running a video using omxplayer

WP_20160331_15_19_44_Smart.jpg
Backlight disconneced; RP3 and display logic part still running
Last edited by aBUGSworstnightmare on Thu Mar 31, 2016 2:37 pm, edited 1 time in total.
aBUGSworstnightmare
 
Posts: 1460
Joined: Fri Jun 22, 2012 5:24 pm

Re: AQ QGC 1.7 Beta 1 Linux - Building it on Raspberry Pi 3

Postby pilotnbr1 » Thu Mar 31, 2016 1:06 pm

Wow you have been busy! Very nice Joerg! I like all the screen shots- will make it so much easier!

A couple thoughts for the wiki:
-after running raspi-config if I make changes it prompts me to reboot so I don't have to go to terminal
-I know I am a minority Linux user but for me to create my Jessie image on an sd card I use the "Disks" utility (so all gui). I "format" (quick or slow), "restore disk image"(write Jessie), and can also make a backup with "create disk image"
-maybe I missed it but you can copy the executable from qgroundcontrol_aq/bin to the desktop
-the alternative for udev rules is terminal "sudo su" then "cd /qgroundcontrol_aq/bin" and "./qgroundcontrol_aq" to run as super user AFAIK

A couple ideas on development:
-setup a service or bash script to start qgc. Possibly even avoiding the overhead of the desktop gui by raspi-config boot to cammnd line
-bash script to start the bluetooth by itself or included with the above script

Awesome job! :D

Luke
pilotnbr1
 
Posts: 86
Joined: Thu Feb 26, 2015 10:19 pm

Re: AQ QGC 1.7 Beta 1 Linux - Building it on Raspberry Pi 3

Postby aBUGSworstnightmare » Thu Mar 31, 2016 2:42 pm

pilotnbr1 wrote:Wow you have been busy! Very nice Joerg! I like all the screen shots- will make it so much easier!

A couple thoughts for the wiki:
-after running raspi-config if I make changes it prompts me to reboot so I don't have to go to terminal
-I know I am a minority Linux user but for me to create my Jessie image on an sd card I use the "Disks" utility (so all gui). I "format" (quick or slow), "restore disk image"(write Jessie), and can also make a backup with "create disk image"
-maybe I missed it but you can copy the executable from qgroundcontrol_aq/bin to the desktop
-the alternative for udev rules is terminal "sudo su" then "cd /qgroundcontrol_aq/bin" and "./qgroundcontrol_aq" to run as super user AFAIK

A couple ideas on development:
-setup a service or bash script to start qgc. Possibly even avoiding the overhead of the desktop gui by raspi-config boot to cammnd line
-bash script to start the bluetooth by itself or included with the above script

Awesome job! :D

Luke


You are telling me that you're the 'Linux guy', so why don't YOu post such stuff:
Code: Select all
[Desktop Entry]
 Name=qgroundcontrol_aq
 Comment=Autoquad Ground Control Centre
 Icon=/home/pi/build-qgroundcontrol_aq-Desktop-Release/qgroundcontrol.png
 Exec=/home/pi/build-qgroundcontrol_aq-Desktop-Release/bin/qgroundcontrol_aq
 Type=Application
 Encoding=UTF-8
 Terminal=false
 Categories=None;

QGroundcontrol.zip
(356 Bytes) Downloaded 182 times


Same can be done for BT; already had to scripts with different sysmbols...

So please go ahead! Make some screenshots on the image writing/generating process on Linux and post them here. I'm sure I will do the same for Win32diskimager before this stuff goes into the wiki.

This kind of 'usability' stuff is not my focus atm; need to figure out why the install script and QuatosTool is still not running.
Beside of that you will alreday get a full functional QGC!
aBUGSworstnightmare
 
Posts: 1460
Joined: Fri Jun 22, 2012 5:24 pm

Re: AQ QGC 1.7 Beta 1 Linux - Building it on Raspberry Pi 3

Postby pilotnbr1 » Thu Mar 31, 2016 3:52 pm

I don't have any scripts atm but I would post if/when I do... I play with Linux and figure things out with lots of googling but barely have the knowledge and abilty as the rest of you! At the moment, have some time, but life is about to get very busy for me. The least I can do is post a screenshot of Linux Disks utility if thats helpful! Sorry if I am muddying the waters with suggestions. :oops: Thanks again for your efforts!

Luke

Screenshot from 2016-03-31 10-44-06.png
pilotnbr1
 
Posts: 86
Joined: Thu Feb 26, 2015 10:19 pm

Re: AQ QGC 1.7 Beta 1 Linux - Building it on Raspberry Pi 3

Postby pilotnbr1 » Thu Mar 31, 2016 4:53 pm

One other small thing I can contribute- and I am sorry this falls in the usability category, so low priority- is this shutdown by an external switch. This is done in order for the rpi to have an orderly shutdown and not corrupt files in particular any video stream you are recording. Really only applies if you run it without a mouse or headless.

shutdown.sh
Code: Select all
#!/bin/bash

SHUTDOWN_PIN=25

echo $SHUTDOWN_PIN > /sys/class/gpio/export

while :
do
   PINV=`cat /sys/class/gpio/gpio$SHUTDOWN_PIN/value`
   if [ $PINV -eq "1" ]; then
      echo "Shutdown"
      sudo halt
   fi
   sleep 1
done


Within my local "init.d" folder is "shutdown" file--- change the directories to point to where you have the other scripts
Code: Select all
#!/bin/sh
### BEGIN INIT INFO
# Provides:          shutdown
# Required-Start:
# Required-Stop:   
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: shutdown by gpio event
# Description:     
### END INIT INFO
 
# Actions
case "$1" in
    start)
        # START
        /home/pi/wifibroadcast_fpv_scripts/shutdown.sh &
        ;;
    stop)
        # STOP
        killall shutdown.sh
        ;;
    restart)
        # RESTART
   killall shutdown.sh
        /home/pi/wifibroadcast_fpv_scripts/shutdown.sh &
   ;;
esac
 
exit 0


Then the service to keep it running within local folder "systemd" is file "shutdown.service"
Code: Select all
[Unit]
Description=shutdown
After=multi-user.target

[Service]
TimeoutStartSec=0
ExecStart=/home/pi/wifibroadcast_fpv_scripts/shutdown.sh

[Install]
WantedBy=multi-user.target



For the switch is a simple single pole rocker type switch with two wires going to gpio pins 5 and 6. For the shutdown script that is just gpio 3.


20160204_172203.jpg
pilotnbr1
 
Posts: 86
Joined: Thu Feb 26, 2015 10:19 pm

Next

Return to AQ Software

Who is online

Users browsing this forum: No registered users and 3 guests

cron