Skip to content

Commit

Permalink
Copter: Increase second stage land detect wait time
Browse files Browse the repository at this point in the history
  • Loading branch information
priseborough committed Aug 30, 2016
1 parent f776756 commit 7ecf63e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
14 changes: 10 additions & 4 deletions ArduCopter/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,23 @@
//////////////////////////////////////////////////////////////////////////////
// Landing Detector
//
#ifndef LAND_DETECTOR_TRIGGER_SEC
# define LAND_DETECTOR_TRIGGER_SEC 1.0f // number of seconds to detect a landing
// Number of seconds to detect a probable landing. This results in the ESC upper pwm limit being reduced and is reversible.
#ifndef FIRST_STAGE_LANDED_TRIGGER_SEC
# define FIRST_STAGE_LANDED_TRIGGER_SEC 1.0f
#endif
// Number of seconds to detect with certainty that we have landed. This results in motors being disarmed.
// This check commences after the first stage detector has passed and the ESC upper pwm limit has been reduced
#ifndef SECOND_STAGE_LANDED_TRIGGER_SEC
# define SECOND_STAGE_LANDED_TRIGGER_SEC 2.0f
#endif
#ifndef LAND_DETECTOR_MAYBE_TRIGGER_SEC
# define LAND_DETECTOR_MAYBE_TRIGGER_SEC 0.2f // number of seconds that means we might be landed (used to reset horizontal position targets to prevent tipping over)
#endif
#ifndef LAND_DETECTOR_ACCEL_LPF_CUTOFF
# define LAND_DETECTOR_ACCEL_LPF_CUTOFF 5.0f // frequency cutoff of land detector accelerometer filter
# define LAND_DETECTOR_ACCEL_LPF_CUTOFF 5.0f // frequency cutoff of land detector accelerometer filter
#endif
#ifndef LAND_DETECTOR_ACCEL_MAX
# define LAND_DETECTOR_ACCEL_MAX 1.0f // vehicle acceleration must be under 1m/s/s
# define LAND_DETECTOR_ACCEL_MAX 1.0f // vehicle acceleration must be under 1m/s/s
#endif

//////////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 5 additions & 5 deletions ArduCopter/land_detector.pde
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ static void update_land_detector()

// Increment a counter when throttle is at the lower limit
// Reset the counter if the throttle comes off the limit
// Declare the check as passed when the coutner reaches the pass threshold
// Declare the check as passed when the counter reaches the pass threshold
// If the throttle comes off the limit, also reset the counter used check for monitor movement
bool throttle_check_passed = false;
if (throttle_at_lower_limit) {
if (counter_min_throttle < ((float)LAND_DETECTOR_TRIGGER_SEC)*MAIN_LOOP_RATE) {
if (counter_min_throttle < ((float)FIRST_STAGE_LANDED_TRIGGER_SEC)*MAIN_LOOP_RATE) {
counter_min_throttle++;
} else {
throttle_check_passed = true;
Expand All @@ -92,7 +92,7 @@ static void update_land_detector()
// declare the check as passed when the counter reaches the pass threshold
bool accel_check_passed = false;
if (accel_stationary) {
if (counter_not_accelerating < ((float)LAND_DETECTOR_TRIGGER_SEC)*MAIN_LOOP_RATE) {
if (counter_not_accelerating < ((float)FIRST_STAGE_LANDED_TRIGGER_SEC)*MAIN_LOOP_RATE) {
counter_not_accelerating++;
} else {
accel_check_passed = true;
Expand All @@ -106,7 +106,7 @@ static void update_land_detector()
// declare the check as passed when the counter reaches the pass threshold
bool falling_check_passed = false;
if (accel_not_falling) {
if (counter_not_falling < ((float)LAND_DETECTOR_TRIGGER_SEC)*MAIN_LOOP_RATE) {
if (counter_not_falling < ((float)FIRST_STAGE_LANDED_TRIGGER_SEC)*MAIN_LOOP_RATE) {
counter_not_falling++;
} else {
falling_check_passed = true;
Expand Down Expand Up @@ -145,7 +145,7 @@ static void update_land_detector()
// Because the esc's have already been lowered to a value that will not allow the copter to tip
// this check can be slower to pass
if (falling_check_passed && throttle_check_passed && reduce_max_pwm) {
if (counter_landed < ((float)LAND_DETECTOR_TRIGGER_SEC)*MAIN_LOOP_RATE) {
if (counter_landed < ((float)SECOND_STAGE_LANDED_TRIGGER_SEC)*MAIN_LOOP_RATE) {
counter_landed++;
} else {
set_land_complete(true);
Expand Down

0 comments on commit 7ecf63e

Please sign in to comment.