Skip to content

Commit

Permalink
Copter: ensure force flying with heli inverted flag
Browse files Browse the repository at this point in the history
  • Loading branch information
bnsgeyer committed Mar 20, 2024
1 parent 13841b2 commit b42a6a7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ArduCopter/Copter.h
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,8 @@ class Copter : public AP_Vehicle {
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();
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/crash_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 13 additions & 2 deletions ArduCopter/land_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -218,11 +218,22 @@ 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();
}
}
#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;
}

0 comments on commit b42a6a7

Please sign in to comment.