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 <span>
4
5#include <QtCore/QList>
6#include <QtCore/QObject>
7#include <QtCore/QString>
8#include <QtQmlIntegration/QtQmlIntegration>
10#include "MAVLinkEnums.h"
11#include "MAVLinkMessageType.h"
12#include "QGCMAVLinkTypes.h"
13
14class QGCMAVLink : public QObject, public QGCMAVLinkTypes
15{
16 Q_OBJECT
17 QML_NAMED_ELEMENT(MAVLink)
18 QML_SINGLETON
19
20public:
21 // Creating an instance of QGCMAVLink is only meant to be used for the Qml Singleton
22 QGCMAVLink(QObject *parent = nullptr);
24
25 // FirmwareClass_t, VehicleClass_t, VehicleClassGeneric, maxRcChannels inherited from QGCMAVLinkTypes
26
27 static constexpr const FirmwareClass_t FirmwareClassPX4 = MAV_AUTOPILOT_PX4;
28 static constexpr const FirmwareClass_t FirmwareClassArduPilot = MAV_AUTOPILOT_ARDUPILOTMEGA;
29 static constexpr const FirmwareClass_t FirmwareClassGeneric = MAV_AUTOPILOT_GENERIC;
30
31 static constexpr const VehicleClass_t VehicleClassAirship = MAV_TYPE_AIRSHIP;
32 static constexpr const VehicleClass_t VehicleClassFixedWing = MAV_TYPE_FIXED_WING;
33 static constexpr const VehicleClass_t VehicleClassRoverBoat = MAV_TYPE_GROUND_ROVER;
34 static constexpr const VehicleClass_t VehicleClassSub = MAV_TYPE_SUBMARINE;
35 static constexpr const VehicleClass_t VehicleClassSpacecraft = MAV_TYPE_SPACECRAFT_ORBITER;
36 static constexpr const VehicleClass_t VehicleClassMultiRotor = MAV_TYPE_QUADROTOR;
37 static constexpr const VehicleClass_t VehicleClassVTOL = MAV_TYPE_VTOL_TAILSITTER_QUADROTOR;
38 // VehicleClassGeneric inherited from QGCMAVLinkTypes
39 static_assert(QGCMAVLinkTypes::VehicleClassGeneric == MAV_TYPE_GENERIC, "VehicleClassGeneric value mismatch");
40
41 static bool isPX4FirmwareClass (MAV_AUTOPILOT autopilot) { return autopilot == MAV_AUTOPILOT_PX4; }
42 static bool isArduPilotFirmwareClass (MAV_AUTOPILOT autopilot) { return autopilot == MAV_AUTOPILOT_ARDUPILOTMEGA; }
43 static bool isGenericFirmwareClass (MAV_AUTOPILOT autopilot) { return !isPX4FirmwareClass(autopilot) && ! isArduPilotFirmwareClass(autopilot); }
44 static FirmwareClass_t firmwareClass (MAV_AUTOPILOT autopilot);
45 static MAV_AUTOPILOT firmwareClassToAutopilot (FirmwareClass_t firmwareClass) { return static_cast<MAV_AUTOPILOT>(firmwareClass); }
48 static MAV_AUTOPILOT firmwareTypeFromString (const QString &firmwareTypeStr);
49 static QList<FirmwareClass_t> allFirmwareClasses ();
50
51 static bool isAirship (MAV_TYPE mavType);
52 static bool isFixedWing (MAV_TYPE mavType);
53 static bool isRoverBoat (MAV_TYPE mavType);
54 static bool isSub (MAV_TYPE mavType);
55 static bool isSpacecraft (MAV_TYPE mavType);
56 static bool isMultiRotor (MAV_TYPE mavType);
57 static bool isVTOL (MAV_TYPE mavType);
58 static VehicleClass_t vehicleClass (MAV_TYPE mavType);
59 static MAV_TYPE vehicleClassToMavType (VehicleClass_t vehicleClass) { return static_cast<MAV_TYPE>(vehicleClass); }
63 static MAV_TYPE vehicleTypeFromString(const QString &vehicleStr);
64 static QList<VehicleClass_t> allVehicleClasses (void);
65
66 static QString mavResultToString (uint8_t result);
67 static QString mavResultToString (MAV_RESULT result) { return mavResultToString(static_cast<uint8_t>(result)); }
68 static QString mavSysStatusSensorToString (MAV_SYS_STATUS_SENSOR sysStatusSensor);
69 static QString mavTypeToString (MAV_TYPE mavType);
70 static QString firmwareVersionTypeToString (FIRMWARE_VERSION_TYPE firmwareVersionType);
71 static FIRMWARE_VERSION_TYPE firmwareVersionTypeFromString(const QString &typeStr);
72 static int motorCount (MAV_TYPE mavType, uint8_t frameType = 0);
74 static QString compIdToString (uint8_t compId);
75
77 static QString boundedStringField(std::span<const char> raw);
78 static QString boundedStringField(std::span<const uint8_t> raw);
79
96 Q_ENUM(CalibrationType)
97
99 typedef struct param_ext_union {
100 union {
101 float param_float;
102 double param_double;
103 int64_t param_int64;
104 uint64_t param_uint64;
105 int32_t param_int32;
106 uint32_t param_uint32;
107 int16_t param_int16;
108 uint16_t param_uint16;
109 int8_t param_int8;
110 uint8_t param_uint8;
112 };
113 uint8_t type;
114 }) param_ext_union_t;
115
116 static bool isValidChannel(uint8_t channel) { return (channel < MAVLINK_COMM_NUM_BUFFERS); }
117 static bool isValidChannel(mavlink_channel_t channel) { return isValidChannel(static_cast<uint8_t>(channel)); }
118
119 static mavlink_status_t* getChannelStatus(mavlink_channel_t channel) { return mavlink_get_channel_status(static_cast<uint8_t>(channel)); }
120
121 static const QHash<int, QString> mavlinkCompIdHash;
122};
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