-
Notifications
You must be signed in to change notification settings - Fork 42
/
viz_traj.py
executable file
·93 lines (70 loc) · 1.74 KB
/
viz_traj.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/python
import matplotlib.pyplot as plt
import math
import sys
if len(sys.argv) > 1:
lane_data_file = sys.argv[1]
else:
lane_data_file = "./test_data/lane_data.txt"
smoothed_path = open(lane_data_file + ".traj", 'r')
a_star_path = open(lane_data_file + ".traj.astar", 'r')
# draw smoothed path
x = []
y = []
theta = []
kappa = []
for line in smoothed_path:
point = line.split(',')
x.append(float(point[0]))
y.append(float(point[1]))
theta.append(float(point[2]))
kappa.append(float(point[3]))
plt.subplot(2, 1, 1)
plt.axis('equal')
plt.plot(x, y, 'g-', label='smooted traj')
plt.legend(loc='upper left')
# plt.plot(x, kappa, 'g-')
u = []
v = []
for t in theta:
u.append(0.5 * math.cos(t))
v.append(0.5 * math.sin(t))
plt.quiver(x, y, u, v, angles='uv', color='g', width=0.002)
plt.xlabel('x')
plt.ylabel('y')
plt.subplot(2, 1, 2)
# plt.plot(x, theta, 'g-')
plt.axis('equal')
plt.plot(x, kappa, 'g-', label='smoothed kappa')
plt.legend(loc='upper left')
plt.xlabel('x')
plt.ylabel('kappa')
# draw a-star raw path
x = []
y = []
theta = []
kappa = []
for line in a_star_path:
point = line.split(',')
x.append(float(point[0]))
y.append(float(point[1]))
theta.append(float(point[2]))
kappa.append(float(point[3]))
plt.subplot(2, 1, 1)
plt.axis('equal')
plt.plot(x, y, 'r-', label='hybrid-a-star traj')
plt.legend(loc='upper left')
# plt.plot(x, kappa, 'r--')
u = []
v = []
for t in theta:
u.append(0.5 * math.cos(t))
v.append(0.5 * math.sin(t))
plt.quiver(x, y, u, v, angles='uv', color='r', width=0.002)
plt.subplot(2, 1, 2)
# plt.plot(x, theta)
plt.axis('equal')
plt.plot(x, kappa, 'r-', label='hybrid-a-star kappa')
plt.legend(loc='upper left')
plt.savefig(lane_data_file+".png")
plt.show()