-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
80 lines (55 loc) · 2.19 KB
/
Main.py
File metadata and controls
80 lines (55 loc) · 2.19 KB
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
import argparse
import time
import traceback
def GetCliAction():
print("")
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("-a", "--action", type = str, help = "what action to take. Must be one of the following: " + str(["help", "calibrate", "activate"]))
args = arg_parser.parse_args()
action = args.action
if action is None:
print(" [Error]: You need to specify an action with the --action argument, i.e. --action [flag].")
print(" For more information, try: --action help")
exit()
return action
def Main():
start_time = time.time()
actions = {"help": "help", "calibrate_tracker": "calibrate_tracker", "calibrate_depth": "calibrate_depth", "calibrate_space": "calibrate_space", "activate": "activate"}
action = GetCliAction()
if action not in actions:
action = actions["help"]
if action == actions["calibrate_tracker"]:
import calibration.TrackerCalibration as TrackerCalibration
calibrator = TrackerCalibration.TrackerCalibration()
calibrator.Execute()
if action == actions["calibrate_depth"]:
import calibration.DepthCalibration as DepthCalibration
calibrator = DepthCalibration.DepthCalibration()
calibrator.Execute()
if action == actions["calibrate_space"]:
import calibration.SpaceCalibration as SpaceCalibration
calibrator = SpaceCalibration.SpaceCalibration()
calibrator.Execute()
if action == actions["activate"]:
import Phantom4Controller
controller = Phantom4Controller.Phantom4Controller(5000)
try:
controller.Execute()
except Exception:
print('\007')
traceback.print_exc()
if action == "help":
print(" [P4CK] Phantom 4 Conversion Kit")
print(" The P4CK is a software suite built to convert a Phantom 4 Pro from a manual FPV drone into an autonomous TPV drone.")
print(" Usage:")
print(" python Main.py --action [OPTIONS]")
print(" python Main.py -a [OPTIONS]")
print(" Options:")
print(" help Show this screen.")
print(" calibrate Opens the spatial calibration UI")
print(" activate Activates the control software")
runtime = time.time() - start_time
runtime = "{:.2f}".format(runtime)
print("\n[" + action + "]: Operation complete")
print(" Total runtime: " + runtime + " sec\n")
Main()