Skip to content

Commit

Permalink
Plane: allow set_throttle in manual and move disarmed override up
Browse files Browse the repository at this point in the history
  • Loading branch information
IamPete1 committed Feb 14, 2024
1 parent 9cc194b commit 2337f06
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
7 changes: 7 additions & 0 deletions ArduPlane/mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,13 @@ class ModeManual : public Mode
void update() override;

void run() override;

// true if throttle min/max limits should be applied
bool use_throttle_limits() const { return false; }

// true if voltage correction should be applied to throttle
bool use_battery_compensation() const { return false; }

};


Expand Down
36 changes: 20 additions & 16 deletions ArduPlane/servos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ void Plane::throttle_slew_limit(SRV_Channel::Aux_servo_function_t func)
*/
bool Plane::suppress_throttle(void)
{
if (control_mode == &mode_manual) {
// Throttle is never suppressed in manual mode
return false;
}

#if PARACHUTE == ENABLED
if (control_mode->does_auto_throttle() && parachute.release_initiated()) {
// throttle always suppressed in auto-throttle modes after parachute release initiated
Expand Down Expand Up @@ -562,20 +567,7 @@ void Plane::set_throttle(void)
SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, limited_throttle);
}

if (!arming.is_armed_and_safety_off()) {
// Always set 0 scaled even if overriding to zero pwm.
// This ensures slew limits and other functions using the scaled value pick up in the correct place
SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, 0.0);
SRV_Channels::set_output_scaled(SRV_Channel::k_throttleLeft, 0.0);
SRV_Channels::set_output_scaled(SRV_Channel::k_throttleRight, 0.0);

if (arming.arming_required() == AP_Arming::Required::YES_ZERO_PWM) {
SRV_Channels::set_output_limit(SRV_Channel::k_throttle, SRV_Channel::Limit::ZERO_PWM);
SRV_Channels::set_output_limit(SRV_Channel::k_throttleLeft, SRV_Channel::Limit::ZERO_PWM);
SRV_Channels::set_output_limit(SRV_Channel::k_throttleRight, SRV_Channel::Limit::ZERO_PWM);
}

} else if (suppress_throttle()) {
if (suppress_throttle()) {
if (g.throttle_suppress_manual) {
// manual pass through of throttle while throttle is suppressed
SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, get_throttle_input(true));
Expand Down Expand Up @@ -842,8 +834,20 @@ void Plane::set_servos(void)
landing.override_servos();
}

if (control_mode != &mode_manual) {
set_throttle();
set_throttle();

if ((control_mode != &mode_manual) && !arming.is_armed_and_safety_off()) {
// Always set 0 scaled even if overriding to zero pwm.
// This ensures slew limits and other functions using the scaled value pick up in the correct place
SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, 0.0);
SRV_Channels::set_output_scaled(SRV_Channel::k_throttleLeft, 0.0);
SRV_Channels::set_output_scaled(SRV_Channel::k_throttleRight, 0.0);

if (arming.arming_required() == AP_Arming::Required::YES_ZERO_PWM) {
SRV_Channels::set_output_limit(SRV_Channel::k_throttle, SRV_Channel::Limit::ZERO_PWM);
SRV_Channels::set_output_limit(SRV_Channel::k_throttleLeft, SRV_Channel::Limit::ZERO_PWM);
SRV_Channels::set_output_limit(SRV_Channel::k_throttleRight, SRV_Channel::Limit::ZERO_PWM);
}
}

// Warn AHRS if we might take off soon
Expand Down

0 comments on commit 2337f06

Please sign in to comment.