Commit 5e043189 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #3896 from bluerobotics/pluginSemantics

Fix plugin semantics for ArduSub additions
parents 2ed50262 2664e9a5
...@@ -66,7 +66,7 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void) ...@@ -66,7 +66,7 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void)
_airframeComponent->setupTriggerSignals(); _airframeComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent)); _components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent));
if ( !_vehicle->sub() ) { if ( _vehicle->supportsRadio() ) {
_radioComponent = new APMRadioComponent(_vehicle, this); _radioComponent = new APMRadioComponent(_vehicle, this);
_radioComponent->setupTriggerSignals(); _radioComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_radioComponent)); _components.append(QVariant::fromValue((VehicleComponent*)_radioComponent));
......
...@@ -52,3 +52,23 @@ int ArduSubFirmwarePlugin::manualControlReservedButtonCount(void) ...@@ -52,3 +52,23 @@ int ArduSubFirmwarePlugin::manualControlReservedButtonCount(void)
{ {
return 0; return 0;
} }
bool ArduSubFirmwarePlugin::supportsThrottleModeCenterZero(void)
{
return false;
}
bool ArduSubFirmwarePlugin::supportsManualControl(void)
{
return true;
}
bool ArduSubFirmwarePlugin::supportsRadio(void)
{
return false;
}
bool ArduSubFirmwarePlugin::supportsJSButton(void)
{
return true;
}
...@@ -69,6 +69,13 @@ public: ...@@ -69,6 +69,13 @@ public:
// Overrides from FirmwarePlugin // Overrides from FirmwarePlugin
int manualControlReservedButtonCount(void); int manualControlReservedButtonCount(void);
bool supportsThrottleModeCenterZero(void);
bool supportsManualControl(void);
bool supportsRadio(void);
bool supportsJSButton(void);
}; };
#endif #endif
...@@ -83,6 +83,27 @@ int FirmwarePlugin::manualControlReservedButtonCount(void) ...@@ -83,6 +83,27 @@ int FirmwarePlugin::manualControlReservedButtonCount(void)
return -1; return -1;
} }
bool FirmwarePlugin::supportsThrottleModeCenterZero(void)
{
// By default, this is supported
return true;
}
bool FirmwarePlugin::supportsManualControl(void)
{
return false;
}
bool FirmwarePlugin::supportsRadio(void)
{
return true;
}
bool FirmwarePlugin::supportsJSButton(void)
{
return false;
}
bool FirmwarePlugin::adjustIncomingMavlinkMessage(Vehicle* vehicle, mavlink_message_t* message) bool FirmwarePlugin::adjustIncomingMavlinkMessage(Vehicle* vehicle, mavlink_message_t* message)
{ {
Q_UNUSED(vehicle); Q_UNUSED(vehicle);
......
...@@ -128,6 +128,23 @@ public: ...@@ -128,6 +128,23 @@ public:
/// @return -1: reserver all buttons, >0 number of buttons to reserve /// @return -1: reserver all buttons, >0 number of buttons to reserve
virtual int manualControlReservedButtonCount(void); virtual int manualControlReservedButtonCount(void);
/// Returns true if the vehicle and firmware supports the use of a throttle joystick that
/// is zero when centered. Typically not supported on vehicles that have bidirectional
/// throttle.
virtual bool supportsThrottleModeCenterZero(void);
/// Returns true if the firmware supports the use of the MAVlink "MANUAL_CONTROL" message.
/// By default, this returns false unless overridden in the firmware plugin.
virtual bool supportsManualControl(void);
/// Returns true if the firmware supports the use of the RC radio and requires the RC radio
/// setup page. Returns true by default.
virtual bool supportsRadio(void);
/// Returns true if the firmware supports the AP_JSButton library, which allows joystick buttons
/// to be assigned via parameters in firmware. Default is false.
virtual bool supportsJSButton(void);
/// Called before any mavlink message is processed by Vehicle such that the firmwre plugin /// Called before any mavlink message is processed by Vehicle such that the firmwre plugin
/// can adjust any message characteristics. This is handy to adjust or differences in mavlink /// can adjust any message characteristics. This is handy to adjust or differences in mavlink
/// spec implementations such that the base code can remain mavlink generic. /// spec implementations such that the base code can remain mavlink generic.
......
...@@ -170,6 +170,11 @@ int PX4FirmwarePlugin::manualControlReservedButtonCount(void) ...@@ -170,6 +170,11 @@ int PX4FirmwarePlugin::manualControlReservedButtonCount(void)
return 0; // 0 buttons reserved for rc switch simulation return 0; // 0 buttons reserved for rc switch simulation
} }
bool PX4FirmwarePlugin::supportsManualControl(void)
{
return true;
}
bool PX4FirmwarePlugin::isCapable(const Vehicle *vehicle, FirmwareCapabilities capabilities) bool PX4FirmwarePlugin::isCapable(const Vehicle *vehicle, FirmwareCapabilities capabilities)
{ {
if(vehicle->multiRotor()) { if(vehicle->multiRotor()) {
......
...@@ -44,6 +44,7 @@ public: ...@@ -44,6 +44,7 @@ public:
void guidedModeChangeAltitude (Vehicle* vehicle, double altitudeRel) final; void guidedModeChangeAltitude (Vehicle* vehicle, double altitudeRel) final;
bool isGuidedMode (const Vehicle* vehicle) const; bool isGuidedMode (const Vehicle* vehicle) const;
int manualControlReservedButtonCount(void) final; int manualControlReservedButtonCount(void) final;
bool supportsManualControl (void) final;
void initializeVehicle (Vehicle* vehicle) final; void initializeVehicle (Vehicle* vehicle) final;
bool sendHomePositionToVehicle (void) final; bool sendHomePositionToVehicle (void) final;
void addMetaDataToFact (QObject* parameterMetaData, Fact* fact, MAV_TYPE vehicleType) final; void addMetaDataToFact (QObject* parameterMetaData, Fact* fact, MAV_TYPE vehicleType) final;
......
...@@ -284,7 +284,7 @@ void Joystick::run(void) ...@@ -284,7 +284,7 @@ void Joystick::run(void)
throttle = std::max(-1.0f, std::min(tanf(asinf(throttle_limited)), 1.0f)); throttle = std::max(-1.0f, std::min(tanf(asinf(throttle_limited)), 1.0f));
// Adjust throttle to 0:1 range // Adjust throttle to 0:1 range
if (_throttleMode == ThrottleModeCenterZero && !_activeVehicle->sub()) { if (_throttleMode == ThrottleModeCenterZero && _activeVehicle->supportsThrottleModeCenterZero()) {
throttle = std::max(0.0f, throttle); throttle = std::max(0.0f, throttle);
} else { } else {
throttle = (throttle + 1.0f) / 2.0f; throttle = (throttle + 1.0f) / 2.0f;
......
...@@ -1517,15 +1517,22 @@ bool Vehicle::vtol(void) const ...@@ -1517,15 +1517,22 @@ bool Vehicle::vtol(void) const
bool Vehicle::supportsManualControl(void) const bool Vehicle::supportsManualControl(void) const
{ {
// PX4 Firmware supports manual control message return _firmwarePlugin->supportsManualControl();
if ( px4Firmware() ) { }
return true;
} bool Vehicle::supportsThrottleModeCenterZero(void) const
// ArduSub supports manual control message (identified by APM + Submarine type) {
if ( apmFirmware() && vehicleType() == MAV_TYPE_SUBMARINE ) { return _firmwarePlugin->supportsThrottleModeCenterZero();
return true; }
}
return false; bool Vehicle::supportsRadio(void) const
{
return _firmwarePlugin->supportsRadio();
}
bool Vehicle::supportsJSButton(void) const
{
return _firmwarePlugin->supportsJSButton();
} }
void Vehicle::_setCoordinateValid(bool coordinateValid) void Vehicle::_setCoordinateValid(bool coordinateValid)
......
...@@ -276,6 +276,8 @@ public: ...@@ -276,6 +276,8 @@ public:
Q_PROPERTY(bool vtol READ vtol CONSTANT) Q_PROPERTY(bool vtol READ vtol CONSTANT)
Q_PROPERTY(bool rover READ rover CONSTANT) Q_PROPERTY(bool rover READ rover CONSTANT)
Q_PROPERTY(bool supportsManualControl READ supportsManualControl CONSTANT) Q_PROPERTY(bool supportsManualControl READ supportsManualControl CONSTANT)
Q_PROPERTY(bool supportsThrottleModeCenterZero READ supportsThrottleModeCenterZero CONSTANT)
Q_PROPERTY(bool supportsJSButton READ supportsJSButton CONSTANT)
Q_PROPERTY(bool sub READ sub CONSTANT) Q_PROPERTY(bool sub READ sub CONSTANT)
Q_PROPERTY(bool autoDisconnect MEMBER _autoDisconnect NOTIFY autoDisconnectChanged) Q_PROPERTY(bool autoDisconnect MEMBER _autoDisconnect NOTIFY autoDisconnectChanged)
Q_PROPERTY(QString prearmError READ prearmError WRITE setPrearmError NOTIFY prearmErrorChanged) Q_PROPERTY(QString prearmError READ prearmError WRITE setPrearmError NOTIFY prearmErrorChanged)
...@@ -473,6 +475,9 @@ public: ...@@ -473,6 +475,9 @@ public:
bool sub(void) const; bool sub(void) const;
bool supportsManualControl(void) const; bool supportsManualControl(void) const;
bool supportsThrottleModeCenterZero(void) const;
bool supportsRadio(void) const;
bool supportsJSButton(void) const;
void setFlying(bool flying); void setFlying(bool flying);
void setGuidedMode(bool guidedMode); void setGuidedMode(bool guidedMode);
......
...@@ -381,7 +381,7 @@ QGCView { ...@@ -381,7 +381,7 @@ QGCView {
Column { Column {
spacing: ScreenTools.defaultFontPixelHeight / 3 spacing: ScreenTools.defaultFontPixelHeight / 3
visible: !_activeVehicle.sub visible: _activeVehicle.supportsThrottleModeCenterZero
ExclusiveGroup { id: throttleModeExclusiveGroup } ExclusiveGroup { id: throttleModeExclusiveGroup }
...@@ -449,8 +449,8 @@ QGCView { ...@@ -449,8 +449,8 @@ QGCView {
if (buttonActionRepeater.itemAt(index)) { if (buttonActionRepeater.itemAt(index)) {
buttonActionRepeater.itemAt(index).pressed = pressed buttonActionRepeater.itemAt(index).pressed = pressed
} }
if (subButtonActionRepeater.itemAt(index)) { if (jsButtonActionRepeater.itemAt(index)) {
subButtonActionRepeater.itemAt(index).pressed = pressed jsButtonActionRepeater.itemAt(index).pressed = pressed
} }
} }
} }
...@@ -474,7 +474,7 @@ QGCView { ...@@ -474,7 +474,7 @@ QGCView {
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: (_activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount) && !_activeVehicle.sub visible: (_activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount) && !_activeVehicle.supportsJSButton
property bool pressed property bool pressed
...@@ -516,7 +516,7 @@ QGCView { ...@@ -516,7 +516,7 @@ QGCView {
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: _activeVehicle.sub visible: _activeVehicle.supportsJSButton
QGCLabel { QGCLabel {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
...@@ -536,12 +536,12 @@ QGCView { ...@@ -536,12 +536,12 @@ QGCView {
} // Row } // Row
Repeater { Repeater {
id: subButtonActionRepeater id: jsButtonActionRepeater
model: _activeJoystick.totalButtonCount model: _activeJoystick.totalButtonCount
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: _activeVehicle.sub visible: _activeVehicle.supportsJSButton
property bool pressed property bool pressed
...@@ -564,14 +564,14 @@ QGCView { ...@@ -564,14 +564,14 @@ QGCView {
} }
FactComboBox { FactComboBox {
id: mainSubButtonActionCombo id: mainJSButtonActionCombo
width: ScreenTools.defaultFontPixelWidth * 15 width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null; fact: controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null;
indexModel: false indexModel: false
} }
FactComboBox { FactComboBox {
id: shiftSubButtonActionCombo id: shiftJSButtonActionCombo
width: ScreenTools.defaultFontPixelWidth * 15 width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null; fact: controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null;
indexModel: false indexModel: false
......
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