The Mission Planner Plugin System provides a powerful mechanism to extend the functionality of the Ground Control Station (GCS) without modifying the core codebase. It allows for runtime compilation of C# scripts, dynamic UI injection, and deep access to vehicle state and communication streams.
The architecture is built around a decoupled model where plugins are discovered as source files or compiled DLLs, loaded into memory, and executed within a managed lifecycle. The core of this system resides in the MissionPlanner.Plugin namespace.
| Component | Description |
|---|---|
Plugin | The abstract base class that all plugins must inherit from. Plugin/Plugin.cs21 |
PluginLoader | Responsible for scanning directories, compiling .cs files via Roslyn, and managing the active plugin list. Plugin/PluginLoader.cs18-19 |
PluginHost | The concrete implementation of the interface through which plugins interact with the main application, providing access to MainV2, MAVLink interfaces, and map controls. Plugin/PluginLoader.cs172 |
CodeGenRoslyn | A utility class using Microsoft.CodeAnalysis.CSharp to compile plugin source code into IL at runtime, including MD5-based assembly caching. ExtLibs/Utilities/CodeGen.cs19-20 |
This diagram maps the natural language concept of "Loading a Plugin" to the specific classes and methods in the codebase.
Sources: Plugin/PluginLoader.cs39-45 Plugin/PluginLoader.cs99-139 ExtLibs/Utilities/CodeGen.cs25-53 Plugin/PluginLoader.cs172-175
Plugins follow a strict lifecycle managed by PluginLoader. This ensures that plugins are initialized correctly and cleaned up during application shutdown.
Sources: Plugin/Plugin.cs21-50 Plugin/PluginLoader.cs166-175 Plugin/PluginLoader.cs144-182
Init(): Called immediately after instantiation. Used for internal variable setup. Returning false aborts loading. Plugin/Plugin.cs52Loaded(): Called once the plugin is fully integrated. This is the ideal place to add menu items to Host.FDMenuMap. Plugin/Plugin.cs54Loop(): Executed periodically based on loopratehz. Plugin/Plugin.cs58Exit(): Called when Mission Planner closes or the plugin is disabled. Must be used to remove UI elements and stop background threads. Plugin/Plugin.cs47Plugins are written in C# and placed in the plugins/ folder. They can be provided as raw .cs files for runtime compilation or as pre-compiled .dll files.
Plugins interact with the vehicle via the MAVLinkInterface provided by the Host. They can also inject tabs into the Flight Data view.
Sources: plugins/example8-modechange.cs60-61 Plugins/OpenDroneID2/OpenDroneID_Plugin.cs45-55
The PluginHost allows plugins to inject themselves into map context menus or the main form.
Sources: plugins/Dowding/DowdingPlugin.cs104-114 plugins/Dowding/DowdingPlugin.cs130-140
Mission Planner uses Microsoft.CodeAnalysis.CSharp (Roslyn) to compile plugins. This allows users to modify plugin logic without needing a full IDE.
CodeGenRoslyn generates an MD5 hash of the source file. If a matching .dll and .pdb exist in the plugins/ cache directory, it loads the cached version to speed up startup. ExtLibs/Utilities/CodeGen.cs35-52AppDomain.CurrentDomain.GetAssemblies(), ensuring plugins have access to MissionPlanner.Drawing, System.Windows.Forms, and other core libraries. ExtLibs/Utilities/CodeGen.cs58-76//loadassembly: Name to force the loading of specific dependencies. plugins/example.cs11The codebase includes several functional examples in the plugins/ directory:
| File | Purpose |
|---|---|
example8-modechange.cs | Logic to trigger actions and UI updates when the vehicle flight mode changes. plugins/example8-modechange.cs15 |
DowdingPlugin.cs | A complex plugin implementing a tracking system with WebSocket communication and map overlays. plugins/Dowding/DowdingPlugin.cs21 |
OpenDroneID_Plugin.cs | Implements Remote ID support, injecting a dedicated "Drone ID" tab into the Flight Data view. Plugins/OpenDroneID2/OpenDroneID_Plugin.cs9 |
generator.cs | Demonstrates a plugin with a custom UserControl UI for generator status monitoring. plugins/generator.cs10 |
Sources: plugins/example8-modechange.cs plugins/Dowding/DowdingPlugin.cs Plugins/OpenDroneID2/OpenDroneID_Plugin.cs plugins/generator.cs