Commit e0baebfc authored by Don Gagne's avatar Don Gagne

Merge pull request #1987 from pritamghanghas/apm_mode_support

flight mode support for ArduPilot
parents e2d46469 232baa6a
...@@ -520,6 +520,8 @@ HEADERS+= \ ...@@ -520,6 +520,8 @@ HEADERS+= \
src/FirmwarePlugin/FirmwarePlugin.h \ src/FirmwarePlugin/FirmwarePlugin.h \
src/FirmwarePlugin/APM/APMFirmwarePlugin.h \ src/FirmwarePlugin/APM/APMFirmwarePlugin.h \
src/FirmwarePlugin/APM/ArduCopterFirmwarePlugin.h \ src/FirmwarePlugin/APM/ArduCopterFirmwarePlugin.h \
src/FirmwarePlugin/APM/ArduPlaneFirmwarePlugin.h \
src/FirmwarePlugin/APM/ArduRoverFirmwarePlugin.h \
src/FirmwarePlugin/Generic/GenericFirmwarePlugin.h \ src/FirmwarePlugin/Generic/GenericFirmwarePlugin.h \
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h \ src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h \
src/Vehicle/MultiVehicleManager.h \ src/Vehicle/MultiVehicleManager.h \
...@@ -557,6 +559,8 @@ SOURCES += \ ...@@ -557,6 +559,8 @@ SOURCES += \
src/AutoPilotPlugins/PX4/SensorsComponentController.cc \ src/AutoPilotPlugins/PX4/SensorsComponentController.cc \
src/FirmwarePlugin/APM/APMFirmwarePlugin.cc \ src/FirmwarePlugin/APM/APMFirmwarePlugin.cc \
src/FirmwarePlugin/APM/ArduCopterFirmwarePlugin.cc \ src/FirmwarePlugin/APM/ArduCopterFirmwarePlugin.cc \
src/FirmwarePlugin/APM/ArduPlaneFirmwarePlugin.cc \
src/FirmwarePlugin/APM/ArduRoverFirmwarePlugin.cc \
src/FirmwarePlugin/FirmwarePluginManager.cc \ src/FirmwarePlugin/FirmwarePluginManager.cc \
src/FirmwarePlugin/Generic/GenericFirmwarePlugin.cc \ src/FirmwarePlugin/Generic/GenericFirmwarePlugin.cc \
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc \ src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc \
......
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
#include "Generic/GenericFirmwarePlugin.h" #include "Generic/GenericFirmwarePlugin.h"
#include "QGCMAVLink.h" #include "QGCMAVLink.h"
#include <QDebug>
QGC_LOGGING_CATEGORY(APMFirmwarePluginLog, "APMFirmwarePluginLog") QGC_LOGGING_CATEGORY(APMFirmwarePluginLog, "APMFirmwarePluginLog")
static const QRegExp APM_COPTER_REXP("^(ArduCopter|APM:Copter)"); static const QRegExp APM_COPTER_REXP("^(ArduCopter|APM:Copter)");
...@@ -115,6 +113,31 @@ void APMFirmwareVersion::_parseVersion(const QString &versionText) ...@@ -115,6 +113,31 @@ void APMFirmwareVersion::_parseVersion(const QString &versionText)
_patch = capturedTexts[4].toInt(); _patch = capturedTexts[4].toInt();
} }
/*
* @brief APMCustomMode encapsulates the custom modes for APM
*/
APMCustomMode::APMCustomMode(uint32_t mode, bool settable) :
_mode(mode),
_settable(settable)
{
}
void APMCustomMode::setEnumToStringMapping(const QMap<uint32_t, QString>& enumToString)
{
_enumToString = enumToString;
}
QString APMCustomMode::modeString() const
{
QString mode = _enumToString.value(modeAsInt());
if (mode.isEmpty()) {
mode = "mode" + QString::number(modeAsInt());
}
return mode;
}
APMFirmwarePlugin::APMFirmwarePlugin(QObject* parent) : APMFirmwarePlugin::APMFirmwarePlugin(QObject* parent) :
FirmwarePlugin(parent) FirmwarePlugin(parent)
{ {
...@@ -123,11 +146,7 @@ APMFirmwarePlugin::APMFirmwarePlugin(QObject* parent) : ...@@ -123,11 +146,7 @@ APMFirmwarePlugin::APMFirmwarePlugin(QObject* parent) :
bool APMFirmwarePlugin::isCapable(FirmwareCapabilities capabilities) bool APMFirmwarePlugin::isCapable(FirmwareCapabilities capabilities)
{ {
Q_UNUSED(capabilities); return (capabilities & (MavCmdPreflightStorageCapability | SetFlightModeCapability)) == capabilities;
// FIXME: No capabilitis yet supported
return false;
} }
QList<VehicleComponent*> APMFirmwarePlugin::componentsForVehicle(AutoPilotPlugin* vehicle) QList<VehicleComponent*> APMFirmwarePlugin::componentsForVehicle(AutoPilotPlugin* vehicle)
...@@ -139,28 +158,50 @@ QList<VehicleComponent*> APMFirmwarePlugin::componentsForVehicle(AutoPilotPlugin ...@@ -139,28 +158,50 @@ QList<VehicleComponent*> APMFirmwarePlugin::componentsForVehicle(AutoPilotPlugin
QStringList APMFirmwarePlugin::flightModes(void) QStringList APMFirmwarePlugin::flightModes(void)
{ {
// FIXME: NYI QStringList flightModesList;
foreach (const APMCustomMode& customMode, _supportedModes) {
qWarning() << "APMFirmwarePlugin::flightModes not supported"; if (customMode.canBeSet()) {
flightModesList << customMode.modeString();
return QStringList(); }
}
return flightModesList;
} }
QString APMFirmwarePlugin::flightMode(uint8_t base_mode, uint32_t custom_mode) QString APMFirmwarePlugin::flightMode(uint8_t base_mode, uint32_t custom_mode)
{ {
// FIXME: Nothing more than generic support yet QString flightMode = "Unknown";
return GenericFirmwarePlugin::instance()->flightMode(base_mode, custom_mode);
if (base_mode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED) {
foreach (const APMCustomMode& customMode, _supportedModes) {
if (customMode.modeAsInt() == custom_mode) {
flightMode = customMode.modeString();
}
}
}
return flightMode;
} }
bool APMFirmwarePlugin::setFlightMode(const QString& flightMode, uint8_t* base_mode, uint32_t* custom_mode) bool APMFirmwarePlugin::setFlightMode(const QString& flightMode, uint8_t* base_mode, uint32_t* custom_mode)
{ {
Q_UNUSED(flightMode); *base_mode = 0;
Q_UNUSED(base_mode); *custom_mode = 0;
Q_UNUSED(custom_mode);
qWarning() << "APMFirmwarePlugin::setFlightMode called on base class, not supported"; bool found = false;
return false; foreach(const APMCustomMode& mode, _supportedModes) {
if (flightMode.compare(mode.modeString(), Qt::CaseInsensitive) == 0) {
*base_mode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED;
*custom_mode = mode.modeAsInt();
found = true;
break;
}
}
if (!found) {
qCWarning(APMFirmwarePluginLog) << "Unknown flight Mode" << flightMode;
}
return found;
} }
int APMFirmwarePlugin::manualControlReservedButtonCount(void) int APMFirmwarePlugin::manualControlReservedButtonCount(void)
...@@ -332,3 +373,8 @@ void APMFirmwarePlugin::initializeVehicle(Vehicle* vehicle) ...@@ -332,3 +373,8 @@ void APMFirmwarePlugin::initializeVehicle(Vehicle* vehicle)
vehicle->requestDataStream(MAV_DATA_STREAM_EXTRA2, 10); vehicle->requestDataStream(MAV_DATA_STREAM_EXTRA2, 10);
vehicle->requestDataStream(MAV_DATA_STREAM_EXTRA3, 3); vehicle->requestDataStream(MAV_DATA_STREAM_EXTRA3, 3);
} }
void APMFirmwarePlugin::setSupportedModes(QList<APMCustomMode> supportedModes)
{
_supportedModes = supportedModes;
}
...@@ -55,6 +55,23 @@ private: ...@@ -55,6 +55,23 @@ private:
int _patch; int _patch;
}; };
class APMCustomMode
{
public:
APMCustomMode(uint32_t mode, bool settable);
uint32_t modeAsInt() const { return _mode; }
bool canBeSet() const { return _settable; }
QString modeString() const;
protected:
void setEnumToStringMapping(const QMap<uint32_t,QString>& enumToString);
private:
uint32_t _mode;
bool _settable;
QMap<uint32_t,QString> _enumToString;
};
/// This is the base class for all stack specific APM firmware plugins /// This is the base class for all stack specific APM firmware plugins
class APMFirmwarePlugin : public FirmwarePlugin class APMFirmwarePlugin : public FirmwarePlugin
{ {
...@@ -74,6 +91,7 @@ public: ...@@ -74,6 +91,7 @@ public:
protected: protected:
/// All access to singleton is through stack specific implementation /// All access to singleton is through stack specific implementation
APMFirmwarePlugin(QObject* parent = NULL); APMFirmwarePlugin(QObject* parent = NULL);
void setSupportedModes(QList<APMCustomMode> supportedModes);
private: private:
void _adjustSeverity(mavlink_message_t* message) const; void _adjustSeverity(mavlink_message_t* message) const;
...@@ -81,6 +99,7 @@ private: ...@@ -81,6 +99,7 @@ private:
APMFirmwareVersion _firmwareVersion; APMFirmwareVersion _firmwareVersion;
bool _textSeverityAdjustmentNeeded; bool _textSeverityAdjustmentNeeded;
QList<APMCustomMode> _supportedModes;
}; };
......
...@@ -26,56 +26,53 @@ ...@@ -26,56 +26,53 @@
#include "ArduCopterFirmwarePlugin.h" #include "ArduCopterFirmwarePlugin.h"
#include "Generic/GenericFirmwarePlugin.h" #include "Generic/GenericFirmwarePlugin.h"
#include "QGCMAVLink.h"
#include <QDebug>
IMPLEMENT_QGC_SINGLETON(ArduCopterFirmwarePlugin, ArduCopterFirmwarePlugin) IMPLEMENT_QGC_SINGLETON(ArduCopterFirmwarePlugin, ArduCopterFirmwarePlugin)
ArduCopterFirmwarePlugin::ArduCopterFirmwarePlugin(QObject* parent) : APMCopterMode::APMCopterMode(uint32_t mode, bool settable) : APMCustomMode(mode, settable)
APMFirmwarePlugin(parent)
{
}
bool ArduCopterFirmwarePlugin::isCapable(FirmwareCapabilities capabilities)
{ {
Q_UNUSED(capabilities); QMap<uint32_t,QString> enumToString;
enumToString.insert(STABILIZE, "Stabilize");
// FIXME: No capabilitis yet supported enumToString.insert(ACRO, "Acro");
enumToString.insert(ALT_HOLD, "Alt Hold");
return false; enumToString.insert(AUTO, "Auto");
} enumToString.insert(GUIDED, "Guided");
enumToString.insert(LOITER, "Loiter");
QList<VehicleComponent*> ArduCopterFirmwarePlugin::componentsForVehicle(AutoPilotPlugin* vehicle) enumToString.insert(RTL, "RTL");
{ enumToString.insert(CIRCLE, "Circle");
Q_UNUSED(vehicle); enumToString.insert(POSITION, "Position");
enumToString.insert(LAND, "Land");
return QList<VehicleComponent*>(); enumToString.insert(OF_LOITER, "OF Loiter");
enumToString.insert(DRIFT, "Drift");
enumToString.insert(SPORT, "Sport");
enumToString.insert(FLIP, "Flip");
enumToString.insert(AUTOTUNE, "Autotune");
enumToString.insert(POS_HOLD, "Pos Hold");
enumToString.insert(BRAKE, "Brake");
setEnumToStringMapping(enumToString);
} }
QStringList ArduCopterFirmwarePlugin::flightModes(void) ArduCopterFirmwarePlugin::ArduCopterFirmwarePlugin(QObject* parent) :
{ APMFirmwarePlugin(parent)
// FIXME: NYI
qWarning() << "ArduCopterFirmwarePlugin::flightModes not supported";
return QStringList();
}
QString ArduCopterFirmwarePlugin::flightMode(uint8_t base_mode, uint32_t custom_mode)
{
// FIXME: Nothing more than generic support yet
return GenericFirmwarePlugin::instance()->flightMode(base_mode, custom_mode);
}
bool ArduCopterFirmwarePlugin::setFlightMode(const QString& flightMode, uint8_t* base_mode, uint32_t* custom_mode)
{ {
Q_UNUSED(flightMode); QList<APMCustomMode> supportedFlightModes;
Q_UNUSED(base_mode); supportedFlightModes << APMCopterMode(APMCopterMode::STABILIZE ,true);
Q_UNUSED(custom_mode); supportedFlightModes << APMCopterMode(APMCopterMode::ACRO ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::ALT_HOLD ,true);
qWarning() << "ArduCopterFirmwarePlugin::setFlightMode called on base class, not supported"; supportedFlightModes << APMCopterMode(APMCopterMode::AUTO ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::GUIDED ,true);
return false; supportedFlightModes << APMCopterMode(APMCopterMode::LOITER ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::RTL ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::CIRCLE ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::POSITION ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::LAND ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::OF_LOITER ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::DRIFT ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::SPORT ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::FLIP ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::AUTOTUNE ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::POS_HOLD ,true);
supportedFlightModes << APMCopterMode(APMCopterMode::BRAKE ,true);
setSupportedModes(supportedFlightModes);
} }
...@@ -29,6 +29,35 @@ ...@@ -29,6 +29,35 @@
#include "APMFirmwarePlugin.h" #include "APMFirmwarePlugin.h"
class APMCopterMode : public APMCustomMode
{
public:
enum Mode {
STABILIZE = 0, // hold level position
ACRO = 1, // rate control
ALT_HOLD = 2, // AUTO control
AUTO = 3, // AUTO control
GUIDED = 4, // AUTO control
LOITER = 5, // Hold a single location
RTL = 6, // AUTO control
CIRCLE = 7, // AUTO control
POSITION = 8, // AUTO control
LAND = 9, // AUTO control
OF_LOITER = 10, // Hold a single location using optical flow
// sensor
DRIFT = 11, // Drift 'Car Like' mode
RESERVED_12 = 12, // RESERVED FOR FUTURE USE
SPORT = 13, // [TODO] Verify this is correct.
FLIP = 14,
AUTOTUNE = 15,
POS_HOLD = 16, // HYBRID LOITER.
BRAKE = 17
};
static const int modeCount = 18;
APMCopterMode(uint32_t mode, bool settable);
};
class ArduCopterFirmwarePlugin : public APMFirmwarePlugin class ArduCopterFirmwarePlugin : public APMFirmwarePlugin
{ {
Q_OBJECT Q_OBJECT
...@@ -36,12 +65,6 @@ class ArduCopterFirmwarePlugin : public APMFirmwarePlugin ...@@ -36,12 +65,6 @@ class ArduCopterFirmwarePlugin : public APMFirmwarePlugin
DECLARE_QGC_SINGLETON(ArduCopterFirmwarePlugin, ArduCopterFirmwarePlugin) DECLARE_QGC_SINGLETON(ArduCopterFirmwarePlugin, ArduCopterFirmwarePlugin)
public: public:
// Overrides from FirmwarePlugin
virtual bool isCapable(FirmwareCapabilities capabilities);
virtual QList<VehicleComponent*> componentsForVehicle(AutoPilotPlugin* vehicle);
virtual QStringList flightModes(void);
virtual QString flightMode(uint8_t base_mode, uint32_t custom_mode);
virtual bool setFlightMode(const QString& flightMode, uint8_t* base_mode, uint32_t* custom_mode);
protected: protected:
/// All access to singleton is through instance() /// All access to singleton is through instance()
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Pritam Ghanghas <pritam.ghanghas@gmail.com>
#include "ArduPlaneFirmwarePlugin.h"
#include "Generic/GenericFirmwarePlugin.h"
IMPLEMENT_QGC_SINGLETON(ArduPlaneFirmwarePlugin, ArduPlaneFirmwarePlugin)
APMPlaneMode::APMPlaneMode(uint32_t mode, bool settable) : APMCustomMode(mode, settable)
{
QMap<uint32_t,QString> enumToString;
enumToString.insert(MANUAL, "Manual");
enumToString.insert(CIRCLE, "Circle");
enumToString.insert(STABILIZE, "Stabilize");
enumToString.insert(TRAINING, "Training");
enumToString.insert(ACRO, "Acro");
enumToString.insert(FLY_BY_WIRE_A, "FWB A");
enumToString.insert(FLY_BY_WIRE_B, "FWB B");
enumToString.insert(CRUISE, "Cruise");
enumToString.insert(AUTOTUNE, "Autotune");
enumToString.insert(AUTO, "Auto");
enumToString.insert(RTL, "RTL");
enumToString.insert(LOITER, "Loiter");
enumToString.insert(GUIDED, "Guided");
enumToString.insert(INITIALIZING, "Initializing");
setEnumToStringMapping(enumToString);
}
ArduPlaneFirmwarePlugin::ArduPlaneFirmwarePlugin(QObject* parent) :
APMFirmwarePlugin(parent)
{
QList<APMCustomMode> supportedFlightModes;
supportedFlightModes << APMPlaneMode(APMPlaneMode::MANUAL ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::CIRCLE ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::STABILIZE ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::TRAINING ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::ACRO ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::FLY_BY_WIRE_A ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::FLY_BY_WIRE_B ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::CRUISE ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::AUTOTUNE ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::AUTO ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::RTL ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::LOITER ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::GUIDED ,true);
supportedFlightModes << APMPlaneMode(APMPlaneMode::INITIALIZING ,false);
setSupportedModes(supportedFlightModes);
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Pritam Ghanghas <pritam.ghanghas@gmail.com>
#ifndef ArduPlaneFirmwarePlugin_H
#define ArduPlaneFirmwarePlugin_H
#include "APMFirmwarePlugin.h"
class APMPlaneMode: public APMCustomMode
{
public:
enum Mode {
MANUAL = 0,
CIRCLE = 1,
STABILIZE = 2,
TRAINING = 3,
ACRO = 4,
FLY_BY_WIRE_A = 5,
FLY_BY_WIRE_B = 6,
CRUISE = 7,
AUTOTUNE = 8,
RESERVED_9 = 9, // RESERVED FOR FUTURE USE
AUTO = 10,
RTL = 11,
LOITER = 12,
RESERVED_13 = 13, // RESERVED FOR FUTURE USE
RESERVED_14 = 14, // RESERVED FOR FUTURE USE
GUIDED = 15,
INITIALIZING = 16
};
static const int modeCount = 17;
APMPlaneMode(uint32_t mode, bool settable);
};
class ArduPlaneFirmwarePlugin : public APMFirmwarePlugin
{
Q_OBJECT
DECLARE_QGC_SINGLETON(ArduPlaneFirmwarePlugin, ArduPlaneFirmwarePlugin)
public:
protected:
/// All access to singleton is through instance()
ArduPlaneFirmwarePlugin(QObject* parent = NULL);
private:
};
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Pritam Ghanghas <pritam.ghanghas@gmail.com>
#include "ArduRoverFirmwarePlugin.h"
#include "Generic/GenericFirmwarePlugin.h"
IMPLEMENT_QGC_SINGLETON(ArduRoverFirmwarePlugin, ArduRoverFirmwarePlugin)
APMRoverMode::APMRoverMode(uint32_t mode, bool settable) : APMCustomMode(mode, settable)
{
QMap<uint32_t,QString> enumToString;
enumToString.insert(MANUAL, "Manual");
enumToString.insert(LEARNING, "Learning");
enumToString.insert(STEERING, "Steering");
enumToString.insert(HOLD, "Hold");
enumToString.insert(AUTO, "Auto");
enumToString.insert(RTL, "RTL");
enumToString.insert(GUIDED, "Guided");
enumToString.insert(INITIALIZING, "Initializing");
setEnumToStringMapping(enumToString);
}
ArduRoverFirmwarePlugin::ArduRoverFirmwarePlugin(QObject* parent) :
APMFirmwarePlugin(parent)
{
QList<APMCustomMode> supportedFlightModes;
supportedFlightModes << APMRoverMode(APMRoverMode::MANUAL ,true);
supportedFlightModes << APMRoverMode(APMRoverMode::LEARNING ,true);
supportedFlightModes << APMRoverMode(APMRoverMode::STEERING ,true);
supportedFlightModes << APMRoverMode(APMRoverMode::HOLD ,true);
supportedFlightModes << APMRoverMode(APMRoverMode::AUTO ,true);
supportedFlightModes << APMRoverMode(APMRoverMode::RTL ,true);
supportedFlightModes << APMRoverMode(APMRoverMode::GUIDED ,true);
supportedFlightModes << APMRoverMode(APMRoverMode::INITIALIZING ,false);
setSupportedModes(supportedFlightModes);
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Pritam Ghanghas <pritam.ghanghas@gmail.com>
#ifndef ArduRoverFirmwarePlugin_H
#define ArduRoverFirmwarePlugin_H
#include "APMFirmwarePlugin.h"
class APMRoverMode : public APMCustomMode
{
public:
enum Mode {
MANUAL = 0,
RESERVED_1 = 1, // RESERVED FOR FUTURE USE
LEARNING = 2,
STEERING = 3,
HOLD = 4,
RESERVED_5 = 5, // RESERVED FOR FUTURE USE
RESERVED_6 = 6, // RESERVED FOR FUTURE USE
RESERVED_7 = 7, // RESERVED FOR FUTURE USE
RESERVED_8 = 8, // RESERVED FOR FUTURE USE
RESERVED_9 = 9, // RESERVED FOR FUTURE USE
AUTO = 10,
RTL = 11,
RESERVED_12 = 12, // RESERVED FOR FUTURE USE
RESERVED_13 = 13, // RESERVED FOR FUTURE USE
RESERVED_14 = 14, // RESERVED FOR FUTURE USE
GUIDED = 15,
INITIALIZING = 16,
};
static const int modeCount = 17;
APMRoverMode(uint32_t mode, bool settable);
};
class ArduRoverFirmwarePlugin : public APMFirmwarePlugin
{
Q_OBJECT
DECLARE_QGC_SINGLETON(ArduRoverFirmwarePlugin, ArduRoverFirmwarePlugin)
public:
protected:
/// All access to singleton is through instance()
ArduRoverFirmwarePlugin(QObject* parent = NULL);
private:
};
#endif
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "FirmwarePluginManager.h" #include "FirmwarePluginManager.h"
#include "Generic/GenericFirmwarePlugin.h" #include "Generic/GenericFirmwarePlugin.h"
#include "APM/ArduCopterFirmwarePlugin.h" #include "APM/ArduCopterFirmwarePlugin.h"
#include "APM/ArduPlaneFirmwarePlugin.h"
#include "APM/ArduRoverFirmwarePlugin.h"
#include "PX4/PX4FirmwarePlugin.h" #include "PX4/PX4FirmwarePlugin.h"
IMPLEMENT_QGC_SINGLETON(FirmwarePluginManager, FirmwarePluginManager) IMPLEMENT_QGC_SINGLETON(FirmwarePluginManager, FirmwarePluginManager)
...@@ -51,22 +53,24 @@ FirmwarePlugin* FirmwarePluginManager::firmwarePluginForAutopilot(MAV_AUTOPILOT ...@@ -51,22 +53,24 @@ FirmwarePlugin* FirmwarePluginManager::firmwarePluginForAutopilot(MAV_AUTOPILOT
case MAV_TYPE_HEXAROTOR: case MAV_TYPE_HEXAROTOR:
case MAV_TYPE_OCTOROTOR: case MAV_TYPE_OCTOROTOR:
case MAV_TYPE_TRICOPTER: case MAV_TYPE_TRICOPTER:
case MAV_TYPE_COAXIAL:
case MAV_TYPE_HELICOPTER:
return ArduCopterFirmwarePlugin::instance(); return ArduCopterFirmwarePlugin::instance();
break; break;
// FIXME: The remainder of these need to be correctly assigned and new plugin classes created as needed.
// Once done, the unused cases can be removed and just the fall back default: left
case MAV_TYPE_FIXED_WING: case MAV_TYPE_FIXED_WING:
return ArduPlaneFirmwarePlugin::instance();
break;
case MAV_TYPE_GROUND_ROVER:
case MAV_TYPE_SURFACE_BOAT:
case MAV_TYPE_SUBMARINE:
return ArduRoverFirmwarePlugin::instance();
break;
case MAV_TYPE_GENERIC: case MAV_TYPE_GENERIC:
case MAV_TYPE_COAXIAL:
case MAV_TYPE_HELICOPTER:
case MAV_TYPE_ANTENNA_TRACKER: case MAV_TYPE_ANTENNA_TRACKER:
case MAV_TYPE_GCS: case MAV_TYPE_GCS:
case MAV_TYPE_AIRSHIP: case MAV_TYPE_AIRSHIP:
case MAV_TYPE_FREE_BALLOON: case MAV_TYPE_FREE_BALLOON:
case MAV_TYPE_ROCKET: case MAV_TYPE_ROCKET:
case MAV_TYPE_GROUND_ROVER:
case MAV_TYPE_SURFACE_BOAT:
case MAV_TYPE_SUBMARINE:
case MAV_TYPE_FLAPPING_WING: case MAV_TYPE_FLAPPING_WING:
case MAV_TYPE_KITE: case MAV_TYPE_KITE:
case MAV_TYPE_ONBOARD_CONTROLLER: case MAV_TYPE_ONBOARD_CONTROLLER:
......
...@@ -74,6 +74,8 @@ ...@@ -74,6 +74,8 @@
#include "MultiVehicleManager.h" #include "MultiVehicleManager.h"
#include "Generic/GenericFirmwarePlugin.h" #include "Generic/GenericFirmwarePlugin.h"
#include "APM/ArduCopterFirmwarePlugin.h" #include "APM/ArduCopterFirmwarePlugin.h"
#include "APM/ArduPlaneFirmwarePlugin.h"
#include "APM/ArduRoverFirmwarePlugin.h"
#include "PX4/PX4FirmwarePlugin.h" #include "PX4/PX4FirmwarePlugin.h"
#include "Vehicle.h" #include "Vehicle.h"
#include "MavlinkQmlSingleton.h" #include "MavlinkQmlSingleton.h"
...@@ -596,6 +598,8 @@ void QGCApplication::_createSingletons(void) ...@@ -596,6 +598,8 @@ void QGCApplication::_createSingletons(void)
// No dependencies // No dependencies
firmwarePlugin = PX4FirmwarePlugin::_createSingleton(); firmwarePlugin = PX4FirmwarePlugin::_createSingleton();
firmwarePlugin = ArduCopterFirmwarePlugin::_createSingleton(); firmwarePlugin = ArduCopterFirmwarePlugin::_createSingleton();
firmwarePlugin = ArduPlaneFirmwarePlugin::_createSingleton();
firmwarePlugin = ArduRoverFirmwarePlugin::_createSingleton();
// No dependencies // No dependencies
FirmwarePluginManager* firmwarePluginManager = FirmwarePluginManager::_createSingleton(); FirmwarePluginManager* firmwarePluginManager = FirmwarePluginManager::_createSingleton();
...@@ -673,6 +677,8 @@ void QGCApplication::_destroySingletons(void) ...@@ -673,6 +677,8 @@ void QGCApplication::_destroySingletons(void)
GenericFirmwarePlugin::_deleteSingleton(); GenericFirmwarePlugin::_deleteSingleton();
PX4FirmwarePlugin::_deleteSingleton(); PX4FirmwarePlugin::_deleteSingleton();
ArduCopterFirmwarePlugin::_deleteSingleton(); ArduCopterFirmwarePlugin::_deleteSingleton();
ArduPlaneFirmwarePlugin::_deleteSingleton();
ArduRoverFirmwarePlugin::_deleteSingleton();
HomePositionManager::_deleteSingleton(); HomePositionManager::_deleteSingleton();
FlightMapSettings::_deleteSingleton(); FlightMapSettings::_deleteSingleton();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment