Copter: ensure force flying with heli inverted flag

This commit is contained in:
bnsgeyer 2024-03-19 23:26:54 -04:00 committed by Randy Mackay
parent a07b514ee8
commit 0de2d6d482
3 changed files with 16 additions and 4 deletions

View File

@ -830,7 +830,8 @@ private:
void set_land_complete(bool b);
void set_land_complete_maybe(bool b);
void update_throttle_mix();
bool get_force_flying() const;
#if AP_LANDINGGEAR_ENABLED
// landing_gear.cpp
void landinggear_update();

View File

@ -36,7 +36,7 @@ void Copter::crash_check()
}
// exit immediately if in force flying
if (force_flying && !flightmode->is_landing()) {
if (get_force_flying() && !flightmode->is_landing()) {
crash_counter = 0;
return;
}

View File

@ -78,7 +78,7 @@ void Copter::update_land_detector()
#if MODE_AUTOROTATE_ENABLED == ENABLED
|| (flightmode->mode_number() == Mode::Number::AUTOROTATE && motors->get_below_land_min_coll())
#endif
|| ((!force_flying || landing) && motors->limit.throttle_lower && pos_control->get_vel_desired_cms().z < 0.0f);
|| ((!get_force_flying() || landing) && motors->limit.throttle_lower && pos_control->get_vel_desired_cms().z < 0.0f);
bool throttle_mix_at_min = true;
#else
// check that the average throttle output is near minimum (less than 12.5% hover throttle)
@ -251,7 +251,7 @@ void Copter::update_throttle_mix()
// check if landing
const bool landing = flightmode->is_landing();
if (((large_angle_request || force_flying) && !landing) || large_angle_error || accel_moving || descent_not_demanded) {
if (((large_angle_request || get_force_flying()) && !landing) || large_angle_error || accel_moving || descent_not_demanded) {
attitude_control->set_throttle_mix_max(pos_control->get_vel_z_control_ratio());
} else {
attitude_control->set_throttle_mix_min();
@ -259,3 +259,14 @@ void Copter::update_throttle_mix()
}
#endif
}
// helper function for force flying flag
bool Copter::get_force_flying() const
{
#if FRAME_CONFIG == HELI_FRAME
if (attitude_control->get_inverted_flight()) {
return true;
}
#endif
return force_flying;
}