Commit 5b3311a3 authored by Gus Grubba's avatar Gus Grubba

Instead of trying to keep a vehicle type within the FirmwarePlugin instance,...

Instead of trying to keep a vehicle type within the FirmwarePlugin instance, pass the vehicle to the function so it can query the type that way.
parent ad5d6b68
......@@ -74,7 +74,7 @@ void ArduRoverFirmwarePlugin::guidedModeChangeAltitude(Vehicle* vehicle, double
qgcApp()->showMessage(QStringLiteral("Change altitude not supported."));
}
bool ArduRoverFirmwarePlugin::supportsNegativeThrust(void)
bool ArduRoverFirmwarePlugin::supportsNegativeThrust(Vehicle* /*vehicle*/)
{
return true;
}
......@@ -50,7 +50,7 @@ public:
void guidedModeChangeAltitude (Vehicle* vehicle, double altitudeChange) final;
int remapParamNameHigestMinorVersionNumber (int majorVersionNumber) const final;
const FirmwarePlugin::remapParamNameMajorVersionMap_t& paramNameRemapMajorVersionMap(void) const final { return _remapParamName; }
bool supportsNegativeThrust (void) final;
bool supportsNegativeThrust (Vehicle *) final;
bool supportsSmartRTL (void) const override { return true; }
QString offlineEditingParamFile (Vehicle* vehicle) override { Q_UNUSED(vehicle); return QStringLiteral(":/FirmwarePlugin/APM/Rover.OfflineEditing.params"); }
......
......@@ -50,11 +50,6 @@ FirmwarePluginFactoryRegister* FirmwarePluginFactoryRegister::instance(void)
return _instance;
}
FirmwarePlugin::FirmwarePlugin(MAV_TYPE vehicleType)
{
_vehicleType = vehicleType;
}
AutoPilotPlugin* FirmwarePlugin::autopilotPlugin(Vehicle* vehicle)
{
return new GenericAutoPilotPlugin(vehicle, vehicle);
......@@ -132,7 +127,7 @@ bool FirmwarePlugin::supportsThrottleModeCenterZero(void)
return true;
}
bool FirmwarePlugin::supportsNegativeThrust(void)
bool FirmwarePlugin::supportsNegativeThrust(Vehicle* /*vehicle*/)
{
// By default, this is not supported
return false;
......
......@@ -49,8 +49,6 @@ 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
......@@ -164,7 +162,7 @@ public:
/// Returns true if the vehicle and firmware supports the use of negative thrust
/// Typically supported rover.
virtual bool supportsNegativeThrust(void);
virtual bool supportsNegativeThrust(Vehicle *);
/// Returns true if the firmware supports the use of the RC radio and requires the RC radio
/// setup page. Returns true by default.
......@@ -346,9 +344,6 @@ 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,9 +35,8 @@ PX4FirmwarePluginInstanceData::PX4FirmwarePluginInstanceData(QObject* parent)
}
PX4FirmwarePlugin::PX4FirmwarePlugin(MAV_TYPE vehicleType)
: FirmwarePlugin(vehicleType)
, _manualFlightMode (tr("Manual"))
PX4FirmwarePlugin::PX4FirmwarePlugin()
: _manualFlightMode (tr("Manual"))
, _acroFlightMode (tr("Acro"))
, _stabilizedFlightMode (tr("Stabilized"))
, _rattitudeFlightMode (tr("Rattitude"))
......@@ -591,7 +590,7 @@ QString PX4FirmwarePlugin::_versionRegex() {
return QStringLiteral("v([0-9,\\.]*) Stable");
}
bool PX4FirmwarePlugin::supportsNegativeThrust(void)
bool PX4FirmwarePlugin::supportsNegativeThrust(Vehicle* vehicle)
{
return _vehicleType == MAV_TYPE_GROUND_ROVER;
return vehicle->vehicleType() == MAV_TYPE_GROUND_ROVER;
}
......@@ -23,7 +23,7 @@ class PX4FirmwarePlugin : public FirmwarePlugin
Q_OBJECT
public:
PX4FirmwarePlugin (MAV_TYPE vehicleType);
PX4FirmwarePlugin ();
~PX4FirmwarePlugin () override;
// Overrides from FirmwarePlugin
......@@ -69,7 +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;
bool supportsNegativeThrust (Vehicle *vehicle) override;
protected:
typedef struct {
......
......@@ -29,11 +29,11 @@ QList<MAV_AUTOPILOT> PX4FirmwarePluginFactory::supportedFirmwareTypes(void) cons
return list;
}
FirmwarePlugin* PX4FirmwarePluginFactory::firmwarePluginForAutopilot(MAV_AUTOPILOT autopilotType, MAV_TYPE vehicleType)
FirmwarePlugin* PX4FirmwarePluginFactory::firmwarePluginForAutopilot(MAV_AUTOPILOT autopilotType, MAV_TYPE /*vehicleType*/)
{
if (autopilotType == MAV_AUTOPILOT_PX4) {
if (!_pluginInstance) {
_pluginInstance = new PX4FirmwarePlugin(vehicleType);
_pluginInstance = new PX4FirmwarePlugin();
}
return _pluginInstance;
}
......
......@@ -2871,9 +2871,9 @@ bool Vehicle::supportsThrottleModeCenterZero(void) const
return _firmwarePlugin->supportsThrottleModeCenterZero();
}
bool Vehicle::supportsNegativeThrust(void) const
bool Vehicle::supportsNegativeThrust(void)
{
return _firmwarePlugin->supportsNegativeThrust();
return _firmwarePlugin->supportsNegativeThrust(this);
}
bool Vehicle::supportsRadio(void) const
......
......@@ -854,7 +854,7 @@ public:
bool sub(void) const;
bool supportsThrottleModeCenterZero (void) const;
bool supportsNegativeThrust (void) const;
bool supportsNegativeThrust (void);
bool supportsRadio (void) const;
bool supportsJSButton (void) const;
bool supportsMotorInterference (void) const;
......
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