Plane: move manual mode throttle limits to main throttle limit function.

This commit is contained in:
Iampete1 2024-02-21 18:53:33 +00:00 committed by Andrew Tridgell
parent 7db7f95a3b
commit 674f75fce1
2 changed files with 13 additions and 16 deletions

View File

@ -400,7 +400,7 @@ public:
void run() override; void run() override;
// true if throttle min/max limits should be applied // true if throttle min/max limits should be applied
bool use_throttle_limits() const override { return false; } bool use_throttle_limits() const override;
// true if voltage correction should be applied to throttle // true if voltage correction should be applied to throttle
bool use_battery_compensation() const override { return false; } bool use_battery_compensation() const override { return false; }

View File

@ -6,22 +6,8 @@ void ModeManual::update()
SRV_Channels::set_output_scaled(SRV_Channel::k_aileron, plane.roll_in_expo(false)); SRV_Channels::set_output_scaled(SRV_Channel::k_aileron, plane.roll_in_expo(false));
SRV_Channels::set_output_scaled(SRV_Channel::k_elevator, plane.pitch_in_expo(false)); SRV_Channels::set_output_scaled(SRV_Channel::k_elevator, plane.pitch_in_expo(false));
output_rudder_and_steering(plane.rudder_in_expo(false)); output_rudder_and_steering(plane.rudder_in_expo(false));
float throttle = plane.get_throttle_input(true);
const float throttle = plane.get_throttle_input(true);
#if HAL_QUADPLANE_ENABLED
if (quadplane.available() && quadplane.option_is_set(QuadPlane::OPTION::IDLE_GOV_MANUAL)) {
// for quadplanes it can be useful to run the idle governor in MANUAL mode
// as it prevents the VTOL motors from running
int8_t min_throttle = plane.aparm.throttle_min.get();
// apply idle governor
#if AP_ICENGINE_ENABLED
plane.g2.ice_control.update_idle_governor(min_throttle);
#endif
throttle = MAX(throttle, min_throttle);
}
#endif
SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, throttle); SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, throttle);
plane.nav_roll_cd = ahrs.roll_sensor; plane.nav_roll_cd = ahrs.roll_sensor;
@ -32,3 +18,14 @@ void ModeManual::run()
{ {
reset_controllers(); reset_controllers();
} }
// true if throttle min/max limits should be applied
bool ModeManual::use_throttle_limits() const
{
#if HAL_QUADPLANE_ENABLED
if (quadplane.available() && quadplane.option_is_set(QuadPlane::OPTION::IDLE_GOV_MANUAL)) {
return true;
}
#endif
return false;
}