This commit is contained in:
Max 2021-09-21 12:41:06 +01:00
parent b5a5593cdc
commit 3817d9338d
2 changed files with 8 additions and 6 deletions

View File

@ -409,6 +409,7 @@ class DroneInterface:
if distance_to_pallet < self.pallet_min_distance:
self.log.info(f"We are close enough to pallet ({distance_to_pallet} m)")
pallet_approached = True
self.override_stop()
self.clear_override_channels()
else:
self.log.info(f"Distance to pallet ({distance_to_pallet} m), moving forward...")

View File

@ -23,16 +23,17 @@ void pulse_pin(int trig_pin) {
int get_distance(int trig_pin, int echo_pin){
pulse_pin(trig_pin);
int duration = pulseIn(echo_pin, HIGH);
int distance = duration*0.034/2;
return duration;
long duration = pulseIn(echo_pin, HIGH, 50000);
if (duration == 0) duration = 50000;
// Serial.println(duration);
long distance = duration*0.034/2;
return distance;
}
void loop() {
distance_1 = get_distance(trig_pin, echo_pin);
Serial.print(" | ");
Serial.print(distance_1);
Serial.println(" | ");
delay(100);
delay(1);
}