/**************************************************************************** * * (c) 2009-2016 QGROUNDCONTROL PROJECT * * QGroundControl is licensed according to the terms in the file * COPYING.md in the root of the source code directory. * ****************************************************************************/ #include "FirmwarePlugin.h" #include "QGCApplication.h" #include "Generic/GenericAutoPilotPlugin.h" #include static FirmwarePluginFactoryRegister* _instance = NULL; const char* guided_mode_not_supported_by_vehicle = "Guided mode not supported by Vehicle."; const char* FirmwarePlugin::px4FollowMeFlightMode = "Follow Me"; FirmwarePluginFactory::FirmwarePluginFactory(void) { FirmwarePluginFactoryRegister::instance()->registerPluginFactory(this); } FirmwarePluginFactoryRegister* FirmwarePluginFactoryRegister::instance(void) { if (!_instance) { _instance = new FirmwarePluginFactoryRegister; } return _instance; } AutoPilotPlugin* FirmwarePlugin::autopilotPlugin(Vehicle* vehicle) { return new GenericAutoPilotPlugin(vehicle, vehicle); } bool FirmwarePlugin::isCapable(const Vehicle *vehicle, FirmwareCapabilities capabilities) { Q_UNUSED(vehicle); Q_UNUSED(capabilities); return false; } QList FirmwarePlugin::componentsForVehicle(AutoPilotPlugin* vehicle) { Q_UNUSED(vehicle); return QList(); } QString FirmwarePlugin::flightMode(uint8_t base_mode, uint32_t custom_mode) const { QString flightMode; struct Bit2Name { uint8_t baseModeBit; const char* name; }; static const struct Bit2Name rgBit2Name[] = { { MAV_MODE_FLAG_MANUAL_INPUT_ENABLED, "Manual" }, { MAV_MODE_FLAG_STABILIZE_ENABLED, "Stabilize" }, { MAV_MODE_FLAG_GUIDED_ENABLED, "Guided" }, { MAV_MODE_FLAG_AUTO_ENABLED, "Auto" }, { MAV_MODE_FLAG_TEST_ENABLED, "Test" }, }; Q_UNUSED(custom_mode); if (base_mode == 0) { flightMode = "PreFlight"; } else if (base_mode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED) { flightMode = QString("Custom:0x%1").arg(custom_mode, 0, 16); } else { for (size_t i=0; i FirmwarePlugin::supportedMissionCommands(void) { // Generic supports all commands return QList(); } QString FirmwarePlugin::missionCommandOverrides(MAV_TYPE vehicleType) const { switch (vehicleType) { case MAV_TYPE_GENERIC: return QStringLiteral(":/json/MavCmdInfoCommon.json"); break; case MAV_TYPE_FIXED_WING: return QStringLiteral(":/json/MavCmdInfoFixedWing.json"); break; case MAV_TYPE_QUADROTOR: return QStringLiteral(":/json/MavCmdInfoMultiRotor.json"); break; case MAV_TYPE_VTOL_QUADROTOR: return QStringLiteral(":/json/MavCmdInfoVTOL.json"); break; case MAV_TYPE_SUBMARINE: return QStringLiteral(":/json/MavCmdInfoSub.json"); break; case MAV_TYPE_GROUND_ROVER: return QStringLiteral(":/json/MavCmdInfoRover.json"); break; default: qWarning() << "FirmwarePlugin::missionCommandOverrides called with bad MAV_TYPE:" << vehicleType; return QString(); } } void FirmwarePlugin::getParameterMetaDataVersionInfo(const QString& metaDataFile, int& majorVersion, int& minorVersion) { Q_UNUSED(metaDataFile); majorVersion = -1; minorVersion = -1; } bool FirmwarePlugin::isGuidedMode(const Vehicle* vehicle) const { // Not supported by generic vehicle Q_UNUSED(vehicle); return false; } void FirmwarePlugin::setGuidedMode(Vehicle* vehicle, bool guidedMode) { Q_UNUSED(vehicle); Q_UNUSED(guidedMode); qgcApp()->showMessage(guided_mode_not_supported_by_vehicle); } bool FirmwarePlugin::isPaused(const Vehicle* vehicle) const { // Not supported by generic vehicle Q_UNUSED(vehicle); return false; } void FirmwarePlugin::pauseVehicle(Vehicle* vehicle) { // Not supported by generic vehicle Q_UNUSED(vehicle); qgcApp()->showMessage(guided_mode_not_supported_by_vehicle); } void FirmwarePlugin::guidedModeRTL(Vehicle* vehicle) { // Not supported by generic vehicle Q_UNUSED(vehicle); qgcApp()->showMessage(guided_mode_not_supported_by_vehicle); } void FirmwarePlugin::guidedModeLand(Vehicle* vehicle) { // Not supported by generic vehicle Q_UNUSED(vehicle); qgcApp()->showMessage(guided_mode_not_supported_by_vehicle); } void FirmwarePlugin::guidedModeTakeoff(Vehicle* vehicle, double altitudeRel) { // Not supported by generic vehicle Q_UNUSED(vehicle); Q_UNUSED(altitudeRel); qgcApp()->showMessage(guided_mode_not_supported_by_vehicle); } void FirmwarePlugin::guidedModeOrbit(Vehicle* /*vehicle*/, const QGeoCoordinate& /*centerCoord*/, double /*radius*/, double /*velocity*/, double /*altitude*/) { // Not supported by generic vehicle qgcApp()->showMessage(guided_mode_not_supported_by_vehicle); } void FirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord) { // Not supported by generic vehicle Q_UNUSED(vehicle); Q_UNUSED(gotoCoord); qgcApp()->showMessage(guided_mode_not_supported_by_vehicle); } void FirmwarePlugin::guidedModeChangeAltitude(Vehicle* vehicle, double altitudeRel) { // Not supported by generic vehicle Q_UNUSED(vehicle); Q_UNUSED(altitudeRel); qgcApp()->showMessage(guided_mode_not_supported_by_vehicle); } const FirmwarePlugin::remapParamNameMajorVersionMap_t& FirmwarePlugin::paramNameRemapMajorVersionMap(void) const { static const remapParamNameMajorVersionMap_t remap; return remap; } int FirmwarePlugin::remapParamNameHigestMinorVersionNumber(int majorVersionNumber) const { Q_UNUSED(majorVersionNumber); return 0; } QString FirmwarePlugin::missionFlightMode(void) { return QString(); } QString FirmwarePlugin::rtlFlightMode(void) { return QString(); } QString FirmwarePlugin::takeControlFlightMode(void) { return QString(); }