-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpark.py
45 lines (34 loc) · 960 Bytes
/
park.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import drivers
import os
import time
ROBOT_LATERAL_LENGTH = 3 + 5 / 8
ROBOT_AXIAL_LENGTH = 3 + 3 / 8
PARKER_NAME = "BLUE"
START_SIGNAL = "go"
def in_to_cm(inches):
return inches / 0.393701
# Initialize drivers
print("Initializing drivers...")
drivers.init()
# Identify which robot I am
identity = None
with open("identity.dat", "r") as file:
identity = file.readlines()[0].strip()
print(identity, "spinning up. Pray to Lafayette Official God.")
# Wait for server to distribute start signal
print("Waiting for start signal.")
while not os.path.isfile(START_SIGNAL):
pass
if identity == PARKER_NAME:
print("Parking...")
# Back in and out
drivers.move(drivers.RobotState(drivers.DRIVE,
in_to_cm(ROBOT_AXIAL_LENGTH + 2)))
time.sleep(2)
drivers.move(drivers.RobotState(drivers.DRIVE,
-in_to_cm(ROBOT_AXIAL_LENGTH + 2)))
# Signal done
drivers.LED1.on()
os.remove(START_SIGNAL)
print("Done.")
time.sleep(10)