From 8de04e2155f68a935af2bb9ad86afed55c680007 Mon Sep 17 00:00:00 2001 From: George_Andreou Date: Thu, 22 May 2025 17:58:27 +0300 Subject: [PATCH] Added option for turning. --- folkrace.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/folkrace.py b/folkrace.py index ffdcd3a..ff75a79 100644 --- a/folkrace.py +++ b/folkrace.py @@ -50,6 +50,18 @@ def dgleft(): m2.throttle = 1 m3.throttle = 1 m4.throttle = 0 + +def turnright(): + m1.throttle = 1 + m2.throttle = 1 + m3.throttle = 1 + m4.throttle = 0 + +def turnleft(): + m1.throttle = 1 + m2.throttle = 1 + m3.throttle = 0 + m4.throttle = 1 while True: print("F=", f"{front.distance:.2f}", "R=", f"{right.distance:.2f}", "L=", f"{left.distance:.2f}") @@ -60,9 +72,11 @@ while True: if right.distance > left.distance: # Diagonally right dgright() if left.distance < 30: # Strafe right - stright() + turnright() + #stright() if right.distance < 30: # Strafe left - stleft() + turnleft() + #stleft() else: forward()