MAVLink tunnel through MQTT

On the opensource project uasmqtt now it’s possible to ‘tunnel’ MAVLink packets. That means it’s not only to control the smartphone from the ground and get it’s data. Through the same message queue mechanism MAVLink packets can send and received.

To get a proof of concept the AircamQC app was extended to get a bluetooth connection to the Quanum Nova/CX-20 APM quadrocopter. Also a small utility was created to listen on a TCP socket and transfer these data to the MQTT broker (TCPmavlink2uasmqtt).

At the picture you can see the working example. The picture itself was taken through the AircamQC app and triggered by the AircamQC Viewer app.

uasmqtt_2appsAndAPMtunnel

MAVLink packets are different in it’s size and have a starting id (0xFE). The payload length up to 254 bytes is following direct after the starting id. There are also some other importand status bytes so that a packet size is calculated by 6 bytes header + payload + 2 bytes checksum.

The drawback on this approach is the performance. It’s really slow for some reason. A better approach is not to interpred the MAVLink packet stream but to create proper topic structure and json content.
Then the smartphone app can act like a ‘companion computer’ and talk with the copter through MAVLink with all necessary information at the right time, like the heardbeat. But to another aircraft or groundstation the smartphone can talk in it’s own MQTT ‘language’ which should not be too time critical.

The experiment set-up is shown in the following picture.

uasmqtt_components

MAVLink tunnel through MQTT

Open source project for unmanned aerial system on MQTT base

Introduce of a new open source project which uses MQTT with Json data format to communicate between devices. At the moment it contains the parts uavMap to display position and Android app to transfer theses information and also take pictures on demand.

https://github.com/mobile2power/uasmqtt

Why use Message Queue Telemetry Transport with Json data format?

With MQTT you have a broker. Every device can send data and listen to new data complete independently. Means that MQTT has some benefits:

  • With Json data format it’s open and independend from programming language
  • Easy for testing. No problem to write a Mock and connect it to the broker.
  • It’s scalable. Means for example you can have a couple of UAV in the air and control it all with one application. Every UAV can also listen to other UAV to prevent collision.
  • With SSL and login or other authentification it’s secured by design.
  • There are some mechanisms if connection is broken and in case of a timeout.

But there are also some drawbacks

  • TCP has more overhead than UDP. Performance is lower.
  • Not possible to have a direct device to device communication. Single point of failure and again lower performance.

But usually these drawbacks are not that critical. Only if you want to transmit live video it might be better to use another technology.

About the applications

The first app for the Android Smartphone just collects sensor values for location (GPS, Pressure Sensor) and attitude (Gyros, Accelerator). It uses Eclipse Paho mqtt client to communicate with the broker and Gson to generate json data format for location, attitude and view angle of the cam.
The app also registers a listener for the broker to get the trigger for the cam. Every photo is stored locally on the Smartphone with Geo tagging. Additional a json file is stored with the additional information about attitude and pressure based altitude.

AircamQC Screenshot

The second application is a processing app to show a map with the actual position and orientation of the Smartphone. The pressure based altitude is shown as a number and a rectangle displays the covered area by the camera.
On every taken picture the rectangle marker stays in the position to see, what is already covered. Used libraries are UnfoldingMap, Qatja and again Gson.

uavMap Screenshot

Configuration

A really simple approach is to connect the Smartphone via tethering to a laptop with uavMap and the MQTT broker on it. But the wlan range has a limit about 50-70 m without the use of directional antenna.

It’s better to have 2 mobile internet connections running and MQTT broker on an internet server. Then there is no range limitation except the accesss to the mobile internet.

Open source project for unmanned aerial system on MQTT base