From 0fa19b5ddf90d83ce4120cde5e3bb370b1ba21df Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 10 May 2024 06:14:44 -0400 Subject: [PATCH] Vehicle: Move Generic Code to MAVLink Module --- .../APM/APMSensorsComponent.qml | 5 +- .../APM/APMSensorsComponentController.cc | 48 ++-- .../APM/APMSensorsComponentController.h | 18 +- .../Common/RadioComponentController.cc | 4 +- .../PX4/PowerComponentController.cc | 2 +- .../PX4/SensorsComponentController.cc | 10 +- src/MAVLink/ImageProtocolManager.h | 2 +- src/MAVLink/MAVLinkFTP.h | 3 + src/MAVLink/MAVLinkStreamConfig.h | 3 + src/MAVLink/QGCMAVLink.cc | 142 +++++++++++ src/MAVLink/QGCMAVLink.h | 66 +++++ src/MAVLink/SysStatusSensorInfo.h | 3 + src/Vehicle/Vehicle.cc | 228 +++--------------- src/Vehicle/Vehicle.h | 62 +---- 14 files changed, 290 insertions(+), 306 deletions(-) diff --git a/src/AutoPilotPlugins/APM/APMSensorsComponent.qml b/src/AutoPilotPlugins/APM/APMSensorsComponent.qml index 3e054227f57..6335ab371ee 100644 --- a/src/AutoPilotPlugins/APM/APMSensorsComponent.qml +++ b/src/AutoPilotPlugins/APM/APMSensorsComponent.qml @@ -22,6 +22,7 @@ import QGroundControl.ScreenTools import QGroundControl.Controllers import QGroundControl.ArduPilot import QGroundControl.QGCPositionManager +import MAVLink SetupPage { id: sensorsPage @@ -166,8 +167,8 @@ SetupPage { onCalibrationComplete: { switch (calType) { - case APMSensorsComponentController.CalTypeAccel: - case APMSensorsComponentController.CalTypeOnboardCompass: + case MAVLink.CalibrationAccel: + case MAVLink.CalibrationMag: _singleCompassSettingsComponentShowPriority = true postOnboardCompassCalibrationComponent.createObject(mainWindow).open() break diff --git a/src/AutoPilotPlugins/APM/APMSensorsComponentController.cc b/src/AutoPilotPlugins/APM/APMSensorsComponentController.cc index dca25624fc1..5652c3c1f49 100644 --- a/src/AutoPilotPlugins/APM/APMSensorsComponentController.cc +++ b/src/AutoPilotPlugins/APM/APMSensorsComponentController.cc @@ -32,7 +32,7 @@ APMSensorsComponentController::APMSensorsComponentController(void) , _nextButton(nullptr) , _cancelButton(nullptr) , _showOrientationCalArea(false) - , _calTypeInProgress(CalTypeNone) + , _calTypeInProgress(QGCMAVLink::CalibrationNone) , _orientationCalDownSideDone(false) , _orientationCalUpsideDownSideDone(false) , _orientationCalLeftSideDone(false) @@ -101,10 +101,10 @@ void APMSensorsComponentController::_startLogCalibration(void) connect(_vehicle, &Vehicle::textMessageReceived, this, &APMSensorsComponentController::_handleUASTextMessage); emit setAllCalButtonsEnabled(false); - if (_calTypeInProgress == CalTypeAccel || _calTypeInProgress == CalTypeCompassMot) { + if (_calTypeInProgress == QGCMAVLink::CalibrationAccel || _calTypeInProgress == QGCMAVLink::CalibrationAPMCompassMot) { _nextButton->setEnabled(true); } - _cancelButton->setEnabled(_calTypeInProgress == CalTypeOnboardCompass); + _cancelButton->setEnabled(_calTypeInProgress == QGCMAVLink::CalibrationMag); connect(qgcApp()->toolbox()->mavlinkProtocol(), &MAVLinkProtocol::messageReceived, this, &APMSensorsComponentController::_mavlinkMessageReceived); } @@ -159,7 +159,7 @@ void APMSensorsComponentController::_stopCalibration(APMSensorsComponentControll _nextButton->setEnabled(false); _cancelButton->setEnabled(false); - if (_calTypeInProgress == CalTypeOnboardCompass) { + if (_calTypeInProgress == QGCMAVLink::CalibrationMag) { _restorePreviousCompassCalFitness(); } @@ -201,7 +201,7 @@ void APMSensorsComponentController::_stopCalibration(APMSensorsComponentControll break; } - _calTypeInProgress = CalTypeNone; + _calTypeInProgress = QGCMAVLink::CalibrationNone; } void APMSensorsComponentController::_mavCommandResult(int vehicleId, int component, int command, int result, bool noReponseFromVehicle) @@ -217,7 +217,7 @@ void APMSensorsComponentController::_mavCommandResult(int vehicleId, int compone disconnect(_vehicle, &Vehicle::mavCommandResult, this, &APMSensorsComponentController::_mavCommandResult); if (result == MAV_RESULT_ACCEPTED) { // Onboard mag cal is supported - _calTypeInProgress = CalTypeOnboardCompass; + _calTypeInProgress = QGCMAVLink::CalibrationMag; _rgCompassCalProgress[0] = 0; _rgCompassCalProgress[1] = 0; _rgCompassCalProgress[2] = 0; @@ -305,11 +305,11 @@ void APMSensorsComponentController::calibrateCompassNorth(float lat, float lon, void APMSensorsComponentController::calibrateAccel(bool doSimpleAccelCal) { - _calTypeInProgress = CalTypeAccel; + _calTypeInProgress = QGCMAVLink::CalibrationAccel; if (doSimpleAccelCal) { _startLogCalibration(); - _calTypeInProgress = CalTypeAccelFast; - _vehicle->startCalibration(Vehicle::CalibrationAPMAccelSimple); + _calTypeInProgress = QGCMAVLink::CalibrationAPMAccelSimple; + _vehicle->startCalibration(_calTypeInProgress); return; } _vehicle->vehicleLinkManager()->setCommunicationLostEnabled(false); @@ -339,7 +339,7 @@ void APMSensorsComponentController::calibrateAccel(bool doSimpleAccelCal) _orientationCalTailDownSideVisible = false; _orientationCalNoseDownSideVisible = false; - _calTypeInProgress = CalTypeAccel; + _calTypeInProgress = QGCMAVLink::CalibrationAccel; _orientationCalDownSideVisible = true; _orientationCalUpsideDownSideVisible = true; _orientationCalLeftSideVisible = true; @@ -352,45 +352,45 @@ void APMSensorsComponentController::calibrateAccel(bool doSimpleAccelCal) emit orientationCalSidesInProgressChanged(); _updateAndEmitShowOrientationCalArea(true); - _vehicle->startCalibration(Vehicle::CalibrationAccel); + _vehicle->startCalibration(_calTypeInProgress); } void APMSensorsComponentController::calibrateMotorInterference(void) { - _calTypeInProgress = CalTypeCompassMot; + _calTypeInProgress = QGCMAVLink::CalibrationAPMCompassMot; _vehicle->vehicleLinkManager()->setCommunicationLostEnabled(false); _startLogCalibration(); _appendStatusLog(tr("Raise the throttle slowly to between 50% ~ 75% (the props will spin!) for 5 ~ 10 seconds.")); _appendStatusLog(tr("Quickly bring the throttle back down to zero")); _appendStatusLog(tr("Press the Next button to complete the calibration")); - _vehicle->startCalibration(Vehicle::CalibrationAPMCompassMot); + _vehicle->startCalibration(_calTypeInProgress); } void APMSensorsComponentController::levelHorizon(void) { - _calTypeInProgress = CalTypeLevelHorizon; + _calTypeInProgress = QGCMAVLink::CalibrationLevel; _vehicle->vehicleLinkManager()->setCommunicationLostEnabled(false); _startLogCalibration(); _appendStatusLog(tr("Hold the vehicle in its level flight position.")); - _vehicle->startCalibration(Vehicle::CalibrationLevel); + _vehicle->startCalibration(_calTypeInProgress); } void APMSensorsComponentController::calibratePressure(void) { - _calTypeInProgress = CalTypePressure; + _calTypeInProgress = QGCMAVLink::CalibrationAPMPressureAirspeed; _vehicle->vehicleLinkManager()->setCommunicationLostEnabled(false); _startLogCalibration(); _appendStatusLog(tr("Requesting pressure calibration...")); - _vehicle->startCalibration(Vehicle::CalibrationAPMPressureAirspeed); + _vehicle->startCalibration(_calTypeInProgress); } void APMSensorsComponentController::calibrateGyro(void) { - _calTypeInProgress = CalTypeGyro; + _calTypeInProgress = QGCMAVLink::CalibrationGyro; _vehicle->vehicleLinkManager()->setCommunicationLostEnabled(false); _startLogCalibration(); _appendStatusLog(tr("Requesting gyro calibration...")); - _vehicle->startCalibration(Vehicle::CalibrationGyro); + _vehicle->startCalibration(_calTypeInProgress); } void APMSensorsComponentController::_handleUASTextMessage(int uasId, int compId, int severity, QString text) @@ -446,7 +446,7 @@ void APMSensorsComponentController::cancelCalibration(void) { _cancelButton->setEnabled(false); - if (_calTypeInProgress == CalTypeOnboardCompass) { + if (_calTypeInProgress == QGCMAVLink::CalibrationMag) { _vehicle->sendMavCommand(_vehicle->defaultComponentId(), MAV_CMD_DO_CANCEL_MAG_CAL, true /* showError */); _stopCalibration(StopCalibrationCancelled); } else { @@ -479,7 +479,7 @@ void APMSensorsComponentController::nextClicked(void) _vehicle->sendMessageOnLinkThreadSafe(sharedLink.get(), msg); - if (_calTypeInProgress == CalTypeCompassMot) { + if (_calTypeInProgress == QGCMAVLink::CalibrationAPMCompassMot) { _stopCalibration(StopCalibrationSuccess); } } @@ -508,7 +508,7 @@ bool APMSensorsComponentController::usingUDPLink(void) void APMSensorsComponentController::_handleCommandAck(mavlink_message_t& message) { - if (_calTypeInProgress == CalTypeLevelHorizon || _calTypeInProgress == CalTypeGyro || _calTypeInProgress == CalTypePressure || _calTypeInProgress == CalTypeAccelFast) { + if (_calTypeInProgress == QGCMAVLink::CalibrationLevel || _calTypeInProgress == QGCMAVLink::CalibrationGyro || _calTypeInProgress == QGCMAVLink::CalibrationAPMPressureAirspeed || _calTypeInProgress == QGCMAVLink::CalibrationAPMAccelSimple) { mavlink_command_ack_t commandAck; mavlink_msg_command_ack_decode(&message, &commandAck); @@ -532,7 +532,7 @@ void APMSensorsComponentController::_handleCommandAck(mavlink_message_t& message void APMSensorsComponentController::_handleMagCalProgress(mavlink_message_t& message) { - if (_calTypeInProgress == CalTypeOnboardCompass) { + if (_calTypeInProgress == QGCMAVLink::CalibrationMag) { mavlink_mag_cal_progress_t magCalProgress; mavlink_msg_mag_cal_progress_decode(&message, &magCalProgress); @@ -560,7 +560,7 @@ void APMSensorsComponentController::_handleMagCalProgress(mavlink_message_t& mes void APMSensorsComponentController::_handleMagCalReport(mavlink_message_t& message) { - if (_calTypeInProgress == CalTypeOnboardCompass) { + if (_calTypeInProgress == QGCMAVLink::CalibrationMag) { mavlink_mag_cal_report_t magCalReport; mavlink_msg_mag_cal_report_decode(&message, &magCalReport); diff --git a/src/AutoPilotPlugins/APM/APMSensorsComponentController.h b/src/AutoPilotPlugins/APM/APMSensorsComponentController.h index c6adc228ad9..c4b9cec5676 100644 --- a/src/AutoPilotPlugins/APM/APMSensorsComponentController.h +++ b/src/AutoPilotPlugins/APM/APMSensorsComponentController.h @@ -10,7 +10,7 @@ #pragma once #include "FactPanelController.h" -#include "MAVLinkLib.h" +#include "QGCMAVLink.h" #include #include @@ -95,18 +95,6 @@ class APMSensorsComponentController : public FactPanelController bool compassSetupNeeded (void) const; bool accelSetupNeeded (void) const; - typedef enum { - CalTypeAccel, - CalTypeGyro, - CalTypeOnboardCompass, - CalTypeLevelHorizon, - CalTypeCompassMot, - CalTypePressure, - CalTypeAccelFast, - CalTypeNone - } CalType_t; - Q_ENUM(CalType_t) - bool compass1CalSucceeded(void) const { return _rgCompassCalSucceeded[0]; } bool compass2CalSucceeded(void) const { return _rgCompassCalSucceeded[1]; } bool compass3CalSucceeded(void) const { return _rgCompassCalSucceeded[2]; } @@ -125,7 +113,7 @@ class APMSensorsComponentController : public FactPanelController void resetStatusTextArea (void); void waitingForCancelChanged (void); void setupNeededChanged (void); - void calibrationComplete (CalType_t calType); + void calibrationComplete (QGCMAVLink::CalibrationType calType); void compass1CalSucceededChanged (bool compass1CalSucceeded); void compass2CalSucceededChanged (bool compass2CalSucceeded); void compass3CalSucceededChanged (bool compass3CalSucceeded); @@ -172,7 +160,7 @@ private slots: bool _showOrientationCalArea; - CalType_t _calTypeInProgress; + QGCMAVLink::CalibrationType _calTypeInProgress; uint8_t _rgCompassCalProgress[3]; bool _rgCompassCalComplete[3]; diff --git a/src/AutoPilotPlugins/Common/RadioComponentController.cc b/src/AutoPilotPlugins/Common/RadioComponentController.cc index 8c1b6fa659f..bcd062694a0 100644 --- a/src/AutoPilotPlugins/Common/RadioComponentController.cc +++ b/src/AutoPilotPlugins/Common/RadioComponentController.cc @@ -800,7 +800,7 @@ void RadioComponentController::_startCalibration(void) _resetInternalCalibrationValues(); // Let the mav known we are starting calibration. This should turn off motors and so forth. - _vehicle->startCalibration(Vehicle::CalibrationRadio); + _vehicle->startCalibration(QGCMAVLink::CalibrationRadio); _nextButton->setProperty("text", tr("Next")); _cancelButton->setEnabled(true); @@ -1025,7 +1025,7 @@ void RadioComponentController::_signalAllAttitudeValueChanges(void) void RadioComponentController::copyTrims(void) { - _vehicle->startCalibration(Vehicle::CalibrationCopyTrims); + _vehicle->startCalibration(QGCMAVLink::CalibrationCopyTrims); } bool RadioComponentController::_px4Vehicle(void) const diff --git a/src/AutoPilotPlugins/PX4/PowerComponentController.cc b/src/AutoPilotPlugins/PX4/PowerComponentController.cc index 6a31e86f717..15c7ce4eb19 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponentController.cc +++ b/src/AutoPilotPlugins/PX4/PowerComponentController.cc @@ -19,7 +19,7 @@ void PowerComponentController::calibrateEsc(void) { _warningMessages.clear(); connect(_vehicle, &Vehicle::textMessageReceived, this, &PowerComponentController::_handleVehicleTextMessage); - _vehicle->startCalibration(Vehicle::CalibrationEsc); + _vehicle->startCalibration(QGCMAVLink::CalibrationEsc); } void PowerComponentController::startBusConfigureActuators(void) diff --git a/src/AutoPilotPlugins/PX4/SensorsComponentController.cc b/src/AutoPilotPlugins/PX4/SensorsComponentController.cc index 34148748326..9dc429d2560 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponentController.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponentController.cc @@ -196,31 +196,31 @@ void SensorsComponentController::_stopCalibration(SensorsComponentController::St void SensorsComponentController::calibrateGyro(void) { _startLogCalibration(); - _vehicle->startCalibration(Vehicle::CalibrationGyro); + _vehicle->startCalibration(QGCMAVLink::CalibrationGyro); } void SensorsComponentController::calibrateCompass(void) { _startLogCalibration(); - _vehicle->startCalibration(Vehicle::CalibrationMag); + _vehicle->startCalibration(QGCMAVLink::CalibrationMag); } void SensorsComponentController::calibrateAccel(void) { _startLogCalibration(); - _vehicle->startCalibration(Vehicle::CalibrationAccel); + _vehicle->startCalibration(QGCMAVLink::CalibrationAccel); } void SensorsComponentController::calibrateLevel(void) { _startLogCalibration(); - _vehicle->startCalibration(Vehicle::CalibrationLevel); + _vehicle->startCalibration(QGCMAVLink::CalibrationLevel); } void SensorsComponentController::calibrateAirspeed(void) { _startLogCalibration(); - _vehicle->startCalibration(Vehicle::CalibrationPX4Airspeed); + _vehicle->startCalibration(QGCMAVLink::CalibrationPX4Airspeed); } void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, int severity, QString text) diff --git a/src/MAVLink/ImageProtocolManager.h b/src/MAVLink/ImageProtocolManager.h index d6545551054..e5658709610 100644 --- a/src/MAVLink/ImageProtocolManager.h +++ b/src/MAVLink/ImageProtocolManager.h @@ -13,8 +13,8 @@ #include #include -#include #include +#include Q_DECLARE_LOGGING_CATEGORY(ImageProtocolManagerLog) diff --git a/src/MAVLink/MAVLinkFTP.h b/src/MAVLink/MAVLinkFTP.h index 716781b6c73..8e091e61a87 100644 --- a/src/MAVLink/MAVLinkFTP.h +++ b/src/MAVLink/MAVLinkFTP.h @@ -10,9 +10,12 @@ #pragma once #include +#include #include "MAVLinkLib.h" +Q_DECLARE_LOGGING_CATEGORY(MavlinkFTPLog) + class MavlinkFTP { public: /// This is the fixed length portion of the protocol data. diff --git a/src/MAVLink/MAVLinkStreamConfig.h b/src/MAVLink/MAVLinkStreamConfig.h index ccabbd0eaea..83ae6de6217 100644 --- a/src/MAVLink/MAVLinkStreamConfig.h +++ b/src/MAVLink/MAVLinkStreamConfig.h @@ -10,6 +10,9 @@ #pragma once #include +#include + +Q_DECLARE_LOGGING_CATEGORY(MAVLinkStreamConfigLog) /** * @class MAVLinkStreamConfig diff --git a/src/MAVLink/QGCMAVLink.cc b/src/MAVLink/QGCMAVLink.cc index 014d8f664fa..a80b7f74e06 100644 --- a/src/MAVLink/QGCMAVLink.cc +++ b/src/MAVLink/QGCMAVLink.cc @@ -8,6 +8,7 @@ ****************************************************************************/ #include "QGCMAVLink.h" +#include #include @@ -260,3 +261,144 @@ QString QGCMAVLink::mavSysStatusSensorToString(MAV_SYS_STATUS_SENSOR sysStatusSe return QT_TRANSLATE_NOOP("MAVLink unknown SYS_STATUS_SENSOR value", "Unknown sensor"); } + +QString QGCMAVLink::mavTypeToString(MAV_TYPE mavType) { + static QMap typeNames = { + { MAV_TYPE_GENERIC, tr("Generic micro air vehicle" )}, + { MAV_TYPE_FIXED_WING, tr("Fixed wing aircraft")}, + { MAV_TYPE_QUADROTOR, tr("Quadrotor")}, + { MAV_TYPE_COAXIAL, tr("Coaxial helicopter")}, + { MAV_TYPE_HELICOPTER, tr("Normal helicopter with tail rotor.")}, + { MAV_TYPE_ANTENNA_TRACKER, tr("Ground installation")}, + { MAV_TYPE_GCS, tr("Operator control unit / ground control station")}, + { MAV_TYPE_AIRSHIP, tr("Airship, controlled")}, + { MAV_TYPE_FREE_BALLOON, tr("Free balloon, uncontrolled")}, + { MAV_TYPE_ROCKET, tr("Rocket")}, + { MAV_TYPE_GROUND_ROVER, tr("Ground rover")}, + { MAV_TYPE_SURFACE_BOAT, tr("Surface vessel, boat, ship")}, + { MAV_TYPE_SUBMARINE, tr("Submarine")}, + { MAV_TYPE_HEXAROTOR, tr("Hexarotor")}, + { MAV_TYPE_OCTOROTOR, tr("Octorotor")}, + { MAV_TYPE_TRICOPTER, tr("trirotor")}, + { MAV_TYPE_FLAPPING_WING, tr("Flapping wing")}, + { MAV_TYPE_KITE, tr("Kite")}, + { MAV_TYPE_ONBOARD_CONTROLLER, tr("Onboard companion controller")}, + { MAV_TYPE_VTOL_TAILSITTER_DUOROTOR, tr("Two-rotor VTOL using control surfaces in vertical operation in addition. Tailsitter")}, + { MAV_TYPE_VTOL_TAILSITTER_QUADROTOR, tr("Quad-rotor VTOL using a V-shaped quad config in vertical operation. Tailsitter")}, + { MAV_TYPE_VTOL_TILTROTOR, tr("Tiltrotor VTOL")}, + { MAV_TYPE_VTOL_FIXEDROTOR, tr("VTOL Fixedrotor")}, + { MAV_TYPE_VTOL_TAILSITTER, tr("VTOL Tailsitter")}, + { MAV_TYPE_VTOL_TILTWING, tr("VTOL Tiltwing")}, + { MAV_TYPE_VTOL_RESERVED5, tr("VTOL reserved 5")}, + { MAV_TYPE_GIMBAL, tr("Onboard gimbal")}, + { MAV_TYPE_ADSB, tr("Onboard ADSB peripheral")}, + }; + + return typeNames.value(mavType, "MAV_TYPE_UNKNOWN"); +} + +QString QGCMAVLink::firmwareVersionTypeToString(FIRMWARE_VERSION_TYPE firmwareVersionType) +{ + switch (firmwareVersionType) { + case FIRMWARE_VERSION_TYPE_DEV: + return QStringLiteral("dev"); + case FIRMWARE_VERSION_TYPE_ALPHA: + return QStringLiteral("alpha"); + case FIRMWARE_VERSION_TYPE_BETA: + return QStringLiteral("beta"); + case FIRMWARE_VERSION_TYPE_RC: + return QStringLiteral("rc"); + case FIRMWARE_VERSION_TYPE_OFFICIAL: + default: + return QStringLiteral(""); + } +} + +int QGCMAVLink::motorCount(MAV_TYPE mavType, uint8_t frameType) +{ + switch (mavType) { + case MAV_TYPE_HELICOPTER: + return 1; + case MAV_TYPE_VTOL_TAILSITTER_DUOROTOR: + return 2; + case MAV_TYPE_TRICOPTER: + return 3; + case MAV_TYPE_QUADROTOR: + case MAV_TYPE_VTOL_TAILSITTER_QUADROTOR: + return 4; + case MAV_TYPE_HEXAROTOR: + return 6; + case MAV_TYPE_OCTOROTOR: + return 8; + case MAV_TYPE_SUBMARINE: + { + // Supported frame types + enum { + SUB_FRAME_BLUEROV1, + SUB_FRAME_VECTORED, + SUB_FRAME_VECTORED_6DOF, + SUB_FRAME_VECTORED_6DOF_90DEG, + SUB_FRAME_SIMPLEROV_3, + SUB_FRAME_SIMPLEROV_4, + SUB_FRAME_SIMPLEROV_5, + SUB_FRAME_CUSTOM + }; + + switch (frameType) { // ardupilot/libraries/AP_Motors/AP_Motors6DOF.h sub_frame_t + + case SUB_FRAME_BLUEROV1: + case SUB_FRAME_VECTORED: + return 6; + + case SUB_FRAME_SIMPLEROV_3: + return 3; + + case SUB_FRAME_SIMPLEROV_4: + return 4; + + case SUB_FRAME_SIMPLEROV_5: + return 5; + + case SUB_FRAME_VECTORED_6DOF: + case SUB_FRAME_VECTORED_6DOF_90DEG: + case SUB_FRAME_CUSTOM: + return 8; + + default: + return -1; + } + } + + default: + return -1; + } +} + +uint32_t QGCMAVLink::highLatencyFailuresToMavSysStatus(mavlink_high_latency2_t& highLatency2) +{ + struct failure2Sensor_s { + HL_FAILURE_FLAG failureBit; + MAV_SYS_STATUS_SENSOR sensorBit; + }; + + static const failure2Sensor_s rgFailure2Sensor[] = { + { HL_FAILURE_FLAG_GPS, MAV_SYS_STATUS_SENSOR_GPS }, + { HL_FAILURE_FLAG_DIFFERENTIAL_PRESSURE, MAV_SYS_STATUS_SENSOR_DIFFERENTIAL_PRESSURE }, + { HL_FAILURE_FLAG_ABSOLUTE_PRESSURE, MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE }, + { HL_FAILURE_FLAG_3D_ACCEL, MAV_SYS_STATUS_SENSOR_3D_ACCEL }, + { HL_FAILURE_FLAG_3D_GYRO, MAV_SYS_STATUS_SENSOR_3D_GYRO }, + { HL_FAILURE_FLAG_3D_MAG, MAV_SYS_STATUS_SENSOR_3D_MAG }, + }; + + // Map from MAV_FAILURE bits to standard SYS_STATUS message handling + uint32_t onboardControlSensorsEnabled = 0; + for (size_t i=0; ifailureBit) { + // Assume if reporting as unhealthy that is it present and enabled + onboardControlSensorsEnabled |= pFailure2Sensor->sensorBit; + } + } + + return onboardControlSensorsEnabled; +} diff --git a/src/MAVLink/QGCMAVLink.h b/src/MAVLink/QGCMAVLink.h index 9fb58059041..519cc85946e 100644 --- a/src/MAVLink/QGCMAVLink.h +++ b/src/MAVLink/QGCMAVLink.h @@ -12,12 +12,18 @@ #include #include #include +#include +#include #include "MAVLinkLib.h" +Q_DECLARE_LOGGING_CATEGORY(QGCMAVLinkLog) + class QGCMAVLink : public QObject { Q_OBJECT + QML_ELEMENT + QML_UNCREATABLE("") public: // Creating an instance of QGCMAVLink is only meant to be used for the Qml Singleton @@ -62,6 +68,10 @@ class QGCMAVLink : public QObject static QString mavResultToString (MAV_RESULT result); static QString mavSysStatusSensorToString (MAV_SYS_STATUS_SENSOR sysStatusSensor); + static QString mavTypeToString (MAV_TYPE mavType); + static QString firmwareVersionTypeToString (FIRMWARE_VERSION_TYPE firmwareVersionType); + static int motorCount (MAV_TYPE mavType, uint8_t frameType = 0); + static uint32_t highLatencyFailuresToMavSysStatus(mavlink_high_latency2_t& highLatency2); // Expose mavlink enums to Qml. I've tried various way to make this work without duping, but haven't found anything that works. @@ -86,4 +96,60 @@ class QGCMAVLink : public QObject MAV_BATTERY_CHARGE_STATE_CHARGING=7, /* Battery is charging. | */ }; Q_ENUM(MAV_BATTERY_CHARGE_STATE) + + /// Sensor bits from sensors*Bits properties + enum MavlinkSysStatus { + SysStatusSensor3dGyro = MAV_SYS_STATUS_SENSOR_3D_GYRO, + SysStatusSensor3dAccel = MAV_SYS_STATUS_SENSOR_3D_ACCEL, + SysStatusSensor3dMag = MAV_SYS_STATUS_SENSOR_3D_MAG, + SysStatusSensorAbsolutePressure = MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE, + SysStatusSensorDifferentialPressure = MAV_SYS_STATUS_SENSOR_DIFFERENTIAL_PRESSURE, + SysStatusSensorGPS = MAV_SYS_STATUS_SENSOR_GPS, + SysStatusSensorOpticalFlow = MAV_SYS_STATUS_SENSOR_OPTICAL_FLOW, + SysStatusSensorVisionPosition = MAV_SYS_STATUS_SENSOR_VISION_POSITION, + SysStatusSensorLaserPosition = MAV_SYS_STATUS_SENSOR_LASER_POSITION, + SysStatusSensorExternalGroundTruth = MAV_SYS_STATUS_SENSOR_EXTERNAL_GROUND_TRUTH, + SysStatusSensorAngularRateControl = MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL, + SysStatusSensorAttitudeStabilization = MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION, + SysStatusSensorYawPosition = MAV_SYS_STATUS_SENSOR_YAW_POSITION, + SysStatusSensorZAltitudeControl = MAV_SYS_STATUS_SENSOR_Z_ALTITUDE_CONTROL, + SysStatusSensorXYPositionControl = MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL, + SysStatusSensorMotorOutputs = MAV_SYS_STATUS_SENSOR_MOTOR_OUTPUTS, + SysStatusSensorRCReceiver = MAV_SYS_STATUS_SENSOR_RC_RECEIVER, + SysStatusSensor3dGyro2 = MAV_SYS_STATUS_SENSOR_3D_GYRO2, + SysStatusSensor3dAccel2 = MAV_SYS_STATUS_SENSOR_3D_ACCEL2, + SysStatusSensor3dMag2 = MAV_SYS_STATUS_SENSOR_3D_MAG2, + SysStatusSensorGeoFence = MAV_SYS_STATUS_GEOFENCE, + SysStatusSensorAHRS = MAV_SYS_STATUS_AHRS, + SysStatusSensorTerrain = MAV_SYS_STATUS_TERRAIN, + SysStatusSensorReverseMotor = MAV_SYS_STATUS_REVERSE_MOTOR, + SysStatusSensorLogging = MAV_SYS_STATUS_LOGGING, + SysStatusSensorBattery = MAV_SYS_STATUS_SENSOR_BATTERY, + }; + Q_ENUM(MavlinkSysStatus) + + enum GRIPPER_OPTIONS { + Gripper_release = GRIPPER_ACTION_RELEASE, + Gripper_grab = GRIPPER_ACTION_GRAB, + Invalid_option = GRIPPER_ACTIONS_ENUM_END, + }; + Q_ENUM(GRIPPER_OPTIONS) + + enum CalibrationType { + CalibrationNone, + CalibrationRadio, + CalibrationGyro, + CalibrationMag, + CalibrationAccel, + CalibrationLevel, + CalibrationEsc, + CalibrationCopyTrims, + CalibrationAPMCompassMot, + CalibrationAPMPressureAirspeed, + CalibrationAPMPreFlight, + CalibrationPX4Airspeed, + CalibrationPX4Pressure, + CalibrationAPMAccelSimple, + }; + Q_ENUM(CalibrationType) }; diff --git a/src/MAVLink/SysStatusSensorInfo.h b/src/MAVLink/SysStatusSensorInfo.h index 87f4a638430..fb68ee8673b 100644 --- a/src/MAVLink/SysStatusSensorInfo.h +++ b/src/MAVLink/SysStatusSensorInfo.h @@ -13,6 +13,9 @@ #include #include +#include + +Q_DECLARE_LOGGING_CATEGORY(SysStatusSensorInfoLog) /// Class which represents sensor info from the SYS_STATUS mavlink message class SysStatusSensorInfo : public QObject diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 8181515260d..68f10959614 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -526,32 +526,7 @@ void Vehicle::_offlineHoverSpeedSettingChanged(QVariant value) QString Vehicle::firmwareTypeString() const { - if (px4Firmware()) { - return QStringLiteral("PX4 Pro"); - } else if (apmFirmware()) { - return QStringLiteral("ArduPilot"); - } else { - return tr("MAVLink Generic"); - } -} - -QString Vehicle::vehicleTypeString() const -{ - if (airship()) { - return tr("Airship"); - } else if (fixedWing()) { - return tr("Fixed Wing"); - } else if (multiRotor()) { - return tr("Multi-Rotor"); - } else if (vtol()) { - return tr("VTOL"); - } else if (rover()) { - return tr("Rover"); - } else if (sub()) { - return tr("Sub"); - } else { - return tr("Unknown"); - } + return QGCMAVLink::firmwareClassToString(_firmwareType); } void Vehicle::resetCounters() @@ -1032,24 +1007,6 @@ void Vehicle::_handleNavControllerOutput(mavlink_message_t& message) _distanceToNextWPFact.setRawValue(navControllerOutput.wp_dist); } -// Ignore warnings from mavlink headers for both GCC/Clang and MSVC -#ifdef __GNUC__ - -#if __GNUC__ > 8 -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Waddress-of-packed-member" -#elif defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Waddress-of-packed-member" -#else -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wall" -#endif - -#else -#pragma warning(push, 0) -#endif - void Vehicle::_handleAttitudeWorker(double rollRadians, double pitchRadians, double yawRadians) { double roll, pitch, yaw; @@ -1249,29 +1206,8 @@ void Vehicle::_handleHighLatency2(mavlink_message_t& message) _altitudeRelativeFact.setRawValue(qQNaN()); _altitudeAMSLFact.setRawValue(highLatency2.altitude); - struct failure2Sensor_s { - HL_FAILURE_FLAG failureBit; - MAV_SYS_STATUS_SENSOR sensorBit; - }; - - static const failure2Sensor_s rgFailure2Sensor[] = { - { HL_FAILURE_FLAG_GPS, MAV_SYS_STATUS_SENSOR_GPS }, - { HL_FAILURE_FLAG_DIFFERENTIAL_PRESSURE, MAV_SYS_STATUS_SENSOR_DIFFERENTIAL_PRESSURE }, - { HL_FAILURE_FLAG_ABSOLUTE_PRESSURE, MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE }, - { HL_FAILURE_FLAG_3D_ACCEL, MAV_SYS_STATUS_SENSOR_3D_ACCEL }, - { HL_FAILURE_FLAG_3D_GYRO, MAV_SYS_STATUS_SENSOR_3D_GYRO }, - { HL_FAILURE_FLAG_3D_MAG, MAV_SYS_STATUS_SENSOR_3D_MAG }, - }; - // Map from MAV_FAILURE bits to standard SYS_STATUS message handling - uint32_t newOnboardControlSensorsEnabled = 0; - for (size_t i=0; ifailureBit) { - // Assume if reporting as unhealthy that is it present and enabled - newOnboardControlSensorsEnabled |= pFailure2Sensor->sensorBit; - } - } + const uint32_t newOnboardControlSensorsEnabled = QGCMAVLink::highLatencyFailuresToMavSysStatus(highLatency2); if (newOnboardControlSensorsEnabled != _onboardControlSensorsEnabled) { _onboardControlSensorsEnabled = newOnboardControlSensorsEnabled; _onboardControlSensorsPresent = newOnboardControlSensorsEnabled; @@ -1876,17 +1812,6 @@ void Vehicle::_handleRCChannels(mavlink_message_t& message) emit rcChannelsChanged(channels.chancount, pwmValues); } -// Pop warnings ignoring for mavlink headers for both GCC/Clang and MSVC -#ifdef __GNUC__ -#if defined(__clang__) -#pragma clang diagnostic pop -#else -#pragma GCC diagnostic pop -#endif -#else -#pragma warning(pop, 0) -#endif - bool Vehicle::sendMessageOnLinkThreadSafe(LinkInterface* link, mavlink_message_t message) { if (!link->isConnected()) { @@ -1910,64 +1835,11 @@ bool Vehicle::sendMessageOnLinkThreadSafe(LinkInterface* link, mavlink_message_t int Vehicle::motorCount() { - switch (_vehicleType) { - case MAV_TYPE_HELICOPTER: - return 1; - case MAV_TYPE_VTOL_TAILSITTER_DUOROTOR: - return 2; - case MAV_TYPE_TRICOPTER: - return 3; - case MAV_TYPE_QUADROTOR: - case MAV_TYPE_VTOL_TAILSITTER_QUADROTOR: - return 4; - case MAV_TYPE_HEXAROTOR: - return 6; - case MAV_TYPE_OCTOROTOR: - return 8; - case MAV_TYPE_SUBMARINE: - { - // Supported frame types - enum { - SUB_FRAME_BLUEROV1, - SUB_FRAME_VECTORED, - SUB_FRAME_VECTORED_6DOF, - SUB_FRAME_VECTORED_6DOF_90DEG, - SUB_FRAME_SIMPLEROV_3, - SUB_FRAME_SIMPLEROV_4, - SUB_FRAME_SIMPLEROV_5, - SUB_FRAME_CUSTOM - }; - - uint8_t frameType = parameterManager()->getParameter(_compID, "FRAME_CONFIG")->rawValue().toInt(); - - switch (frameType) { // ardupilot/libraries/AP_Motors/AP_Motors6DOF.h sub_frame_t - - case SUB_FRAME_BLUEROV1: - case SUB_FRAME_VECTORED: - return 6; - - case SUB_FRAME_SIMPLEROV_3: - return 3; - - case SUB_FRAME_SIMPLEROV_4: - return 4; - - case SUB_FRAME_SIMPLEROV_5: - return 5; - - case SUB_FRAME_VECTORED_6DOF: - case SUB_FRAME_VECTORED_6DOF_90DEG: - case SUB_FRAME_CUSTOM: - return 8; - - default: - return -1; - } - } - - default: - return -1; + uint8_t frameType = 0; + if (_vehicleType == MAV_TYPE_SUBMARINE) { + frameType = parameterManager()->getParameter(_compID, "FRAME_CONFIG")->rawValue().toInt(); } + return QGCMAVLink::motorCount(_vehicleType, frameType); } bool Vehicle::coaxialMotors() @@ -2585,38 +2457,9 @@ bool Vehicle::supportsTerrainFrame() const return !px4Firmware(); } -QString Vehicle::vehicleTypeName() const { - static QMap typeNames = { - { MAV_TYPE_GENERIC, tr("Generic micro air vehicle" )}, - { MAV_TYPE_FIXED_WING, tr("Fixed wing aircraft")}, - { MAV_TYPE_QUADROTOR, tr("Quadrotor")}, - { MAV_TYPE_COAXIAL, tr("Coaxial helicopter")}, - { MAV_TYPE_HELICOPTER, tr("Normal helicopter with tail rotor.")}, - { MAV_TYPE_ANTENNA_TRACKER, tr("Ground installation")}, - { MAV_TYPE_GCS, tr("Operator control unit / ground control station")}, - { MAV_TYPE_AIRSHIP, tr("Airship, controlled")}, - { MAV_TYPE_FREE_BALLOON, tr("Free balloon, uncontrolled")}, - { MAV_TYPE_ROCKET, tr("Rocket")}, - { MAV_TYPE_GROUND_ROVER, tr("Ground rover")}, - { MAV_TYPE_SURFACE_BOAT, tr("Surface vessel, boat, ship")}, - { MAV_TYPE_SUBMARINE, tr("Submarine")}, - { MAV_TYPE_HEXAROTOR, tr("Hexarotor")}, - { MAV_TYPE_OCTOROTOR, tr("Octorotor")}, - { MAV_TYPE_TRICOPTER, tr("Octorotor")}, - { MAV_TYPE_FLAPPING_WING, tr("Flapping wing")}, - { MAV_TYPE_KITE, tr("Kite")}, - { MAV_TYPE_ONBOARD_CONTROLLER, tr("Onboard companion controller")}, - { MAV_TYPE_VTOL_TAILSITTER_DUOROTOR, tr("Two-rotor VTOL using control surfaces in vertical operation in addition. Tailsitter")}, - { MAV_TYPE_VTOL_TAILSITTER_QUADROTOR, tr("Quad-rotor VTOL using a V-shaped quad config in vertical operation. Tailsitter")}, - { MAV_TYPE_VTOL_TILTROTOR, tr("Tiltrotor VTOL")}, - { MAV_TYPE_VTOL_FIXEDROTOR, tr("VTOL Fixedrotor")}, - { MAV_TYPE_VTOL_TAILSITTER, tr("VTOL Tailsitter")}, - { MAV_TYPE_VTOL_TILTWING, tr("VTOL Tiltwing")}, - { MAV_TYPE_VTOL_RESERVED5, tr("VTOL reserved 5")}, - { MAV_TYPE_GIMBAL, tr("Onboard gimbal")}, - { MAV_TYPE_ADSB, tr("Onboard ADSB peripheral")}, - }; - return typeNames[_vehicleType]; +QString Vehicle::vehicleTypeString() const +{ + return QGCMAVLink::mavTypeToString(_vehicleType); } QString Vehicle::vehicleClassInternalName() const @@ -3511,19 +3354,7 @@ void Vehicle::setFirmwareCustomVersion(int majorVersion, int minorVersion, int p QString Vehicle::firmwareVersionTypeString() const { - switch (_firmwareVersionType) { - case FIRMWARE_VERSION_TYPE_DEV: - return QStringLiteral("dev"); - case FIRMWARE_VERSION_TYPE_ALPHA: - return QStringLiteral("alpha"); - case FIRMWARE_VERSION_TYPE_BETA: - return QStringLiteral("beta"); - case FIRMWARE_VERSION_TYPE_RC: - return QStringLiteral("rc"); - case FIRMWARE_VERSION_TYPE_OFFICIAL: - default: - return QStringLiteral(""); - } + return QGCMAVLink::firmwareVersionTypeToString(_firmwareVersionType); } void Vehicle::_rebootCommandResultHandler(void* resultHandlerData, int /*compId*/, const mavlink_command_ack_t& ack, MavCmdResultFailureCode_t failureCode) @@ -3557,7 +3388,7 @@ void Vehicle::rebootVehicle() sendMavCommandWithHandler(&handlerInfo, _defaultComponentId, MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN, 1); } -void Vehicle::startCalibration(Vehicle::CalibrationType calType) +void Vehicle::startCalibration(QGCMAVLink::CalibrationType calType) { SharedLinkInterfacePtr sharedLink = vehicleLinkManager()->primaryLink().lock(); if (!sharedLink) { @@ -3574,49 +3405,52 @@ void Vehicle::startCalibration(Vehicle::CalibrationType calType) float param7 = 0; switch (calType) { - case CalibrationGyro: + case QGCMAVLink::CalibrationGyro: param1 = 1; break; - case CalibrationMag: + case QGCMAVLink::CalibrationMag: param2 = 1; break; - case CalibrationRadio: + case QGCMAVLink::CalibrationRadio: param4 = 1; break; - case CalibrationCopyTrims: + case QGCMAVLink::CalibrationCopyTrims: param4 = 2; break; - case CalibrationAccel: + case QGCMAVLink::CalibrationAccel: param5 = 1; break; - case CalibrationLevel: + case QGCMAVLink::CalibrationLevel: param5 = 2; break; - case CalibrationEsc: + case QGCMAVLink::CalibrationEsc: param7 = 1; break; - case CalibrationPX4Airspeed: + case QGCMAVLink::CalibrationPX4Airspeed: param6 = 1; break; - case CalibrationPX4Pressure: + case QGCMAVLink::CalibrationPX4Pressure: param3 = 1; break; - case CalibrationAPMCompassMot: + case QGCMAVLink::CalibrationAPMCompassMot: param6 = 1; break; - case CalibrationAPMPressureAirspeed: + case QGCMAVLink::CalibrationAPMPressureAirspeed: param3 = 1; break; - case CalibrationAPMPreFlight: + case QGCMAVLink::CalibrationAPMPreFlight: param3 = 1; // GroundPressure/Airspeed if (multiRotor() || rover()) { // Gyro cal for ArduCopter only param1 = 1; } break; - case CalibrationAPMAccelSimple: + case QGCMAVLink::CalibrationAPMAccelSimple: param5 = 4; break; + case QGCMAVLink::CalibrationNone: + default: + break; } // We can't use sendMavCommand here since we have no idea how long it will be before the command returns a result. This in turn @@ -4507,16 +4341,16 @@ void Vehicle::setGripperAction(GRIPPER_ACTIONS gripperAction) 0, 0, 0, 0, 0); // Param 3 ~ 7 : unused } -void Vehicle::sendGripperAction(GRIPPER_OPTIONS gripperOption) +void Vehicle::sendGripperAction(QGCMAVLink::GRIPPER_OPTIONS gripperOption) { switch(gripperOption) { - case Gripper_release: + case QGCMAVLink::Gripper_release: setGripperAction(GRIPPER_ACTION_RELEASE); break; - case Gripper_grab: + case QGCMAVLink::Gripper_grab: setGripperAction(GRIPPER_ACTION_GRAB); break; - case Invalid_option: + case QGCMAVLink::Invalid_option: qDebug("unknown function"); break; default: diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index c7088f147e7..fb2d0f1d9a8 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -133,37 +133,6 @@ class Vehicle : public FactGroup ~Vehicle(); - /// Sensor bits from sensors*Bits properties - enum MavlinkSysStatus { - SysStatusSensor3dGyro = MAV_SYS_STATUS_SENSOR_3D_GYRO, - SysStatusSensor3dAccel = MAV_SYS_STATUS_SENSOR_3D_ACCEL, - SysStatusSensor3dMag = MAV_SYS_STATUS_SENSOR_3D_MAG, - SysStatusSensorAbsolutePressure = MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE, - SysStatusSensorDifferentialPressure = MAV_SYS_STATUS_SENSOR_DIFFERENTIAL_PRESSURE, - SysStatusSensorGPS = MAV_SYS_STATUS_SENSOR_GPS, - SysStatusSensorOpticalFlow = MAV_SYS_STATUS_SENSOR_OPTICAL_FLOW, - SysStatusSensorVisionPosition = MAV_SYS_STATUS_SENSOR_VISION_POSITION, - SysStatusSensorLaserPosition = MAV_SYS_STATUS_SENSOR_LASER_POSITION, - SysStatusSensorExternalGroundTruth = MAV_SYS_STATUS_SENSOR_EXTERNAL_GROUND_TRUTH, - SysStatusSensorAngularRateControl = MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL, - SysStatusSensorAttitudeStabilization = MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION, - SysStatusSensorYawPosition = MAV_SYS_STATUS_SENSOR_YAW_POSITION, - SysStatusSensorZAltitudeControl = MAV_SYS_STATUS_SENSOR_Z_ALTITUDE_CONTROL, - SysStatusSensorXYPositionControl = MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL, - SysStatusSensorMotorOutputs = MAV_SYS_STATUS_SENSOR_MOTOR_OUTPUTS, - SysStatusSensorRCReceiver = MAV_SYS_STATUS_SENSOR_RC_RECEIVER, - SysStatusSensor3dGyro2 = MAV_SYS_STATUS_SENSOR_3D_GYRO2, - SysStatusSensor3dAccel2 = MAV_SYS_STATUS_SENSOR_3D_ACCEL2, - SysStatusSensor3dMag2 = MAV_SYS_STATUS_SENSOR_3D_MAG2, - SysStatusSensorGeoFence = MAV_SYS_STATUS_GEOFENCE, - SysStatusSensorAHRS = MAV_SYS_STATUS_AHRS, - SysStatusSensorTerrain = MAV_SYS_STATUS_TERRAIN, - SysStatusSensorReverseMotor = MAV_SYS_STATUS_REVERSE_MOTOR, - SysStatusSensorLogging = MAV_SYS_STATUS_LOGGING, - SysStatusSensorBattery = MAV_SYS_STATUS_SENSOR_BATTERY, - }; - Q_ENUM(MavlinkSysStatus) - enum CheckList { CheckListNotSetup = 0, CheckListPassed, @@ -519,7 +488,6 @@ class Vehicle : public FactGroup MAV_AUTOPILOT firmwareType() const { return _firmwareType; } MAV_TYPE vehicleType() const { return _vehicleType; } QGCMAVLink::VehicleClass_t vehicleClass(void) const { return QGCMAVLink::vehicleClass(_vehicleType); } - Q_INVOKABLE QString vehicleTypeName() const; Q_INVOKABLE QString vehicleClassInternalName() const; /// Sends a message to the specified link @@ -556,16 +524,8 @@ class Vehicle : public FactGroup * @param gripperAction Gripper action to trigger */ - enum GRIPPER_OPTIONS - { - Gripper_release = GRIPPER_ACTION_RELEASE, - Gripper_grab = GRIPPER_ACTION_GRAB, - Invalid_option = GRIPPER_ACTIONS_ENUM_END, - }; - Q_ENUM(GRIPPER_OPTIONS) - void setGripperAction(GRIPPER_ACTIONS gripperAction); - Q_INVOKABLE void sendGripperAction(GRIPPER_OPTIONS gripperOption); + Q_INVOKABLE void sendGripperAction(QGCMAVLink::GRIPPER_OPTIONS gripperOption); void pairRX(int rxType, int rxSubType); @@ -667,7 +627,7 @@ class Vehicle : public FactGroup bool readyToFly () const{ return _readyToFly; } bool allSensorsHealthy () const{ return _allSensorsHealthy; } QObject* sysStatusSensorInfo () { return &_sysStatusSensorInfo; } - bool requiresGpsFix () const { return static_cast(_onboardControlSensorsPresent & SysStatusSensorGPS); } + bool requiresGpsFix () const { return static_cast(_onboardControlSensorsPresent & QGCMAVLink::SysStatusSensorGPS); } bool hilMode () const { return _base_mode & MAV_MODE_FLAG_HIL_ENABLED; } Actuators* actuators () const { return _actuators; } @@ -675,23 +635,7 @@ class Vehicle : public FactGroup /// @return the maximum version unsigned maxProtoVersion () const { return _maxProtoVersion; } - enum CalibrationType { - CalibrationRadio, - CalibrationGyro, - CalibrationMag, - CalibrationAccel, - CalibrationLevel, - CalibrationEsc, - CalibrationCopyTrims, - CalibrationAPMCompassMot, - CalibrationAPMPressureAirspeed, - CalibrationAPMPreFlight, - CalibrationPX4Airspeed, - CalibrationPX4Pressure, - CalibrationAPMAccelSimple, - }; - - void startCalibration (CalibrationType calType); + void startCalibration (QGCMAVLink::CalibrationType calType); void stopCalibration (bool showError); void startUAVCANBusConfig(void);