This commit is contained in:
NikolajDanger
2022-09-07 13:25:32 +02:00
parent 5956500aa6
commit 9c3628572d

View File

@ -4,37 +4,34 @@ import robot
POWER = 70
TURN_T = 0.079 # 10 degrees
DRIVE_A = 16 # 10 centimeter drive at power 1
DRIVE_T = 0.22 # 10 centimeter
RIGHT_WHEEL_OFFSET = 4
CLOCKWISE_OFFSET = 0.96
def square(arlo, drive_t):
def square(arlo):
while True:
# Driving forward
arlo.go_diff(POWER, POWER + RIGHT_WHEEL_OFFSET, 1, 1)
sleep(drive_t * 10)
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.go_diff(POWER, POWER + RIGHT_WHEEL_OFFSET, 1, 0)
sleep(TURN_T * 9 * CLOCKWISE_OFFSET)
arlo.stop()
sleep(1)
def main():
# Calculates sleep times for the robot
drive_t = DRIVE_A / POWER # 10 centimeter drive at given power
# Initializes the robot and runs the
arlo = robot.Robot()
try:
square(arlo, drive_t)
square(arlo)
except KeyboardInterrupt:
arlo.stop()