Newer
Older
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef PX4FirmwarePlugin_H
#define PX4FirmwarePlugin_H
#include "FirmwarePlugin.h"
#include "PX4ParameterMetaData.h"
class PX4FirmwarePlugin : public FirmwarePlugin
{
Q_OBJECT
public:
Gus Grubba
committed
PX4FirmwarePlugin ();
QList<VehicleComponent*> componentsForVehicle(AutoPilotPlugin* vehicle) override;
QList<MAV_CMD> supportedMissionCommands(QGCMAVLink::VehicleClass_t vehicleClass) override;
AutoPilotPlugin* autopilotPlugin (Vehicle* vehicle) override;
bool isCapable (const Vehicle *vehicle, FirmwareCapabilities capabilities) override;
QStringList flightModes (Vehicle* vehicle) override;
QString flightMode (uint8_t base_mode, uint32_t custom_mode) const override;
bool setFlightMode (const QString& flightMode, uint8_t* base_mode, uint32_t* custom_mode) override;
void setGuidedMode (Vehicle* vehicle, bool guidedMode) override;
QString pauseFlightMode (void) const override { return _holdFlightMode; }
QString missionFlightMode (void) const override { return _missionFlightMode; }
QString rtlFlightMode (void) const override { return _rtlFlightMode; }
QString landFlightMode (void) const override { return _landingFlightMode; }
QString takeControlFlightMode (void) const override { return _manualFlightMode; }
QString followFlightMode (void) const override { return _followMeFlightMode; };
void pauseVehicle (Vehicle* vehicle) override;
void guidedModeLand (Vehicle* vehicle) override;
void guidedModeTakeoff (Vehicle* vehicle, double takeoffAltRel) override;
void guidedModeGotoLocation (Vehicle* vehicle, const QGeoCoordinate& gotoCoord) override;
void guidedModeChangeAltitude (Vehicle* vehicle, double altitudeRel) override;
double minimumTakeoffAltitude (Vehicle* vehicle) override;
void startMission (Vehicle* vehicle) override;
bool isGuidedMode (const Vehicle* vehicle) const override;
void initializeVehicle (Vehicle* vehicle) override;
bool sendHomePositionToVehicle (void) override;
QString missionCommandOverrides (QGCMAVLink::VehicleClass_t vehicleClass) const override;
FactMetaData* _getMetaDataForFact (QObject* parameterMetaData, const QString& name, FactMetaData::ValueType_t type, MAV_TYPE vehicleType) override;
QString _internalParameterMetaDataFile (Vehicle* vehicle) override { Q_UNUSED(vehicle); return QString(":/FirmwarePlugin/PX4/PX4ParameterFactMetaData.xml"); }
void _getParameterMetaDataVersionInfo(const QString& metaDataFile, int& majorVersion, int& minorVersion) override;
QObject* _loadParameterMetaData (const QString& metaDataFile) final;
bool adjustIncomingMavlinkMessage (Vehicle* vehicle, mavlink_message_t* message) override;
QString offlineEditingParamFile (Vehicle* vehicle) override { Q_UNUSED(vehicle); return QStringLiteral(":/FirmwarePlugin/PX4/PX4.OfflineEditing.params"); }
QString brandImageIndoor (const Vehicle* vehicle) const override { Q_UNUSED(vehicle); return QStringLiteral("/qmlimages/PX4/BrandImage"); }
QString brandImageOutdoor (const Vehicle* vehicle) const override { Q_UNUSED(vehicle); return QStringLiteral("/qmlimages/PX4/BrandImage"); }
QString autoDisarmParameter (Vehicle* vehicle) override { Q_UNUSED(vehicle); return QStringLiteral("COM_DISARM_LAND"); }
uint32_t highLatencyCustomModeTo32Bits (uint16_t hlCustomMode) override;
Gus Grubba
committed
bool supportsNegativeThrust (Vehicle *vehicle) override;
uint8_t main_mode;
uint8_t sub_mode;
const QString* name; ///< Name for flight mode
bool canBeSet; ///< true: Vehicle can be set to this flight mode
bool fixedWing; /// fixed wing compatible
bool multiRotor; /// multi rotor compatible
} FlightModeInfo_t;
QList<FlightModeInfo_t> _flightModeInfoList;
// Use these constants to set flight modes using setFlightMode method. Don't use hardcoded string names since the
// names may change.
// If plugin superclass wants to change a mode name, then set a new name for the flight mode in the superclass constructor
QString _manualFlightMode;
QString _acroFlightMode;
QString _stabilizedFlightMode;
QString _rattitudeFlightMode;
QString _altCtlFlightMode;
QString _posCtlFlightMode;
QString _offboardFlightMode;
QString _readyFlightMode;
QString _takeoffFlightMode;
QString _holdFlightMode;
QString _missionFlightMode;
QString _rtlFlightMode;
QString _landingFlightMode;
QString _rtgsFlightMode;
QString _followMeFlightMode;
QString _simpleFlightMode;
private slots:
void _mavCommandResult(int vehicleId, int component, int command, int result, bool noReponseFromVehicle);
private:
void _handleAutopilotVersion(Vehicle* vehicle, mavlink_message_t* message);
Willian Galvani
committed
QString _getLatestVersionFileUrl(Vehicle* vehicle) override;
QString _versionRegex() override;
// Any instance data here must be global to all vehicles
// Vehicle specific data should go into PX4FirmwarePluginInstanceData
};
class PX4FirmwarePluginInstanceData : public QObject
{
Q_OBJECT
public:
PX4FirmwarePluginInstanceData(QObject* parent = nullptr);
bool versionNotified; ///< true: user notified over version issue