-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobot_cmdline.py
70 lines (48 loc) · 1.4 KB
/
robot_cmdline.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
#!/usr/bin/env python3
"""
This application provides a CLI for the robots
"""
from docopt import docopt
from robot import Robot_Scheduler
from robot.Robot import Robot
from robot.robot_config import *
from subprocess import Popen, PIPE
from util import Logger
import time
# ---- Types of manual input ----
def user_input(logger):
print("\nOptions: N / T / L / U / D / F / B / X")
user_option = input("Enter option: ")
logger.info("User input - {}".format(user_option))
return user_option
def main():
config = (Logger.Log_Config.STREAM_LOG | Logger.Log_Config.FILE_LOG)
# Logging
logger = Logger()
# Robot
robot_id = "000"
robot_logger = logger.init("ROBOT", robot_id, config)
my_robot = Robot(robot_id, robot_logger)
sched = Robot_Scheduler(my_robot)
my_robot.register_scheduler(sched)
# ----- Manual User Loop -------
user_id = "000"
user_logger = logger.init("USER", user_id)
user_option = ""
robot_logger.info('User setup complete!')
while user_option != "X":
user_option = user_input(user_logger)
my_robot.queue_command(user_option)
time.sleep(2)
# Clean up
print("Exiting program...")
logger.close()
if log_file:
log_uart.close()
if serial_port or serial_file:
uart.close()
sched.close()
my_robot.close()
if __name__ == "__main__":
#main(args)
main()