-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmast_test.py
50 lines (35 loc) · 1.14 KB
/
mast_test.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
import time
from control import (
handle_operating_mode,
OperatingMode,
Mast,
XboxController,
SoundEffects,
handle_check_mode,
play_check_mode_sound,
)
def main():
max_angular_velocity = 20
mast = Mast(max_angular_velocity)
joy = XboxController()
sounds_effects = SoundEffects()
operating_mode = OperatingMode.EMERGENCY_STOP
while True:
control_inputs = joy.read()
new_operating_mode = handle_operating_mode(control_inputs["operating_mode"])
# Change Operating Mode
if new_operating_mode and operating_mode != new_operating_mode:
operating_mode = new_operating_mode
sounds_effects.play_change_mode()
# Notify currently active mode
if handle_check_mode(control_inputs["check_mode"]):
play_check_mode_sound(operating_mode, sounds_effects)
# Sending Commands to Mast
if operating_mode == OperatingMode.DRIVE:
mast.handle_input(*control_inputs["mast"])
else:
mast.stop_rotating()
mast.stop_tilting()
time.sleep(0.01)
if __name__ == "__main__":
main()