44 lines
808 B
Python
44 lines
808 B
Python
from time import sleep
|
|
import robot
|
|
|
|
POWER = 70
|
|
|
|
TURN_T = 0.076 # 10 degrees
|
|
DRIVE_A = 16 # 10 centimeter drive at power 1
|
|
|
|
TURN_COUNTER_OFFSET = 1.042
|
|
|
|
def square(arlo, drive_t):
|
|
while True:
|
|
# Driving forward
|
|
arlo.go_diff(POWER, POWER, 1, 1)
|
|
sleep(drive_t * 10)
|
|
arlo.stop()
|
|
|
|
sleep(1)
|
|
|
|
# Turning 90 degrees
|
|
arlo.go_diff(POWER, POWER, 0, 1)
|
|
sleep(TURN_T * 9 * TURN_COUNTER_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)
|
|
|
|
except KeyboardInterrupt:
|
|
arlo.stop()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|