Browse Source

Joystick: make negativethrust visible by firmwarePlugin

QGC4.4
khancyr 8 years ago
parent
commit
76d2d8678e
  1. 6
      src/FirmwarePlugin/FirmwarePlugin.cc
  2. 4
      src/FirmwarePlugin/FirmwarePlugin.h
  3. 2
      src/Joystick/Joystick.cc
  4. 5
      src/Vehicle/Vehicle.cc
  5. 2
      src/Vehicle/Vehicle.h
  6. 1
      src/VehicleSetup/JoystickConfig.qml

6
src/FirmwarePlugin/FirmwarePlugin.cc

@ -129,6 +129,12 @@ bool FirmwarePlugin::supportsThrottleModeCenterZero(void) @@ -129,6 +129,12 @@ bool FirmwarePlugin::supportsThrottleModeCenterZero(void)
return true;
}
bool FirmwarePlugin::supportsNegativeThrust(void)
{
// By default, this is not supported
return false;
}
bool FirmwarePlugin::supportsManualControl(void)
{
return false;

4
src/FirmwarePlugin/FirmwarePlugin.h

@ -158,6 +158,10 @@ public: @@ -158,6 +158,10 @@ public:
/// throttle.
virtual bool supportsThrottleModeCenterZero(void);
/// Returns true if the vehicle and firmware supports the use of negative thrust
/// Typically supported rover.
virtual bool supportsNegativeThrust(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);

2
src/Joystick/Joystick.cc

@ -463,7 +463,7 @@ void Joystick::run(void) @@ -463,7 +463,7 @@ void Joystick::run(void)
// Adjust throttle to 0:1 range
if (_throttleMode == ThrottleModeCenterZero && _activeVehicle->supportsThrottleModeCenterZero()) {
if (!_negativeThrust) {
if (!_activeVehicle->supportsNegativeThrust() || !_negativeThrust) {
throttle = std::max(0.0f, throttle);
}
} else {

5
src/Vehicle/Vehicle.cc

@ -2118,6 +2118,11 @@ bool Vehicle::supportsThrottleModeCenterZero(void) const @@ -2118,6 +2118,11 @@ bool Vehicle::supportsThrottleModeCenterZero(void) const
return _firmwarePlugin->supportsThrottleModeCenterZero();
}
bool Vehicle::supportsNegativeThrust(void) const
{
return _firmwarePlugin->supportsNegativeThrust();
}
bool Vehicle::supportsRadio(void) const
{
return _firmwarePlugin->supportsRadio();

2
src/Vehicle/Vehicle.h

@ -284,6 +284,7 @@ public: @@ -284,6 +284,7 @@ public:
Q_PROPERTY(bool sub READ sub NOTIFY vehicleTypeChanged)
Q_PROPERTY(bool supportsManualControl READ supportsManualControl CONSTANT)
Q_PROPERTY(bool supportsThrottleModeCenterZero READ supportsThrottleModeCenterZero CONSTANT)
Q_PROPERTY(bool supportsNegativeThrust READ supportsNegativeThrust CONSTANT)
Q_PROPERTY(bool supportsJSButton READ supportsJSButton CONSTANT)
Q_PROPERTY(bool supportsRadio READ supportsRadio CONSTANT)
Q_PROPERTY(bool supportsMotorInterference READ supportsMotorInterference CONSTANT)
@ -522,6 +523,7 @@ public: @@ -522,6 +523,7 @@ public:
bool supportsManualControl(void) const;
bool supportsThrottleModeCenterZero(void) const;
bool supportsNegativeThrust(void) const;
bool supportsRadio(void) const;
bool supportsJSButton(void) const;
bool supportsMotorInterference(void) const;

1
src/VehicleSetup/JoystickConfig.qml

@ -455,6 +455,7 @@ SetupPage { @@ -455,6 +455,7 @@ SetupPage {
}
QGCCheckBox {
visible: _activeVehicle.supportsNegativeThrust
id: negativeThrust
text: qsTr("Allow negative Thrust")
checked: _activeJoystick ? _activeJoystick.negativeThrust : false

Loading…
Cancel
Save