A how-to guide with code samples on configuring and building your own custom QGroundControl application. We’ll be changing the UI based on a passcode that we supply to unlock different levels of access.
If you already have the required software installed, double-check that you have the correct versions. Then you may continue to the section titled ‘Configuring the Project.’
- Microsoft Visual Studio 2019
- Qt/Qt Creator
- Follow this link to download the last version of Visual Studio 2019:
a. https://my.visualstudio.com/Downloads?q=visual%20studio%202019&wt.mc_id=
o
msftvscom~older-downloads - Once downloaded, run the installer and check the box labeled, “Desktop development with C++”
- Finish installing by checking the Install box
- Follow this link, scroll down to the section titled “Looking for Qt binaries?” a. https://www.qt.io/download-open-source
- Click the button labeled “Download the Qt Online Installer”
- A page will show up with a green button labeled “Download”. Click it and the QT Online Installer will download
- After downloading, launch the installer
- Log in / Create an account for Qt
- Check the box claiming you are an individual
- Hit next until you reach the installation folder
- Check the box labeled “Custom Installation” and hit next
- Select the dropdown for Qt and check the box labeled “5.15.2”
- Finish installation by hitting next until it is complete
- Clone the QGroundControl repository found here: a. https://github.com/mavlink/qgroundcontrol
- Open Qt Creator
- Select “File” and then “Open File or Project...”
- Navigate to the repository
- Select the file “qgroundcontrol.pro”
- Select “Configure Project”
- In the terminal window navigate to the [QGroundControl Repository]/custom
- Update sub dependencies with this command: a. git submodule update --recursive
- Restart Qt Creator
- The project will now be able to build without any modifications
Any files that are mentioned from “the Github Repository” can be found above: The complete working code in in the “custom” directory
There are 3 access types; Basic, Expert, and Factory. In this post, the user will only be able to access the motor component set up page if their access type is labeled as “Expert” or “Factory”
- Create 4 new files under custom/src: a. AccessType.cpp b. AccessTypeConfig.cpp c. AccessType.h d. AccessTypeConfig.h
- For AccessType.cpp, copy “ AccessType.cpp ” from the Github Repository
- For AccessTypeConfig.cpp, copy “ AccessTypeConfig.cpp ” from the Github Repository
- For AccessType.h, copy “ AccessType.h ” from the Github Repository
- For AccessTypeConfig.h, copy “ AccessTypeConfig.h ” from the Github Repository
The custom plugins allow the user to have access types depending on the drone firmware. In this case, the firmware that will have a custom plugin is PX4-based
- Create 6 new files under custom/src (All these files - CustomCorePlugin are modified versions of their original counterparts found under src/FirmwarePlugin/PX4): a. CustomFirmwarePluginFactory.h b. CustomPX4FirmwarePlugin.h c. CustomCorePlugin.h d. CustomFirmwarePluginFactory.cc e. CustomPX4FirmwarePlugin.cc f. CustomCorePlugin.cc
- In CustomFirmwarePluginFactory.h, copy “ CustomFirmwarePluginFactory.h ” from the Github Repository
- In CustomCorePlugin.h, copy “ CustomCorePlugin.h ” from the Github Repository
- In CustomFirmwarePluginFactory.cc, copy “ CustomFirmwarePluginFactory.cc ” from the Github Repository
- In CustomPX4FirmwarePlugin.h, copy “ CustomPX4FirmwarePlugin.h ” from the Github Repository
- In CustomCorePlugin.cc, copy “ CustomCorePlugin.cc ” from the Github Repository
- In CustomPX4FirmwarePlugin.cc, copy “ CustomPX4FirmwarePlugin.cc ” from the Github Repository
This is how the logic is handled for setting and changing the user’s access types
- Create 2 new files under custom/src/PasscodeMenu: a. PascodeManager.h b. PasscodeManager.cc
- In PasscodeManager.h, copy “ PascodeManager.h ” from the Github Repository
- In PasscodeManager.cc, copy “ PasscodeManager.cc ” from the Github Repository
This is the project initialization file
- Open the custom.pri file
- Under SOURCES, add the following:
- Under HEADERS, add the following:
$ $PWD /src/AccessType.cpp \
$ $PWD /src/AccessTypeConfig.cpp \
$ $PWD /src/CustomFirmwarePluginFactory.cc \
$ $PWD /src/CustomPX4FirmwarePlugin.cc \
$ $PWD /src/CustomCorePlugin.cc \
$ $PWD /src/PasscodeMenu/PasscodeManager.cc
$ $PWD /src/AccessType.h \
$ $PWD /src/AccessTypeConfig.h \
$ $PWD /src/CustomFirmwarePluginFactory.h \
$ $PWD /src/CustomPX4FirmwarePlugin.h \
$ $PWD /src/CustomCorePlugin.h \
$ $PWD /src/PasscodeMenu/PasscodeManager.h
This will override the original Motor Component
- Under custom/res/Custom, create the file CustomMotorComponent.qml and copy “ CustomMotorComponent.qml ” from the Github Repository
- In custom/qgroundcontrol.exclusion, add this line:
< file alias= "MotorComponent.qml" > ../src/AutoPilotPlugins/Common/MotorComponent.qml </ file >
- In custom/custom.qrc, under the section with the prefix “qml”, add this line:
< file > CustomMotorComponent.qml </ file >
- In the terminal window navigate to the [QGroundControl Repository]/custom and run this command:
python updateqrc. py
This will be a new view inside the application setup page
- Under custom/res, create the file, PasswordSettings.qml and copy “ PasswordSettings.qml” from the Github Repository
- In custom/custom.qrc, under the section with the prefix “qml”, add this line:
< file alias= "PasswordSettings.qml" > res/PasswordSettings.qml </ file >