-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestPathGeneration.py
70 lines (47 loc) · 1.46 KB
/
testPathGeneration.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
import matplotlib.pyplot as plt
from utils.vehicles import *
from utils.paths import *
from utils.pathgeneration import *
import scipy.io as sio
import numpy as np
veh = Vehicle(vehicleName = "shelley")
# #Create path object
track = Path()
track.loadFromMAT("maps/THcenter.mat")
# #load in road bounds
bounds = sio.loadmat('maps/thunderhill_bounds_shifted.mat')
rpg = RapidPathGeneration(veh, track, bounds, mu = 0.9, NUM_ITERS = 5)
results = rpg.optimize()
vps = results.vps
opt = results.opt
logs = results.logFiles
paths = results.path
lapTimes = results.lapTimes
opt_e = opt[1]["e"]
opt_left = opt[1]["widthLeft"]
opt_right = opt[1]["widthRight"]
optPosE = opt[1]["posE"]
optPosN = opt[1]["posN"]
optS = opt[1]["s"]
optK = opt[1]["K"]
plt.figure()
plt.plot(opt_e, label = "opt")
plt.plot(opt_left, label = "left")
plt.plot(opt_right, label = "right")
plt.legend()
refPath = paths[0]
optPath = paths[1]
plt.figure()
plt.plot(optPosE, optPosN,'bo', label = "raw opt")
plt.plot(refPath["posE"], refPath["posN"], label = "ref path")
plt.plot(optPath["posE"], optPath["posN"], label = "processed opt")
plt.plot(bounds["in"][:,0], bounds["in"][:,1],'k', label = "bounds")
plt.plot(bounds["out"][:,0], bounds["out"][:,1],'k', label = "bounds")
plt.axis("equal")
plt.legend()
plt.figure()
plt.plot(refPath["s"], refPath["K"], label = "ref path")
plt.plot(optS, optK, label = "raw opt")
plt.plot(optPath["s"], optPath["K"], label = "refined opt")
plt.legend()
plt.show()