Skip to content

Commit d54297d

Browse files
committed
fix jerk calc bug and code cleanup
1 parent ba884e7 commit d54297d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

PathPlanning/QuinticPolynomialsPlanner/quintic_polynomials_planner.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ def calc_second_derivative(self, t):
6565
xt = 2 * self.a2 + 6 * self.a3 * t + 12 * self.a4 * t**2 + 20 * self.a5 * t**3
6666

6767
return xt
68-
68+
6969
def calc_third_derivative(self, t):
7070
xt = 6 * self.a3 + 24 * self.a4 * t + 60 * self.a5 * t**2
7171

7272
return xt
7373

74+
7475
def quinic_polynomials_planner(sx, sy, syaw, sv, sa, gx, gy, gyaw, gv, ga, max_accel, max_jerk, dt):
7576
"""
7677
quinic polynomial planner
@@ -112,7 +113,7 @@ def quinic_polynomials_planner(sx, sy, syaw, sv, sa, gx, gy, gyaw, gv, ga, max_a
112113
xqp = quinic_polynomial(sx, vxs, axs, gx, vxg, axg, T)
113114
yqp = quinic_polynomial(sy, vys, ays, gy, vyg, ayg, T)
114115

115-
time, rx, ry, ryaw, rv, ra, rj = [], [], [], [], [], [], []
116+
time, rx, ry, ryaw, rv, ra, rj = [], [], [], [], [], [], []
116117

117118
for t in np.arange(0.0, T + dt, dt):
118119
time.append(t)
@@ -131,12 +132,11 @@ def quinic_polynomials_planner(sx, sy, syaw, sv, sa, gx, gy, gyaw, gv, ga, max_a
131132
a = np.hypot(ax, ay)
132133
if len(rv) >= 2 and rv[-1] - rv[-2] < 0.0:
133134
a *= -1
134-
pass
135135
ra.append(a)
136136

137137
jx = xqp.calc_third_derivative(t)
138138
jy = yqp.calc_third_derivative(t)
139-
j = np.hypot(ax, ay)
139+
j = np.hypot(jx, jy)
140140
if len(ra) >= 2 and ra[-1] - ra[-2] < 0.0:
141141
j *= -1
142142
rj.append(j)
@@ -155,14 +155,16 @@ def quinic_polynomials_planner(sx, sy, syaw, sv, sa, gx, gy, gyaw, gv, ga, max_a
155155
plot_arrow(rx[i], ry[i], ryaw[i])
156156
plt.title("Time[s]:" + str(time[i])[0:4] +
157157
" v[m/s]:" + str(rv[i])[0:4] +
158-
" a[m/ss]:" + str(ra[i])[0:4])
158+
" a[m/ss]:" + str(ra[i])[0:4] +
159+
" jerk[m/sss]:" + str(rj[i])[0:4],
160+
)
159161
plt.pause(0.001)
160162

161163
return time, rx, ry, ryaw, rv, ra, rj
162164

163165

164166
def plot_arrow(x, y, yaw, length=1.0, width=0.5, fc="r", ec="k"):
165-
u"""
167+
"""
166168
Plot arrow
167169
"""
168170

0 commit comments

Comments
 (0)