How to integrate your custom code into DroneBridge images
Since DroneBridge v0.6 plugins are supported. With plugins, the user can easily add own custom scripts to his default DroneBridge image that will execute on startup of the ground station or UAV. Every UAV project is different and every user has its own ideas and plans for his drone. To account for those needs users will want to add custom programmes and functionalities to DroneBridge. With the plugin system of DroneBridge people can add their own software without having to edit the base image. As soon as a new DroneBridge release comes out all you have to do is reinstall your plugins and you are ready to go. No need to merge your custom programmes into the newly released base image.
Examples of plugins are: Trigger actions with your RC hardware switches using DroneBridge RC, custom telemetry parsers, Raspberry Pi PWM output for fan control, ...
Use plugins if you need features that only you or a small group of people will benefit from. If your desired feature is useful for a big part of the community feel free to open an issue/feature request or directly provide code via a pull request.
To install a plugin just download the corresponding
*.zipfile and extract its contents to your
/DroneBridge/plugins/directory. If you are using Windows you can find the folder in the root folder of the mounted DroneBridge partition. It is the one that appears in the explorer when you insert your SD card into the computer.
It is very easy to develop and include your own scripts/modules/programs for DroneBridge. Just follow the steps below.
The main folder should have the same name as your plugin. Inside that folder put a README.md and
settings.iniwill be read on startup by the DroneBridge plugin module. The file contains the commands to execute on either ground station or UAV to start the plugin. See further down for detailed information.
settings.inicontains the following information:
- Name of the plugin
- Version of the plugin
- Start command to run on ground station
- Start command to run on UAV
Important: All of the fields below must exist. They need to be set.
license="Apache License 2.0"
startup_comm="python3 your_script.py -ground"
startup_comm="python3 your_script.py -uav"
Variable types All values must be Strings except the version. Version must be an Integer.
The startup_comm is executed via python:
subprocess.Popen(startup_comm, shell='True'). Make sure you escape your startup_comm if necessary. Any kind of script/program can be executed.
UAV: Currently, there is no (fast/simple) way of accessing the telemetry stream on the UAV. You would need to connect to an additional serial port of you FC and get telemetry via that one. Alternatively you can open a raw socket that listens for packets with destination DroneBridge telemetry port (port:
0x02- or any other port/packet format in case you want different information). You can use the DroneBridge libs to do that (untested). The Linux Kernel and raw sockets allow you to monitor not just the received packets of the wifi adapters, but also all outgoing packets
Ground station: Use the DroneBridge C or Python lib to open a new socket that listens for packets with destination DroneBridge telemetry port (port:
0x02). That way you are sort of creating your own DB-Module. You can have multiple sockets listening for the same DB raw-packets.
UAV: Use the C-lib to open the shared memory segment for the RC values. Before the RC values get sent to the AirPi and before they are written to the flight controller, the control module copies them to the shared memory. That way other applications can read the current channel values sent via DroneBridge RC.
Ground station: same as with UAV
One can always open their own raw socket (using DroneBridge lib or custom code) to listen for all kinds of packets sent or received via the wifi adapters. That way all data that is transported can be accessed. However, you will need to do most of the parsing/data processing yourself.