How to call sendCommand from qml

Hi,

So I am trying to modify QGC on my Herelink to have some on screen buttons to control a Flir Duo Pro R camera, because I don’t have enough hardware buttons.
I have managed to create the UI as widget, but am stuck on how to send a Mavlink command to the vehicle. Here is what I have so far:

import QtQuick 2.4
import QtPositioning 5.2
import QtQuick.Layouts 1.2
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0

import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Vehicle 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0

/// Flir page for controlling a Duo Pro R
Column {
    width: pageWidth
    spacing: ScreenTools.defaultFontPixelHeight * 0.25
   
    property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle

    GridLayout {
        columns: 2
        columnSpacing: ScreenTools.defaultFontPixelWidth * 2
        rowSpacing: ScreenTools.defaultFontPixelHeight
        anchors.horizontalCenter: parent.horizontalCenter

        QGCLabel {
            text: qsTr("Camera Mode")
        }
        QGCComboBox {
            model: ["IR", "RGB", "PIP"]
            onActivated: {

                //move servo via MAVLINK
            }
        }

        QGCLabel {
            text: qsTr("Photo/Video")
        }
        QGCSwitch {
            id: videoMode
            onCheckedChanged: {
                if (checked) {

                    //move servo
                } else {

                    //move servo the other way
                }
            }
        }

        QGCLabel {
            text: qsTr("REC")
        }
        QGCButton {
            text: "Test"
            onClicked: QGroundControl.vehicle.sendCommand(_activeVehicle,   //Component to send to
                                                          183,              //MAV_CMD to send 183:MAV_CMD_DO_SET_SERVO
                                                          true,             //showError
                                                          11,               //servo instance
                                                          1500)             //servo value in us
        }
    }
}

How can I send a mavlink command to the current active vehicle from qml? I found the function “Q_INVOKABLE void sendCommand(…)” in Vehicle.h but don’t know how to call it. I get the error “TypeError: Cannot call method ‘sendCommand’ of undefined” in the QGC console. Can anyone help me out?

@AltitudeDavid,
You need to call sendCommand method on _activeVehicle variable.

onClicked:
    _activeVehicle.sendCommand(...)
2 Likes

Thanks, works perfectly!

Hello
I have the same Problem,

1-can you tell me in wish file in QGroundControl source github code you add this qml script? and can send to me the last version code?

2- and after adding, should I add another think in other files?

Thank you very much for repliying.

Hi,

Check the code here: GitHub - Hasi123/qgroundcontrol-herelink
Have not modified it since then.

