Files
Roboteksperimentarium/square.py
NikolajDanger 916829aecb
2022-09-07 13:17:57 +02:00

44 lines
786 B
Python

from time import sleep
import robot
POWER = 70
TURN_T = 0.079 # 10 degrees
DRIVE_A = 16 # 10 centimeter drive at power 1
CLOCKWISE_OFFSET = 0.96
def square(arlo, drive_t):
while True:
# Driving forward
arlo.go_diff(POWER, POWER+4, 1, 1)
sleep(drive_t * 10)
arlo.stop()
sleep(1)
# Turning 90 degrees
arlo.go_diff(POWER, POWER+4, 0, 1)
sleep(TURN_T * 9)
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)
except KeyboardInterrupt:
arlo.stop()
if __name__ == "__main__":
main()