QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCMAVLink.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QList>
4#include <QtCore/QObject>
5#include <QtCore/QString>
6#include <QtQmlIntegration/QtQmlIntegration>
7
8#include "MAVLinkEnums.h"
10#include "QGCMAVLinkTypes.h"
11
12class QGCMAVLink : public QObject, public QGCMAVLinkTypes
13{
14 Q_OBJECT
15 QML_NAMED_ELEMENT(MAVLink)
16 QML_SINGLETON
17
18public:
19 // Creating an instance of QGCMAVLink is only meant to be used for the Qml Singleton
20 QGCMAVLink(QObject *parent = nullptr);
22
23 // FirmwareClass_t, VehicleClass_t, VehicleClassGeneric, maxRcChannels inherited from QGCMAVLinkTypes
24
25 static constexpr const FirmwareClass_t FirmwareClassPX4 = MAV_AUTOPILOT_PX4;
26 static constexpr const FirmwareClass_t FirmwareClassArduPilot = MAV_AUTOPILOT_ARDUPILOTMEGA;
27 static constexpr const FirmwareClass_t FirmwareClassGeneric = MAV_AUTOPILOT_GENERIC;
28
29 static constexpr const VehicleClass_t VehicleClassAirship = MAV_TYPE_AIRSHIP;
30 static constexpr const VehicleClass_t VehicleClassFixedWing = MAV_TYPE_FIXED_WING;
31 static constexpr const VehicleClass_t VehicleClassRoverBoat = MAV_TYPE_GROUND_ROVER;
32 static constexpr const VehicleClass_t VehicleClassSub = MAV_TYPE_SUBMARINE;
33 static constexpr const VehicleClass_t VehicleClassSpacecraft = MAV_TYPE_SPACECRAFT_ORBITER;
34 static constexpr const VehicleClass_t VehicleClassMultiRotor = MAV_TYPE_QUADROTOR;
35 static constexpr const VehicleClass_t VehicleClassVTOL = MAV_TYPE_VTOL_TAILSITTER_QUADROTOR;
36 // VehicleClassGeneric inherited from QGCMAVLinkTypes
37 static_assert(QGCMAVLinkTypes::VehicleClassGeneric == MAV_TYPE_GENERIC, "VehicleClassGeneric value mismatch");
38
39 static bool isPX4FirmwareClass (MAV_AUTOPILOT autopilot) { return autopilot == MAV_AUTOPILOT_PX4; }
40 static bool isArduPilotFirmwareClass (MAV_AUTOPILOT autopilot) { return autopilot == MAV_AUTOPILOT_ARDUPILOTMEGA; }
41 static bool isGenericFirmwareClass (MAV_AUTOPILOT autopilot) { return !isPX4FirmwareClass(autopilot) && ! isArduPilotFirmwareClass(autopilot); }
42 static FirmwareClass_t firmwareClass (MAV_AUTOPILOT autopilot);
43 static MAV_AUTOPILOT firmwareClassToAutopilot (FirmwareClass_t firmwareClass) { return static_cast<MAV_AUTOPILOT>(firmwareClass); }
46 static MAV_AUTOPILOT firmwareTypeFromString (const QString &firmwareTypeStr);
47 static QList<FirmwareClass_t> allFirmwareClasses ();
48
49 static bool isAirship (MAV_TYPE mavType);
50 static bool isFixedWing (MAV_TYPE mavType);
51 static bool isRoverBoat (MAV_TYPE mavType);
52 static bool isSub (MAV_TYPE mavType);
53 static bool isSpacecraft (MAV_TYPE mavType);
54 static bool isMultiRotor (MAV_TYPE mavType);
55 static bool isVTOL (MAV_TYPE mavType);
56 static VehicleClass_t vehicleClass (MAV_TYPE mavType);
57 static MAV_TYPE vehicleClassToMavType (VehicleClass_t vehicleClass) { return static_cast<MAV_TYPE>(vehicleClass); }
61 static MAV_TYPE vehicleTypeFromString(const QString &vehicleStr);
62 static QList<VehicleClass_t> allVehicleClasses (void);
63
64 static QString mavResultToString (uint8_t result);
65 static QString mavResultToString (MAV_RESULT result) { return mavResultToString(static_cast<uint8_t>(result)); }
66 static QString mavSysStatusSensorToString (MAV_SYS_STATUS_SENSOR sysStatusSensor);
67 static QString mavTypeToString (MAV_TYPE mavType);
68 static QString firmwareVersionTypeToString (FIRMWARE_VERSION_TYPE firmwareVersionType);
69 static FIRMWARE_VERSION_TYPE firmwareVersionTypeFromString(const QString &typeStr);
70 static int motorCount (MAV_TYPE mavType, uint8_t frameType = 0);
72 static QString compIdToString (uint8_t compId);
73
90 Q_ENUM(CalibrationType)
91
93 typedef struct param_ext_union {
94 union {
95 float param_float;
96 double param_double;
97 int64_t param_int64;
98 uint64_t param_uint64;
99 int32_t param_int32;
100 uint32_t param_uint32;
101 int16_t param_int16;
102 uint16_t param_uint16;
103 int8_t param_int8;
104 uint8_t param_uint8;
106 };
107 uint8_t type;
108 }) param_ext_union_t;
109
110 static bool isValidChannel(uint8_t channel) { return (channel < MAVLINK_COMM_NUM_BUFFERS); }
111 static bool isValidChannel(mavlink_channel_t channel) { return isValidChannel(static_cast<uint8_t>(channel)); }
112
113 static mavlink_status_t* getChannelStatus(mavlink_channel_t channel) { return mavlink_get_channel_status(static_cast<uint8_t>(channel)); }
114
115 static const QHash<int, QString> mavlinkCompIdHash;
116};
mavlink_channel_t
mavlink_status_t * mavlink_get_channel_status(uint8_t chan)
Definition QGCMAVLink.cc:53
#define MAVLINK_COMM_NUM_BUFFERS
#define MAVLINK_MSG_PARAM_EXT_SET_FIELD_PARAM_VALUE_LEN
struct __mavlink_high_latency2_t mavlink_high_latency2_t
static constexpr VehicleClass_t VehicleClassGeneric