turn_test.py

This commit is contained in:
NikolajDanger
2022-09-07 13:31:44 +02:00
parent 798445b372
commit 552c783ce8

View File

@ -6,11 +6,11 @@ POWER = 70
TURN_T = 0.079 # 10 degrees
DRIVE_T = 0.22 # 10 centimeter
RIGHT_WHEEL_OFFSET = 0
RIGHT_WHEEL_OFFSET = 4
CLOCKWISE_OFFSET = 0.96
def square(arlo):
def clockwise_square(arlo):
while True:
# Driving forward
arlo.go_diff(POWER, POWER + RIGHT_WHEEL_OFFSET, 1, 1)
@ -26,12 +26,33 @@ def square(arlo):
sleep(1)
def counter_square(arlo):
while True:
# Driving forward
arlo.go_diff(POWER, POWER + RIGHT_WHEEL_OFFSET, 1, 1)
sleep(DRIVE_T * 10)
arlo.stop()
sleep(1)
# Turning 90 degrees
arlo.go_diff(POWER, POWER + RIGHT_WHEEL_OFFSET, 0, 1)
sleep(TURN_T * 9)
arlo.stop()
sleep(1)
def main():
# Initializes the robot and runs the
arlo = robot.Robot()
direction = int(input("clockwise (1)/counter (2):"))
try:
square(arlo)
if direction == 1:
clockwise_square(arlo)
else:
counter_square(arlo)
except KeyboardInterrupt:
arlo.stop()