-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
executable file
·78 lines (65 loc) · 2.43 KB
/
main.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
#!/usr/bin/python
from derivations import *
from codegen import *
import os
import sys
import signal
import argparse
from multiprocessing import Process
import datetime
workers = []
def sigint_handler(sig, frame):
for p in workers:
if p.is_alive():
p.terminate()
print 'Terminated by Ctrl-C'
exit(0)
signal.signal(signal.SIGINT,sigint_handler)
parser = argparse.ArgumentParser()
parser.add_argument('--outputdir', nargs=1, dest='outdir', default=['output'])
parser.add_argument('--derive', nargs='*', dest='derive', default=[])
parser.add_argument('--codegen', dest='codegen', action='store_true')
args = parser.parse_args()
outdir = args.outdir[0]
if not os.path.exists(outdir):
os.makedirs(outdir)
predictionjson = os.path.join(outdir, 'covariancePrediction.json')
posnejson = os.path.join(outdir, 'posNEFusion.json')
posdjson = os.path.join(outdir, 'posDFusion.json')
velnejson = os.path.join(outdir, 'velNEFusion.json')
veldjson = os.path.join(outdir, 'velDFusion.json')
airspeedjson = os.path.join(outdir, 'airspeedFusion.json')
betajson = os.path.join(outdir, 'betaFusion.json')
magjson = os.path.join(outdir, 'magFusion.json')
yaw312json = os.path.join(outdir, 'yaw312Fusion.json')
yaw321json = os.path.join(outdir, 'yaw321Fusion.json')
flowjson = os.path.join(outdir, 'flowFusion.json')
declinationjson = os.path.join(outdir, 'declinationFusion.json')
c_header = os.path.join(outdir, 'ekf_defines.h')
derivations = {
'posne': (derivePosNEFusion, posnejson),
'posd': (derivePosDFusion, posdjson),
'velne': (deriveVelNEFusion, velnejson),
'veld': (deriveVelDFusion, veldjson),
'covpred': (deriveCovariancePrediction, predictionjson),
'airspeed': (deriveAirspeedFusion, airspeedjson),
'beta': (deriveBetaFusion, betajson),
'mag': (deriveMagFusion, magjson),
'yaw312': (deriveYaw312Fusion, yaw312json),
'yaw321': (deriveYaw321Fusion, yaw321json),
'flow': (deriveOptFlowFusion, flowjson),
'declination': (deriveDeclinationFusion, declinationjson)
}
assert set(args.derive).issubset(set(derivations.keys()+['all']))
if 'all' in args.derive:
args.derive = derivations.keys()
for k in args.derive:
workers.append(Process(target=derivations[k][0], args=(derivations[k][1],)))
workers[-1].start()
for p in workers:
p.join()
if args.codegen:
jsondict = {}
for key, val in derivations.iteritems():
jsondict[key] = val[1]
generateCode(jsondict,c_header)