Hello,
I encountered an error while running the QGC code. This is my first experience with QT Android development applications.
((((((((((((((((
02:17:07: Exécution des étapes pour le projet qgroundcontrol…
02:17:07: Débute : “C:\Qt\5.15.2\android\bin\qmake.exe” C:\Users\elied\Bureau\qgc\qgroundcontrol\qgroundcontrol.pro -spec android-clang “CONFIG+=debug” “CONFIG+=qml_debug” ANDROID_ABIS=“armeabi-v7a arm64-v8a”
Project MESSAGE: Qt version 5.15.2
Project MESSAGE: Android Arm 64 bit build
Project MESSAGE: Daily Build
Project MESSAGE: GIT_DESCRIBE
Project MESSAGE: QGroundControl APP_VERSION_STR VERSION vUnknown 0.0.0
Project MESSAGE: VERSION 0.0.0
Project MESSAGE: Android version info: 660000000 bitness:66 major:0 minor:0 patch:00 dev:000
Project MESSAGE: Debug flavor
Project MESSAGE: Skipping support for Pairing
Project MESSAGE: Using MAVLink dialect ‘ardupilotmega’.
Project MESSAGE: ANDROID_EXTRA_LIBS
Project MESSAGE: arm64-v8a
Project MESSAGE: C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm/libssl_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm64/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm64/libssl_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86/libssl_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86_64/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86_64/libssl_1_1.so
Project MESSAGE: Skipping support for Zeroconf (unsupported platform)
Project MESSAGE: Including support for AirMap
Project MESSAGE: Taisync disabled
Project MESSAGE: Microhard disabled
Project MESSAGE: Skipping support for video streaming (GStreamer libraries not installed)
Project MESSAGE: Installation instructions here: qgroundcontrol/src/VideoReceiver/README.md at aa0f2c61b2c0dbf1913f1f8186312811ca7dbdeb · mavlink/qgroundcontrol · GitHub
Project MESSAGE: Adding Serial Java Classes
Project MESSAGE: This project is using private headers and will therefore be tied to this specific Qt module build version.
Project MESSAGE: Running this project against other versions of the Qt modules may crash at any arbitrary point.
Project MESSAGE: This is not a bug, but a result of using Qt internals. You have been warned!
Project MESSAGE: Qt version 5.15.2
Project MESSAGE: Android Arm 32 bit build
Project MESSAGE: Daily Build
Project MESSAGE: GIT_DESCRIBE
Project MESSAGE: QGroundControl APP_VERSION_STR VERSION vUnknown 0.0.0
Project MESSAGE: VERSION 0.0.0
Project MESSAGE: Android version info: 340000000 bitness:34 major:0 minor:0 patch:00 dev:000
Project MESSAGE: Debug flavor
Project MESSAGE: Skipping support for Pairing
Project MESSAGE: Using MAVLink dialect ‘ardupilotmega’.
Project MESSAGE: ANDROID_EXTRA_LIBS
Project MESSAGE: armeabi-v7a
Project MESSAGE: C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm/libssl_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm64/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm64/libssl_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86/libssl_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86_64/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86_64/libssl_1_1.so
Project MESSAGE: Skipping support for Zeroconf (unsupported platform)
Project MESSAGE: Including support for AirMap
Project MESSAGE: Taisync disabled
Project MESSAGE: Microhard disabled
Project MESSAGE: Skipping support for video streaming (GStreamer libraries not installed)
Project MESSAGE: Installation instructions here: qgroundcontrol/src/VideoReceiver/README.md at aa0f2c61b2c0dbf1913f1f8186312811ca7dbdeb · mavlink/qgroundcontrol · GitHub
Project MESSAGE: Adding Serial Java Classes
Project MESSAGE: Qt version 5.15.2
Project MESSAGE: Android Arm 64 bit build
Project MESSAGE: Daily Build
Project MESSAGE: GIT_DESCRIBE
Project MESSAGE: QGroundControl APP_VERSION_STR VERSION vUnknown 0.0.0
Project MESSAGE: VERSION 0.0.0
Project MESSAGE: Android version info: 660000000 bitness:66 major:0 minor:0 patch:00 dev:000
Project MESSAGE: Debug flavor
Project MESSAGE: Skipping support for Pairing
Project MESSAGE: Using MAVLink dialect ‘ardupilotmega’.
Project MESSAGE: ANDROID_EXTRA_LIBS
Project MESSAGE: arm64-v8a
Project MESSAGE: C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm/libssl_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm64/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/arm64/libssl_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86/libssl_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86_64/libcrypto_1_1.so C:/Users/elied/Bureau/qgc/qgroundcontrol/libs/OpenSSL/android_openssl/no-asm/latest/x86_64/libssl_1_1.so
Project MESSAGE: Skipping support for Zeroconf (unsupported platform)
Project MESSAGE: Including support for AirMap
Project MESSAGE: Taisync disabled
Project MESSAGE: Microhard disabled
Project MESSAGE: Skipping support for video streaming (GStreamer libraries not installed)
Project MESSAGE: Installation instructions here: qgroundcontrol/src/VideoReceiver/README.md at aa0f2c61b2c0dbf1913f1f8186312811ca7dbdeb · mavlink/qgroundcontrol · GitHub
Project MESSAGE: Adding Serial Java Classes
02:17:23: The process “C:\Qt\5.15.2\android\bin\qmake.exe” exited normally.
02:17:23: Débute : “C:\Users\elied\AppData\Local\Android\Sdk\ndk\19_2_5345600\prebuilt\windows-x86_64\bin\make.exe” -f C:/Users/elied/Bureau/qgc/build-qgroundcontrol-Android_Qt_5_15_2_Clang_Multi_Abi-Debug/Makefile qmake_all
make: Nothing to be done for qmake_all'. 02:17:23: The process "C:\Users\elied\AppData\Local\Android\Sdk\ndk\19_2_5345600\prebuilt\windows-x86_64\bin\make.exe" exited normally. 02:17:23: Débute : "C:\Users\elied\AppData\Local\Android\Sdk\ndk\19_2_5345600\prebuilt\windows-x86_64\bin\make.exe" -j4 C:/Users/elied/AppData/Local/Android/Sdk/ndk/19_2_5345600/prebuilt/windows-x86_64/bin/make -f Makefile.Armeabi-v7a all C:/Users/elied/AppData/Local/Android/Sdk/ndk/19_2_5345600/prebuilt/windows-x86_64/bin/make -f Makefile.Arm64-v8a all make[1]: Entering directory C:/Users/elied/Bureau/qgc/build-qgroundcontrol-Android_Qt_5_15_2_Clang_Multi_Abi-Debug’
make[1]: Entering directory C:/Users/elied/Bureau/qgc/build-qgroundcontrol-Android_Qt_5_15_2_Clang_Multi_Abi-Debug' rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\qgroundcontrol.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\qgroundcontrol.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\qgcresources.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\qgcresources.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\qgcimages.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\qgcimages.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\resources\InstrumentValueIcons\InstrumentValueIcons.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\resources\InstrumentValueIcons\InstrumentValueIcons.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\UnitTest.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\UnitTest.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\src\FirmwarePlugin\APM\APMResources.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\src\FirmwarePlugin\APM\APMResources.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\src\FirmwarePlugin\PX4\PX4Resources.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\src\FirmwarePlugin\PX4\PX4Resources.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\src\Airmap\dummy\airmap_dummy.qrc rcc C:\Users\elied\Bureau\qgc\qgroundcontrol\src\Airmap\dummy\airmap_dummy.qrc rcc armeabi-v7a\qmake_qmake_qm_files.qrc rcc arm64-v8a\qmake_qmake_qm_files.qrc RCC: Error in 'armeabi-v7a\qmake_qmake_qm_files.qrc': Cannot find file 'C:/Users/elied/Bureau/qgc/build-qgroundcontrol-Android_Qt_5_15_2_Clang_Multi_Abi-Debug/armeabi-v7a/qgc_az_AZ.qm' make[1]: *** [armeabi-v7a\qrc_qmake_qmake_qm_files.obj] Error 1 make[1]: Leaving directory C:/Users/elied/Bureau/qgc/build-qgroundcontrol-Android_Qt_5_15_2_Clang_Multi_Abi-Debug’
make: *** [armeabi-v7a-all] Error 2
make: *** Waiting for unfinished jobs…
RCC: Error in ‘arm64-v8a\qmake_qmake_qm_files.qrc’: Cannot find file ‘C:/Users/elied/Bureau/qgc/build-qgroundcontrol-Android_Qt_5_15_2_Clang_Multi_Abi-Debug/arm64-v8a/qgc_az_AZ.qm’
make[1]: *** [arm64-v8a\qrc_qmake_qmake_qm_files.obj] Error 1
make[1]: Leaving directory `C:/Users/elied/Bureau/qgc/build-qgroundcontrol-Android_Qt_5_15_2_Clang_Multi_Abi-Debug’
make: *** [arm64-v8a-all] Error 2
02:17:28: Le processus “C:\Users\elied\AppData\Local\Android\Sdk\ndk\19_2_5345600\prebuilt\windows-x86_64\bin\make.exe” s’est terminé avec le code 2.
Erreur lors de la compilation/déploiement du projet qgroundcontrol (kit : Android Qt 5.15.2 Clang Multi-Abi)
When executing step “Make”
02:17:28: Elapsed time: 00:21.
))))))))))))))))

Any help pleqse?

@AltitudeDavid
great info !! What is the version of the QGC on that Github link

Not sure, 3.6 or 4.0. Quite an old one, but CubePilot also hasn´t updated it in their GitHub repo.

thank you for the feedback. What is the issue in updating the QGC on Herelink…Are there no developers to assist

No idea, ask CubePilot on GitHub. I forked my repo from there

1 Like