Wifibroadcast is a project aimed at the live transmission of HD video (and other) data using wifi radios. One prominent use case is to transmit camera images for a first person view (FPV) of remote controlled aircrafts.
In contrast to a normal wifi connection wifibroadcast tries to mimic the advantageous properties of an analog link (like graceful signal degradation, unidirectional data flow, no association between devices).
Wifibroadcast puts the wifi cards into monitor mode. This mode allows to send and receive arbitrary packets without association. Additionally, it is also possible to receive erroneous frames (where the checksum does not match). This way a true unidirectional connection is established which mimics the advantageous properties of an analog link.
Wifibroadcast is included in the latest EMLID Raspberry Pi beta image for NAVIO+ and NAVIO2. One may use one RPi’s untapped processing power to get video from the camera and transmit it on the fly, while running Ardupilot or PX4 on the same unit.
Enabling and disabling WBC can be done via ssh as demonstrated in the docs, but this quickly gets frustrating when in the field. Instead, it would be much simpler to be able to control video transmission via a spare RC switch on the Radio Transmitter. With Ardupilot running and PyMavlink it is easy to write a Python script that controls WBC. The folks at EMLID have introduced WBC as a
systemd service, thus interfacing with
systemctl from python is enough to do the job. According to this Stackoverflow question, there is an easy way to interface with systemd, using the DBus API, and this is what we will be using. Below are the steps I used to achieve this.
First, we need to configure Ardupilot to output telemetry locally via UDP:
This will enable us to communicate with Ardupilot easily from within the RPi. Then, we are going to need to have the PyMAVLink library installed. This library enables a Python script to send and receive MAVLink messages. You can install PyMAVLink using pip as follows:
The Wifibroadcast Control Script
As a next step comes the actual script that listen for RC related MAV messages and runs our shell commands:
The script is configured to listen to RC channel 8, so if you need to listen to a different chennel, you’ll need to change that. Also, the threshold for detecting a value change is 1500, which is somewhere around the middle of a servo value. Again, change this if required.
Finally, we will need to let the OS know that we want the script to run at startup. While we may do this easily by altering
/etc/rc.local, a cleaner alternative is to introduce a new service. This is easily done by creating a new file with extension
/lib/systemd/system/ . I chose to name it “wbcrcs”, for Wifibroadcast RC Switch1:
And add the following:
Finally, you’ll need to enable the service:
Reboot the Pi and your custom service should run :
In this post we implemented a simple way to enable and disable Wifibroadcast video transmission through the use of an RC Switch. If successfully configured, our script will run as a service, and be available at boot time. This is convenient to allow configuration through WiFi and later on switching on video transmission when in the field.
Why not Dronekit?
There was a post sometime back in the EMLID forums where George Staroselskiy had demonstrated the same type of control using Dronekit. But using Dronekit alone raised the CPU usage on a RPi2 to around 20%. With the MAVLink-based solution presented in this post, the CPU usage floats around 2%. Still too much for a simple RC switch listener, but acceptable.