Skip to content

Commit

Permalink
Plane: added TKOFF_THR_MIN for quadplane SLT
Browse files Browse the repository at this point in the history
this allows for a minimum throttle to be applied during a takeoff or a
forward transition in auto throttle modes. This is useful on high drag
aircraft where normal TECS throttle control results in a slow
transition or takeoff
  • Loading branch information
tridge committed Aug 14, 2024
1 parent 78c2622 commit 70c7a79
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 2 deletions.
9 changes: 9 additions & 0 deletions ArduPlane/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ const AP_Param::Info Plane::var_info[] = {
// @Increment: 0.5
// @User: Standard
ASCALAR(takeoff_throttle_max_t, "TKOFF_THR_MAX_T", 4),

// @Param: TKOFF_THR_MIN
// @DisplayName: Takeoff minimum throttle
// @Description: The minimum throttle to use in takeoffs in AUTO and TAKEOFF flight modes, when TKOFF_OPTIONS bit 0 is set. Also, the minimum throttle to use in a quadpane forward transition. This can be useful to ensure faster takeoffs or transitions on aircraft where the normal throttle control leads to a slow takeoff or transition. It is used when it is larger than THR_MIN, otherwise THR_MIN is used instead.
// @Units: %
// @Range: 0 100
// @Increment: 1
// @User: Standard
ASCALAR(takeoff_throttle_min, "TKOFF_THR_MIN", 60),

// @Param: TKOFF_TDRAG_ELEV
// @DisplayName: Takeoff tail dragger elevator
Expand Down
1 change: 1 addition & 0 deletions ArduPlane/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ class Parameters {
k_param_acro_yaw_rate,
k_param_takeoff_throttle_max_t,
k_param_autotune_options,
k_param_takeoff_throttle_min,
};

AP_Int16 format_version;
Expand Down
24 changes: 24 additions & 0 deletions ArduPlane/quadplane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4064,6 +4064,21 @@ bool QuadPlane::in_transition(void) const
return available() && transition->active();
}

/*
return true if we are in a fwd transition for a SLT quadplane
and in an auto-throttle mode
*/
bool QuadPlane::in_slt_fwd_transition(void) const
{
if (!in_transition() || tiltrotor.enabled() || tailsitter.enabled()) {
return false;
}
if (!plane.control_mode->does_auto_throttle()) {
return false;
}
return transition->in_fwd_transition();
}

/*
calculate current stopping distance for a quadplane in fixed wing flight
*/
Expand Down Expand Up @@ -4554,6 +4569,15 @@ void SLT_Transition::set_last_fw_pitch()
last_fw_nav_pitch_cd = plane.nav_pitch_cd;
}

/*
return true if in a forward transition
*/
bool SLT_Transition::in_fwd_transition() const
{
return transition_state == TRANSITION_AIRSPEED_WAIT ||
transition_state == TRANSITION_TIMER;
}

void SLT_Transition::force_transition_complete() {
transition_state = TRANSITION_DONE;
in_forced_transition = false;
Expand Down
6 changes: 6 additions & 0 deletions ArduPlane/quadplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ class QuadPlane
*/
bool in_transition(void) const;

/*
return true if we are in a fwd transition for a SLT quadplane
and in an auto-throttle mode
*/
bool in_slt_fwd_transition(void) const;

bool handle_do_vtol_transition(enum MAV_VTOL_STATE state) const;

bool do_vtol_takeoff(const AP_Mission::Mission_Command& cmd);
Expand Down
17 changes: 15 additions & 2 deletions ArduPlane/servos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ float Plane::apply_throttle_limits(float throttle_in)

const bool use_takeoff_throttle_max =
#if HAL_QUADPLANE_ENABLED
quadplane.in_transition() ||
quadplane.in_slt_fwd_transition() ||
#endif
(flight_stage == AP_FixedWing::FlightStage::TAKEOFF) ||
(flight_stage == AP_FixedWing::FlightStage::ABORT_LANDING);
Expand All @@ -538,7 +538,20 @@ float Plane::apply_throttle_limits(float throttle_in)
throttle_watt_limiter(min_throttle, max_throttle);
#endif

return constrain_float(throttle_in, min_throttle, max_throttle);
/*
apply TKOFF_THR_MIN if enabled and in an auto-throttle forward
transition
*/
if (use_takeoff_throttle_max) {
const auto tmin_thr = aparm.takeoff_throttle_min;
if (tmin_thr > throttle_in) {
throttle_in = MAX(throttle_in, tmin_thr);
}
}

auto throttle = constrain_float(throttle_in, min_throttle, max_throttle);

return throttle;
}

/*
Expand Down
8 changes: 8 additions & 0 deletions ArduPlane/tailsitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,4 +1034,12 @@ bool Tailsitter_Transition::allow_weathervane()
return !tailsitter.in_vtol_transition() && (vtol_limit_start_ms == 0);
}

/*
return true if in a forward transition
*/
bool Tailsitter_Transition::in_fwd_transition() const
{
return transition_state == TRANSITION_ANGLE_WAIT_FW;
}

#endif // HAL_QUADPLANE_ENABLED
2 changes: 2 additions & 0 deletions ArduPlane/tailsitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ friend class Tailsitter;

bool allow_weathervane() override;

bool in_fwd_transition() const override;

private:

enum {
Expand Down
4 changes: 4 additions & 0 deletions ArduPlane/transition.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class Transition

virtual bool allow_stick_mixing() const { return true; }

virtual bool in_fwd_transition() const = 0;

protected:

// refences for convenience
Expand Down Expand Up @@ -101,6 +103,8 @@ class SLT_Transition : public Transition

void set_last_fw_pitch(void) override;

bool in_fwd_transition() const override;

protected:

enum {
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_Vehicle/AP_FixedWing.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct AP_FixedWing {
AP_Int8 throttle_slewrate;
AP_Int8 throttle_cruise;
AP_Int8 takeoff_throttle_max;
AP_Int8 takeoff_throttle_min;
AP_Int16 airspeed_min;
AP_Int16 airspeed_max;
AP_Float airspeed_cruise;
Expand Down

0 comments on commit 70c7a79

Please sign in to comment.