-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
76 lines (61 loc) · 2.6 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
import sys
import getopt
from trconfig import Configuration
from trcalc import TrajectoryCalc
from trcalc import ConstV2TrCalc
from trcalc import LinearV2TrCalc
from trcalc import TrigonometricV2TrCalc
def main(argv):
help = "\nOption\tLongoption\tDescription\n\n-a\t--algorithm\tSet an Algorithm for steering angle calculation (constant,linear,trigonometric)\n-l\t--lenght\tSet length of Vehicle\n-s\t--steeringangle\tSet the Steering angle. Works only with constant steering angle algorithm\n-v\t--velocity\tSet the velocity at the rear angle\n-d\t--timedelta\tSet the time between each step. A small value approximates the path better, but needs more calculations\n-t\t--timeframe\tSet the total time of the simulation\n"
try:
opts, args = getopt.getopt(argv,"ha:l:s:v:d:t:",["algorithm=","length=","steeringangle=","velocity=","timedelta=","timeframe="])
except getopt.GetoptError:
print(help)
sys.exit(2)
algorithm = ""
length = 1
steeringangle = 0
velocity = 1
timedelta = 0.1
timeframe = 1
for opt, arg in opts:
if opt == '-h':
print(help)
sys.exit()
elif opt in ("-a","--algorithm"):
algorithm = arg
elif opt in ("-l","--lenght"):
length = float(arg)
elif opt in ("-s","--steeringangle"):
steeringangle = float(arg)
elif opt in ("-v","--velocity"):
velocity = float(arg)
elif opt in ("-d","--timedelta"):
timedelta = float(arg)
elif opt in ("-t","--timeframe"):
timeframe = float(arg)
sc = Configuration();
if algorithm == "constant":
if timedelta <= timeframe:
tr = ConstV2TrCalc(sc,length,velocity,timedelta,timeframe,steeringangle)
else:
print("Timedelta must be smaller than timeframe")
sys.exit()
elif algorithm == "linear":
if timedelta <= timeframe:
tr = LinearV2TrCalc(sc,length,velocity,timedelta,timeframe)
else:
print("Timedelta must be smaller than timeframe")
sys.exit()
elif algorithm == "trigonometric":
if timedelta <= timeframe:
tr = TrigonometricV2TrCalc(sc,length,velocity,timedelta,timeframe)
else:
print("Timedelta must be smaller than timeframe")
sys.exit()
else:
print("Please specify which algorithm to use")
sys.exit()
tr.plotTrajectory()
if __name__ == "__main__":
main(sys.argv[1:])