Develpment

Prerequisites

The development is done on Ubuntu 22.04 and Windows 10. The application will probably work on other platforms, but only those targets are supported.

  • Git
  • Python
  • A C++ 17 compiler for the platform
    • GCC for Linux
    • MSVC for Windows (installed with Visual Studio)
  • Qt for Open Source Development
    • Qt version 6.5
    • Qt Creator
    • Ubuntu only: Manually install XCB library: sudo apt install libxcb-cursor0
  • Optional, but recommended: Qt installs its own CMake, but you may need to install cmake-format manually, with pip install cmakelang or apt install cmake-format

Selected components in Qt Maintenance Tool

To conserve disk space you can select libraries actually used in the project, see the project's CMakeLists.txt, but it's possible in the future more will be used.

Downloading the source code

To use our own dialect, the project depends on a fork of MAVLink, included as a Git Submodule (which in turn has pymavlink inside).

Open the folder where you want to keep the project code, and open it in terminal. To clone the repository with its inner modules, add the --recursive flag:

git clone https://github.com/marsh-sim/marsh-manager.git --recursive
cd marsh-manager

Note

If you didn't get the submodules during clone, or they changed to a different commit, you can update them with: git submodule update --init --recursive

Building the project

After downloading the project for the first time, or after changes in the MAVLink dialect, the communication library needs to be regenerated. A virtual environment is recommended to avoid mixing packages installed here with system packages. The following commands can be used for Linux:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

For users on Windows, only the line to activate the virtual environment changes to:

./venv/Scripts/activate

With the environment activated and all prerequisites installed, run the generator script:

python scripts/update_mavlink.py

Qt application

Launch Qt Creator, click "Open Project..." on the left and open the CMakeLists.txt file in themarsh-manager directory.

When shown the Configure window, mark a kit that starts with "Desktop Qt 6.5" and click "Configure Project" in the bottom right corner.

The project can be compiled and optionally built using the buttons in the bottom left corner, or the "Build" menu on the top menu bar. This should rebuild all the necessary files, and optionally start the application and attach a debugger.

Note

The details of application version are generated by CMake based on last Git commit. You should fully run CMake after every commit. If you didn't change anything, run manually with: "Build" > "Run CMake"

Build buttons in the corner

The application can be built in different modes, a short explanation quoted from Stack Overflow:

Debug versions are usually slower, larger, and take up more RAM. They have debugging symbols, which make debugging possible and simpler. Release versions are stripped of all non-production information.

In debug builds variables and memory are generally set to zero but in release this step is skipped to save time. Extra data is also added around objects and allocated memory as barriers to detect memory overwrites.

In this specific project, building is noticeably faster for Debug builds. You can differentiate Debug build from Release by the window title, in which Debug builds also have the commit count on the end of version string after a + sign.

Screenshot of MARSH Manager window with visible version

Optional: Qt Creator configuration

Qt Creator includes Vim mode ("Edit" > "Preferences" > "FakeVim").

Formatting

To avoid "noisy diff" where changes are just formatting changes, it's recommended to enable format on save for all used kinds of source files:

  • In window "Edit" > "Preferences":
    • "C++" > "Code Style"
    • "Qt Quick" > "QML/JS Editing"
    • "CMake" > "Formatter"

Setting for C++

Setting for QML

Setting for CMake