Commit 9fa408e4 authored by Gus Grubba's avatar Gus Grubba

Initial support for PX4 rover vehicle.

parent 083dcf0a
......@@ -50,6 +50,11 @@ FirmwarePluginFactoryRegister* FirmwarePluginFactoryRegister::instance(void)
return _instance;
}
FirmwarePlugin::FirmwarePlugin(MAV_TYPE vehicleType)
{
_vehicleType = vehicleType;
}
AutoPilotPlugin* FirmwarePlugin::autopilotPlugin(Vehicle* vehicle)
{
return new GenericAutoPilotPlugin(vehicle, vehicle);
......
......@@ -49,6 +49,8 @@ public:
TakeoffVehicleCapability = 1 << 4, ///< Vehicle supports guided takeoff
} FirmwareCapabilities;
FirmwarePlugin(MAV_TYPE vehicleType = MAV_TYPE_GENERIC);
/// Maps from on parameter name to another
/// key: parameter name to translate from
/// value: mapped parameter name
......@@ -344,6 +346,9 @@ protected:
// Returns regex QString to extract version information from text
virtual QString _versionRegex() { return QString(); }
protected:
MAV_TYPE _vehicleType = MAV_TYPE_GENERIC;
private:
QVariantList _toolBarIndicatorList;
static QVariantList _cameraList; ///< Standard QGC camera list
......
......@@ -35,8 +35,9 @@ PX4FirmwarePluginInstanceData::PX4FirmwarePluginInstanceData(QObject* parent)
}
PX4FirmwarePlugin::PX4FirmwarePlugin(void)
: _manualFlightMode (tr("Manual"))
PX4FirmwarePlugin::PX4FirmwarePlugin(MAV_TYPE vehicleType)
: FirmwarePlugin(vehicleType)
, _manualFlightMode (tr("Manual"))
, _acroFlightMode (tr("Acro"))
, _stabilizedFlightMode (tr("Stabilized"))
, _rattitudeFlightMode (tr("Rattitude"))
......@@ -257,7 +258,7 @@ FactMetaData* PX4FirmwarePlugin::getMetaDataForFact(QObject* parameterMetaData,
qWarning() << "Internal error: pointer passed to PX4FirmwarePlugin::getMetaDataForFact not PX4ParameterMetaData";
}
return NULL;
return nullptr;
}
void PX4FirmwarePlugin::addMetaDataToFact(QObject* parameterMetaData, Fact* fact, MAV_TYPE vehicleType)
......@@ -306,22 +307,16 @@ QString PX4FirmwarePlugin::missionCommandOverrides(MAV_TYPE vehicleType) const
switch (vehicleType) {
case MAV_TYPE_GENERIC:
return QStringLiteral(":/json/PX4/MavCmdInfoCommon.json");
break;
case MAV_TYPE_FIXED_WING:
return QStringLiteral(":/json/PX4/MavCmdInfoFixedWing.json");
break;
case MAV_TYPE_QUADROTOR:
return QStringLiteral(":/json/PX4/MavCmdInfoMultiRotor.json");
break;
case MAV_TYPE_VTOL_QUADROTOR:
return QStringLiteral(":/json/PX4/MavCmdInfoVTOL.json");
break;
case MAV_TYPE_SUBMARINE:
return QStringLiteral(":/json/PX4/MavCmdInfoSub.json");
break;
case MAV_TYPE_GROUND_ROVER:
return QStringLiteral(":/json/PX4/MavCmdInfoRover.json");
break;
default:
qWarning() << "PX4FirmwarePlugin::missionCommandOverrides called with bad MAV_TYPE:" << vehicleType;
return QString();
......@@ -410,13 +405,14 @@ void PX4FirmwarePlugin::guidedModeTakeoff(Vehicle* vehicle, double takeoffAltRel
qDebug() << takeoffAltRel << takeoffAltRelFromVehicle << takeoffAltAMSL << vehicleAltitudeAMSL;
connect(vehicle, &Vehicle::mavCommandResult, this, &PX4FirmwarePlugin::_mavCommandResult);
vehicle->sendMavCommand(vehicle->defaultComponentId(),
MAV_CMD_NAV_TAKEOFF,
true, // show error is fails
-1, // No pitch requested
0, 0, // param 2-4 unused
NAN, NAN, NAN, // No yaw, lat, lon
takeoffAltAMSL); // AMSL altitude
vehicle->sendMavCommand(
vehicle->defaultComponentId(),
MAV_CMD_NAV_TAKEOFF,
true, // show error is fails
-1, // No pitch requested
0, 0, // param 2-4 unused
NAN, NAN, NAN, // No yaw, lat, lon
static_cast<float>(takeoffAltAMSL)); // AMSL altitude
}
void PX4FirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord)
......@@ -446,8 +442,8 @@ void PX4FirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoord
MAV_DO_REPOSITION_FLAGS_CHANGE_MODE,
0.0f,
NAN,
gotoCoord.latitude(),
gotoCoord.longitude(),
static_cast<float>(gotoCoord.latitude()),
static_cast<float>(gotoCoord.longitude()),
vehicle->altitudeAMSL()->rawValue().toFloat());
}
}
......@@ -475,7 +471,7 @@ void PX4FirmwarePlugin::guidedModeChangeAltitude(Vehicle* vehicle, double altitu
NAN,
NAN,
NAN,
vehicle->homePosition().altitude() + newAltRel);
static_cast<float>(vehicle->homePosition().altitude() + newAltRel));
}
void PX4FirmwarePlugin::startMission(Vehicle* vehicle)
......@@ -594,3 +590,8 @@ QString PX4FirmwarePlugin::_getLatestVersionFileUrl(Vehicle* vehicle){
QString PX4FirmwarePlugin::_versionRegex() {
return QStringLiteral("v([0-9,\\.]*) Stable");
}
bool PX4FirmwarePlugin::supportsNegativeThrust(void)
{
return _vehicleType == MAV_TYPE_GROUND_ROVER;
}
......@@ -23,8 +23,8 @@ class PX4FirmwarePlugin : public FirmwarePlugin
Q_OBJECT
public:
PX4FirmwarePlugin(void);
~PX4FirmwarePlugin();
PX4FirmwarePlugin (MAV_TYPE vehicleType);
~PX4FirmwarePlugin () override;
// Overrides from FirmwarePlugin
......@@ -69,6 +69,7 @@ public:
QString autoDisarmParameter (Vehicle* vehicle) override { Q_UNUSED(vehicle); return QStringLiteral("COM_DISARM_LAND"); }
uint32_t highLatencyCustomModeTo32Bits (uint16_t hlCustomMode) override;
bool supportsTerrainFrame (void) const override { return false; }
bool supportsNegativeThrust (void) override;
protected:
typedef struct {
......@@ -122,7 +123,7 @@ class PX4FirmwarePluginInstanceData : public QObject
Q_OBJECT
public:
PX4FirmwarePluginInstanceData(QObject* parent = NULL);
PX4FirmwarePluginInstanceData(QObject* parent = nullptr);
bool versionNotified; ///< true: user notified over version issue
};
......
......@@ -13,6 +13,7 @@
#include "PX4FirmwarePluginFactory.h"
#include "PX4/PX4FirmwarePlugin.h"
PX4FirmwarePluginFactory PX4FirmwarePluginFactory;
PX4FirmwarePluginFactory::PX4FirmwarePluginFactory(void)
......@@ -24,21 +25,17 @@ PX4FirmwarePluginFactory::PX4FirmwarePluginFactory(void)
QList<MAV_AUTOPILOT> PX4FirmwarePluginFactory::supportedFirmwareTypes(void) const
{
QList<MAV_AUTOPILOT> list;
list.append(MAV_AUTOPILOT_PX4);
return list;
}
FirmwarePlugin* PX4FirmwarePluginFactory::firmwarePluginForAutopilot(MAV_AUTOPILOT autopilotType, MAV_TYPE vehicleType)
{
Q_UNUSED(vehicleType);
if (autopilotType == MAV_AUTOPILOT_PX4) {
if (!_pluginInstance) {
_pluginInstance = new PX4FirmwarePlugin;
_pluginInstance = new PX4FirmwarePlugin(vehicleType);
}
return _pluginInstance;
}
return nullptr;
}
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