Skip to content

Commit

Permalink
Copter: Update land detector
Browse files Browse the repository at this point in the history
Replaces the legacy min throttle check with a simple criteria that can be checked using log data
Extends the tip-over protection to include landings in RTL mode
  • Loading branch information
priseborough committed Sep 13, 2016
1 parent 7d2cb35 commit 9b46d34
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ArduCopter/land_detector.pde
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ static void update_land_detector()
} else {
// we are armed and not landed - check for landed criteria
// check that the average throttle output is near minimum
bool throttle_at_lower_limit = motors.limit.throttle_lower && motors.is_throttle_mix_min();
bool throttle_at_lower_limit = g.rc_3.servo_out <= g.throttle_min;

// check that the airframe is not accelerating (not falling or breaking after fast forward flight)
bool accel_stationary = (land_accel_ef_filter.get().length() <= LAND_DETECTOR_ACCEL_MAX);

// check that the airframe is not falling
bool accel_not_falling = (land_accel_ef_filter.get().z <= LAND_DETECTOR_ACCEL_MAX);

// If we are in land mode and motors are at the lower limit, reduce the tilt limit to the minimum over 500msec to prevent tipover
if (throttle_at_lower_limit && (angle_max_dynamic > ANGLE_LIMIT_MINIMUM) && (control_mode == LAND)) {
// If we are in LAND or RTL mode and motors are at the lower limit, reduce the tilt limit to the minimum over 500msec to prevent tipover
bool mode_check = (control_mode == LAND) || (control_mode == RTL);
if (throttle_at_lower_limit && (angle_max_dynamic > ANGLE_LIMIT_MINIMUM) && mode_check) {
angle_max_dynamic -= (aparm.angle_max-ANGLE_LIMIT_MINIMUM)/(MAIN_LOOP_RATE/2);
} else if (!throttle_at_lower_limit && (angle_max_dynamic < aparm.angle_max)) {
angle_max_dynamic += (aparm.angle_max-ANGLE_LIMIT_MINIMUM)/(MAIN_LOOP_RATE/2);
Expand Down

0 comments on commit 9b46d34

Please sign in to comment.