diff --git a/APMrover2/sensors.cpp b/APMrover2/sensors.cpp index cddead068c..cb90bee5be 100644 --- a/APMrover2/sensors.cpp +++ b/APMrover2/sensors.cpp @@ -67,8 +67,8 @@ void Rover::read_sonars(void) // we have two sonars obstacle.sonar1_distance_cm = sonar.distance_cm(0); obstacle.sonar2_distance_cm = sonar.distance_cm(1); - if (obstacle.sonar1_distance_cm <= (uint16_t)g.sonar_trigger_cm && - obstacle.sonar1_distance_cm <= (uint16_t)obstacle.sonar2_distance_cm) { + if (obstacle.sonar1_distance_cm < (uint16_t)g.sonar_trigger_cm && + obstacle.sonar1_distance_cm < (uint16_t)obstacle.sonar2_distance_cm) { // we have an object on the left if (obstacle.detected_count < 127) { obstacle.detected_count++; @@ -79,7 +79,7 @@ void Rover::read_sonars(void) } obstacle.detected_time_ms = AP_HAL::millis(); obstacle.turn_angle = g.sonar_turn_angle; - } else if (obstacle.sonar2_distance_cm <= (uint16_t)g.sonar_trigger_cm) { + } else if (obstacle.sonar2_distance_cm < (uint16_t)g.sonar_trigger_cm) { // we have an object on the right if (obstacle.detected_count < 127) { obstacle.detected_count++; @@ -95,7 +95,7 @@ void Rover::read_sonars(void) // we have a single sonar obstacle.sonar1_distance_cm = sonar.distance_cm(0); obstacle.sonar2_distance_cm = 0; - if (obstacle.sonar1_distance_cm <= (uint16_t)g.sonar_trigger_cm) { + if (obstacle.sonar1_distance_cm < (uint16_t)g.sonar_trigger_cm) { // obstacle detected in front if (obstacle.detected_count < 127) { obstacle.detected_count++;