Generated Vehicle Config Pages
This page explains how the Vehicle Setup pages (Power, Safety, etc.) are generated from JSON definitions and how to extend them.
For the complete JSON schema reference see tools/generators/config_qml/README.md.
Architecture Overview
The generation pipeline is:
- JSON page definitions in
src/AutoPilotPlugins/{APM,PX4}/VehicleConfig/*.VehicleConfig.json - Python generator in
tools/generators/config_qml/page_generator.py - Generated QML in
build/src/AutoPilotPlugins/{APM,PX4}/generated/ - C++ component class (e.g.
APMPowerComponent) loads the generated QML viasetupSource()
At build time, CMake runs the generator for each firmware plugin and places generated QML files in the build tree. Those files are compiled into the corresponding QGroundControl.AutoPilotPlugins.* QML module.
Where Generation Is Wired
Generation is configured in each firmware plugin's CMakeLists.txt:
src/AutoPilotPlugins/APM/CMakeLists.txt— targetGenerateConfigQmlAPMsrc/AutoPilotPlugins/PX4/CMakeLists.txt— targetGenerateConfigQmlPX4
Each runs:
bash
python -m tools.generators.config_qml.generate_pages \
--pages-dir <pages_dir> \
--output-dir <build_gen_dir>The generator entry point is tools/generators/config_qml/generate_pages.py, with most logic in tools/generators/config_qml/page_generator.py.
Base Class: VehicleComponent
VehicleComponent (in src/AutoPilotPlugins/VehicleComponent.h) provides the C++ side for generated pages. It reads the same JSON file at runtime to:
- Build the sidebar section list (including expanded repeat sections)
- Dynamically filter disabled repeat instances from the sidebar
- Connect signals so the sidebar updates when enable parameters change
Subclasses only need to implement vehicleConfigJson() to return the path to the JSON file and setupSource() to return the generated QML URL.
Adding a New Generated Setup Page
Create a new JSON file in the appropriate
VehicleConfig/directory:src/AutoPilotPlugins/APM/VehicleConfig/MyFeature.VehicleConfig.jsonSee tools/generators/config_qml/README.md for the full JSON schema.
Create a minimal C++ component class inheriting
VehicleComponent:- Implement
vehicleConfigJson()to return the JSON path - Implement
setupSource()to return the generated QML URL
- Implement
Register the component in the firmware plugin's
AutoPilotPluginsubclass.Add the generated QML filename to
_config_generated_qml_namesin the plugin'sCMakeLists.txt.Build. CMake will regenerate the QML automatically:
bashcmake --build build --config Debug --target GenerateConfigQmlAPM # or GenerateConfigQmlPX4
Important Notes
- The
constants,params, andbindingssections should appear beforesectionsin the JSON file for readability, since sections reference them. - Constants should use native JSON numbers, not strings (e.g.
0not"0"). - The
_config_generated_qml_nameslist in CMake is explicit. If you forget to add a new page output file, integration will be incomplete. - Inside repeat sections, use parameter postfixes in
paramfields and_fullParamName()inshowWhenexpressions. - The
enableParam/disabledParamValuepair is required together — you cannot specify one without the other.