MAVLink Api is now available too… 🙂
Works now also with the RadioMaster TX16S … no soldering anymore 🙂
The aim of this project is to make RC transmitters which run the OpenTx firmware being able to handle the MAVLink protocol natively.
The project effectively turns the transmitter into a ground control station for operating your drone. That is, the transmitter not only allows you now to receive the most detailed telemetry data, but also provides a full, bidirectional MAVLink communication link with appropriate bandwidth to the drone and therewith the rich set of capabilities coming with this. For instance, you’ll find the project to offer unprecedented camera and gimbal control capabilities.
The project has several aspects:
- Hardware: The solution does NOT need any additional hardware, such as converters, teensys and so on!
- OpenTx: Extension of the OpenTx firmware to handle MAVLink.
- Telemetry Scripts: Fully practical MAVLink telemetry script.
Comment: I distinguish between drones and racers. As regards the communication link racers don’t need the same capabilities as drones do, in terms of bandwidth and bi-directionality, and the options available for racers can be considered sufficient. This is IMHO clearly not so for drones, and MAVLink is the protocol used by the de-facto standard open source drone projects PX4 and ArduPilot. And this is what this project is about.
The project is quite functional; the following videos give an impression of the state of affairs as of Feb. 2021:
Comment: In this video I’m saying that the frequent loss of telemetry connections are due to being indoors. This is wrong. I had upgraded the SiK radios to the latest firmware using MissionPlanner, which screwed it up. Flashing the proper SiK firmware resolved the issue. 🙂
This video demonstrates that it works in the „real world“, by means of a drone quick shot:
Links:
- Github repository with scripts and all the stuff you need: https://github.com/olliw42/otxtelemetry
- Github repository with firmware source: https://github.com/olliw42/opentx/branches
- PR in the OpenTx github repository: https://github.com/opentx/opentx/pull/7702
- Discussion thread at rcgroups: https://www.rcgroups.com/forums/showthread.php?3532969-MAVLink-for-OpenTx-and-Telemetry-Script
Third-Party Links:
- Risto’s documentations: https://github.com/rotorman/opentx/tree/mavtelem-dev/doc
- Risto’s post at rcgroups on the connection schemes using a TX16S and DragonLink: https://www.rcgroups.com/forums/showpost.php?p=46530167&postcount=87905
1. Concept
The idea to add MAVLink support to OpenTx is not new (see e.g. here, here). It also was extensively discussed ca 2 years ago here, and a first albeit very rudimentary implementation was pr’ed here, but both the discussion and the PR went stale long ago.
However, telemetry with sufficient data rate is obviously of great importance, especially for drones, and the currently available options to combine them with OpenTx-based transmitters are – as impressive works they are – little else than hacks and workarounds to get some basic functionality. The FrSky passthrough protocol is a good example. It needs special code on the flight controller, a special converter, the wiring is also not so nice, and the data rate is low. In comparison, MAVLink drone systems typically use full-duplex serial wireless links with baudrates of e.g. 57600 bps. Examples are the abundant 3DR telemetry units, Dragonlink and similar LRS units, wifi-based telemetry units, and so on.
So, hardware-wise, all it really should need for using the telemetry unit is to connect two Rx,Tx wires to the RC transmitter.
Anything else, like using additional modules to squeeze some of the data through the SPort pin, really does not make much sense to me. I know that this view is not shared by everyone, but to me this looks obvious. So I started this project, and arrived at the following concept:
A. Hardware
Obviously, I considered it a strict requirement that one should not need any additional hardware like converters, and accordingly rejected any potential solution which did not comply with this. The good news is, this is indeed achieved.
However, some transmitters do not provide suitable connections to the outside. In these cases one has to solder some wires to the transmitter’s main board, and depending on your soldering skills you may consider this very difficult or very simple. But this is really all this project needs hardware-wise at most. Notably, OpenTx transmitters are available which expose one or more UART ports to the user, such as the RadioMaster TX16S. These transmitters are perfect for the project.
Comment: I only own one OpenTx-based transmitter, a Jumper T16 Pro, and since I thus only can test myself for this transmitter I only can speak for it. However, it has been confirmed by users in the rcgroups thread that it also perfectly works with the RadioMaster TX16S and Jumper T18.
B. OpenTx with MAVLink Firmware
The OpenTx firmware additions I have created can be described by four layers:
MAVLink SDK: This is a higher-level interface to access the MAVLink functionality in Lua scripts, and is really the main driver. The idea here is to make it as simple and convenient as possible to write a telemetry script. For instance, the functionality provided by the well-known Yappu FrSky Telemetry script can be realized by calling some simple Lua functions, but of course much richer functionality such as camera and gimbal control or guided drone control is also possible. This set of functions is provided by the mavsdk module; that is, in the Lua script they are called as, e.g., mavsdk.getGpsLatLonDeg().
MAVLink API: This is a low-level interface to access the MAVLink functionality in Lua scripts. It provides full access, i.e., allows us to receive and send any MAVLink message, and thus allows us to implement the features not provided by the MAVLink SDK. This set of functions is provided by the mavapi module; that is, in the Lua script they are called as, e.g., mavapi.getMessage(mavapi.M_ATTITUDE).
MAVLink Router: This is another key functionality, as it allows us to connect several MAVLink devices, effectively forming a MAVLink network. So, besides the telemetry unit one also can connect e.g. a PC running MissionPlanner or a MAVLink-capable antenna tracker, without any further hardware hickups or modules. Both UARTs of the transmitter (AUX/UART3, AUX2/UART6) as well as the USB port are available for this.
FrSky Sensor Mimicry: The incoming MAVLink messages are – as far as reasonable – translated into corresponding FrSky sensors. That is, a sensor discovery will find a dozen or so of sensors, which can then be used exactly like any „real“ sensor. For instance, they can be put on the screen, but also can be used in scripts as normal. The idea here is to provide a most simple access to the data and to allow you using it in familiar ways – hopefully your favorite script will just work.
My code additions to OpenTX can be found in my OpenTx fork. I also have opened a corresponding PR in the OpenTx github repository, which however is dormant as it doesn’t appear to be worthwhile considering 🙂
Documentation
Rcgroups user Risto has created some great pdfs documenting the mavsdk Lua functions:
C. OlliW Telemetry Script
A further and important part of the project are practical Lua scripts. The cornerstone is the MAVLink Telemetry Script. On the one side, it re-implements familiar telemetry features, at least to some extend (and I want to acknowledge that the layout of this part is indeed much inspired by the Yappu FrSky Telemetry script!). However, it clearly also aims at adding new functionality such as gimbal and camera support, and other stuff.
2. Hardware
As indicated in the above, no additional hardware like converters and such is needed, but some hardware work needs to be done. What needs to be done is to get access to Rx & Tx capable pins.
Jumper T16, Jumper T18
For the Jumper T16 or T18 one has to solder three wires (Gnd, Rx, Tx) directly to the transmitter’s main board. Two options are possible, the UART3 pins or the UART6 pins (the UART6 pins are accessible on the unpopulated Bluetooth module). I have chosen the UART3 pins, but you may prefer those on the unpopulated Bluetooth module area.
RadioMaster TX16S
This transmitter exposes two UARTs on the bottom side. So, all you need to do here is to connect your telemetry link to one of them. Done.
The telemetry link also needs power, and what to do here really very much depends on which wireless link you are using. In my case (Jumper T16 and 3DR telemetry radio) I soldered two further wires to appropriate points on the transmitter main board and am using a Pololu switch regulator to get 5 V for the telemetry unit.
The following video shows what I did with my Jumper T16 Pro:
3. Firmware and Script Installation
A. Installing OlliW’s MAVLink OpenTx
The installation of the modified OpenTx firmware is simple.
The procedure is as follows:
- Download the latest firmware binary (openttx-xxx-2.x.x-XXX.bin) from the Github repository.
- Start OpenTx Companion.
- Switch off the transmitter.
- Connect the transmitter via USB to your PC.
- In OpenTx Companion search the menu „Read/write“ and select the option „Write Firmware to Radio“.
- Select the firmware binary by clicking the „Load…“ button.
- Hit the button „Write to Tx“.
- Be patient, the process can take few minutes.
I certainly hope that the code additions will eventually be merged to OpenTx, and that this chapter really becomes obsolete. However, that’s not in my hands or decision. We just can hope for the best 🙂
B. Installing OlliW Telemetry Script
Also the installation of the OlliW Telemetry Script is simple, and essentially works as for all the other scripts out there.
The procedure is as follows:
- Download the latest SD card content from the Github repository.
- Power on the transmitter.
- Connect the transmitter via USB to your PC.
- This – at least on Windows – will bring up an explorer showing the content of the SD card in your transmitter.
- Drag and drop the downloaded folders named „WIDGETS“ and „SOUNDS“ into the explorer showing the transmitter’s SD card content. This will copy the files to the transmitter’s SD card.
- Disconnect the transmitter from USB and switch it off.
- Power on the transmitter, and install the widget script according to the OpenTx manual.
C. Video Tutorial
The procedures are also described in this video: