From 1ae7b3dbb25b3ac0e0ac2abbbe2cd336919a4ada Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Wed, 9 Nov 2022 23:25:05 +0700 Subject: [PATCH] adjust roam speed --- kuukar/kuukar_motion.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/kuukar/kuukar_motion.py b/kuukar/kuukar_motion.py index 0bc4a3b..694a597 100644 --- a/kuukar/kuukar_motion.py +++ b/kuukar/kuukar_motion.py @@ -105,8 +105,11 @@ class motion: self.__roam_handle() def __roam_handle(self): - sensitivity = 35 - self.drive(23) + sensitivity = 65 + turn_speed = 30 + drive_speed = 30 + + 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") @@ -115,24 +118,24 @@ class motion: if l_dist < sensitivity: # Left side is blocked if r_dist < sensitivity: # Both side are blocked, do a full 180deg turn print("full turn") - self.turn(30, 2*TURN_TIME_FS_90DEG_MS) + self.turn(30, 2) self.drive(23) else: # Right Side is Free, turn right print("right turn") - self.turn(30, TURN_TIME_FS_90DEG_MS) - self.drive(23) + self.turn(turn_speed, 1) + self.drive(drive_speed) elif r_dist < sensitivity: # Right side is blocked, left side is free, turn left print("right left") - self.turn(-30, TURN_TIME_FS_90DEG_MS) - self.drive(23) + self.turn(-turn_speed, 1) + self.drive(drive_speed) else: # Both Side are free, randomize a direction print("turn random") right: bool = randint(0, 1) if right: - self.turn(30, TURN_TIME_FS_90DEG_MS) - self.drive(23) + self.turn(turn_speed, 1) + self.drive(drive_speed) else: - self.turn(-23, TURN_TIME_FS_90DEG_MS) - self.drive(30) + self.turn(-turn_speed, 1) + self.drive(drive_speed) time.sleep(0.5) \ No newline at end of file