From 2418bee4077882d1e5ef758332b9cc90b32b09eb Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Wed, 9 Nov 2022 23:34:26 +0700 Subject: [PATCH] reverse after collision --- kuukar/kuukar_motion.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kuukar/kuukar_motion.py b/kuukar/kuukar_motion.py index c50217d..c377fb8 100644 --- a/kuukar/kuukar_motion.py +++ b/kuukar/kuukar_motion.py @@ -106,13 +106,16 @@ class motion: def __roam_handle(self): sensitivity = 35 - turn_speed = 30 + turn_speed = 40 drive_speed = 25 self.drive(drive_speed) f_dist = self.sensors.sonar_get_distance(1) if 0 < f_dist < sensitivity: # Close to collision, turn the vehicle print("collision") + self.drive(-drive_speed) + time.sleep(0.75) + self.stop() l_dist = self.sensors.sonar_get_distance(0) r_dist = self.sensors.sonar_get_distance(2) if l_dist < sensitivity: # Left side is blocked