Added option for turning.
This commit is contained in:
parent
2310ddd020
commit
8de04e2155
1 changed files with 16 additions and 2 deletions
18
folkrace.py
18
folkrace.py
|
|
@ -50,6 +50,18 @@ def dgleft():
|
||||||
m2.throttle = 1
|
m2.throttle = 1
|
||||||
m3.throttle = 1
|
m3.throttle = 1
|
||||||
m4.throttle = 0
|
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:
|
while True:
|
||||||
print("F=", f"{front.distance:.2f}", "R=", f"{right.distance:.2f}", "L=", f"{left.distance:.2f}")
|
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
|
if right.distance > left.distance: # Diagonally right
|
||||||
dgright()
|
dgright()
|
||||||
if left.distance < 30: # Strafe right
|
if left.distance < 30: # Strafe right
|
||||||
stright()
|
turnright()
|
||||||
|
#stright()
|
||||||
if right.distance < 30: # Strafe left
|
if right.distance < 30: # Strafe left
|
||||||
stleft()
|
turnleft()
|
||||||
|
#stleft()
|
||||||
else:
|
else:
|
||||||
forward()
|
forward()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue