This repository has been archived by the owner on Jul 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
piemos_control.py
executable file
·83 lines (72 loc) · 2.33 KB
/
piemos_control.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python2.7
from __future__ import print_function
import argparse
import lcm
import os
import os.path
import time
import threading
import math
from Forseti import *
def main():
lc = lcm.LCM('udpm://239.255.76.67:7667?ttl=1')
parser = argparse.ArgumentParser()
parser.add_argument('--load', type=str, action='store')
parser.add_argument('--teams', type=str, action='store')
args = parser.parse_args()
msg = ControlData()
msg.TeleopEnabled = False
msg.HaltRadio = False
msg.AutonomousEnabled = False
msg.RobotEnabled = False
msg.Stage = "Setup"
msg.Time = 0
start = time.time()
'''
while True:
msg.TeleopEnabled = True
msg.AutonomousEnabled = False
msg.RobotEnabled = True
msg.Stage = "Teleop"
msg.Time = round(time.time() - start)
lc.publish("PiEMOS4/Control", msg.encode())
print("sending control, time=" + str(msg.Time))
time.sleep(0.25)
'''
while time.time() - start < 2:
msg.Time = round(time.time() - start)
print("sending setup, time=" + str(msg.Time))
msg.AutonomousEnabled = True
msg.TeleopEnabled = False
msg.RobotEnabled = False
msg.Stage = "Setup"
lc.publish("PiEMOS1/Control", msg.encode())
lc.publish("PiEMOS2/Control", msg.encode())
lc.publish("PiEMOS3/Control", msg.encode())
lc.publish("PiEMOS4/Control", msg.encode())
time.sleep(0.25)
'''
while time.time() - start < 17:
msg.Time = round(time.time() - start)
msg.AutonomousEnabled = True
msg.TeleopEnabled = False
msg.RobotEnabled = True
msg.Stage = "Autonomous"
print("sending control, time=" + str(msg.Time))
lc.publish("PiEMOS4/Control", msg.encode())
time.sleep(0.25)
'''
while True:
msg.Time = round(time.time() - start)
msg.AutonomousEnabled = False
msg.TeleopEnabled = True
msg.RobotEnabled = True
msg.Stage = "Teleop"
print("sending teleop, time=" + str(msg.Time))
lc.publish("PiEMOS1/Control", msg.encode())
lc.publish("PiEMOS2/Control", msg.encode())
lc.publish("PiEMOS3/Control", msg.encode())
lc.publish("PiEMOS4/Control", msg.encode())
time.sleep(0.25)
if __name__ == '__main__':
main()