Commit 3b82d52d authored by Rustom Jehangir's avatar Rustom Jehangir

Make supportsThrottleModeCenterZero a plugin option

parent 0538e94e
...@@ -52,3 +52,8 @@ int ArduSubFirmwarePlugin::manualControlReservedButtonCount(void) ...@@ -52,3 +52,8 @@ int ArduSubFirmwarePlugin::manualControlReservedButtonCount(void)
{ {
return 0; return 0;
} }
bool ArduSubFirmwarePlugin::supportsThrottleModeCenterZero(void)
{
return false;
}
...@@ -69,6 +69,8 @@ public: ...@@ -69,6 +69,8 @@ public:
// Overrides from FirmwarePlugin // Overrides from FirmwarePlugin
int manualControlReservedButtonCount(void); int manualControlReservedButtonCount(void);
bool supportsThrottleModeCenterZero(void);
}; };
#endif #endif
...@@ -83,6 +83,12 @@ int FirmwarePlugin::manualControlReservedButtonCount(void) ...@@ -83,6 +83,12 @@ int FirmwarePlugin::manualControlReservedButtonCount(void)
return -1; return -1;
} }
bool FirmwarePlugin::supportsThrottleModeCenterZero(void)
{
// By default, this is supported
return true;
}
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,11 @@ public: ...@@ -128,6 +128,11 @@ 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);
/// 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.
......
...@@ -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;
......
...@@ -1528,6 +1528,11 @@ bool Vehicle::supportsManualControl(void) const ...@@ -1528,6 +1528,11 @@ bool Vehicle::supportsManualControl(void) const
return false; return false;
} }
bool Vehicle::supportsThrottleModeCenterZero(void) const
{
return _firmwarePlugin->supportsThrottleModeCenterZero();
}
void Vehicle::_setCoordinateValid(bool coordinateValid) void Vehicle::_setCoordinateValid(bool coordinateValid)
{ {
if (coordinateValid != _coordinateValid) { if (coordinateValid != _coordinateValid) {
......
...@@ -276,6 +276,7 @@ public: ...@@ -276,6 +276,7 @@ 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 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 +474,7 @@ public: ...@@ -473,6 +474,7 @@ public:
bool sub(void) const; bool sub(void) const;
bool supportsManualControl(void) const; bool supportsManualControl(void) const;
bool supportsThrottleModeCenterZero(void) const;
void setFlying(bool flying); void setFlying(bool flying);
void setGuidedMode(bool guidedMode); void setGuidedMode(bool guidedMode);
......
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