From 280de12b3df8a3ad6ed377a702a56d89c9cb72ca Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Wed, 14 Sep 2022 15:03:42 +0200 Subject: [PATCH] :sparkles: --- careful_forward.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/careful_forward.py b/careful_forward.py index e24ae18..c69ceeb 100644 --- a/careful_forward.py +++ b/careful_forward.py @@ -8,19 +8,23 @@ RIGHT_WHEEL_OFFSET = 5 def careful_forward(drive_time, arlo): start = time.time() end = start + drive_time + turning = None while time.time() < end: forward_dist = arlo.read_front_ping_sensor() right_dist = arlo.read_right_ping_sensor() left_dist = arlo.read_left_ping_sensor() if forward_dist > 600 and all(x > 200 for x in [right_dist, left_dist]): print("not blocked") + turning = None arlo.go_diff(POWER, POWER + RIGHT_WHEEL_OFFSET, 1, 1) else: print("blocked") - if forward_dist > 600 and right_dist > 200: + if turning == "R" or (forward_dist > 600 and right_dist > 200 and turning is None): arlo.go_diff(POWER, POWER, 1, 0) + turning = "R" else: arlo.go_diff(POWER, POWER + RIGHT_WHEEL_OFFSET, 0, 1) + turning = "L" time.sleep(0.01)