@@ -65,9 +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+
69+ def calc_third_derivative (self , t ):
70+ xt = 6 * self .a3 + 24 * self .a4 * t + 60 * self .a5 * t ** 2
6871
72+ return xt
6973
70- def quinic_polynomials_planner (sx , sy , syaw , sv , sa , gx , gy , gyaw , gv , ga , max_accel , dt ):
74+ def quinic_polynomials_planner (sx , sy , syaw , sv , sa , gx , gy , gyaw , gv , ga , max_accel , max_jerk , dt ):
7175 """
7276 quinic polynomial planner
7377
@@ -81,6 +85,7 @@ def quinic_polynomials_planner(sx, sy, syaw, sv, sa, gx, gy, gyaw, gv, ga, max_a
8185 gyaw: goal yaw angle [rad]
8286 ga: goal accel [m/ss]
8387 max_accel: maximum accel [m/ss]
88+ max_jerk: maximum jerk [m/sss]
8489 dt: time tick [s]
8590
8691 return
@@ -107,7 +112,7 @@ def quinic_polynomials_planner(sx, sy, syaw, sv, sa, gx, gy, gyaw, gv, ga, max_a
107112 xqp = quinic_polynomial (sx , vxs , axs , gx , vxg , axg , T )
108113 yqp = quinic_polynomial (sy , vys , ays , gy , vyg , ayg , T )
109114
110- time , rx , ry , ryaw , rv , ra = [], [], [], [], [], []
115+ time , rx , ry , ryaw , rv , ra , rj = [], [], [], [], [], [], []
111116
112117 for t in np .arange (0.0 , T + dt , dt ):
113118 time .append (t )
@@ -129,7 +134,14 @@ def quinic_polynomials_planner(sx, sy, syaw, sv, sa, gx, gy, gyaw, gv, ga, max_a
129134 pass
130135 ra .append (a )
131136
132- if max ([abs (i ) for i in ra ]) <= max_accel :
137+ jx = xqp .calc_third_derivative (t )
138+ jy = yqp .calc_third_derivative (t )
139+ j = np .hypot (ax , ay )
140+ if len (ra ) >= 2 and ra [- 1 ] - ra [- 2 ] < 0.0 :
141+ j *= - 1
142+ rj .append (j )
143+
144+ if max ([abs (i ) for i in ra ]) <= max_accel and max ([abs (i ) for i in rj ]) <= max_jerk :
133145 print ("find path!!" )
134146 break
135147
@@ -146,7 +158,7 @@ def quinic_polynomials_planner(sx, sy, syaw, sv, sa, gx, gy, gyaw, gv, ga, max_a
146158 " a[m/ss]:" + str (ra [i ])[0 :4 ])
147159 plt .pause (0.001 )
148160
149- return time , rx , ry , ryaw , rv , ra
161+ return time , rx , ry , ryaw , rv , ra , rj
150162
151163
152164def plot_arrow (x , y , yaw , length = 1.0 , width = 0.5 , fc = "r" , ec = "k" ):
@@ -177,10 +189,11 @@ def main():
177189 gv = 1.0 # goal speed [m/s]
178190 ga = 0.1 # goal accel [m/ss]
179191 max_accel = 1.0 # max accel [m/ss]
192+ max_jerk = 0.5 # max jerk [m/sss]
180193 dt = 0.1 # time tick [s]
181194
182- time , x , y , yaw , v , a = quinic_polynomials_planner (
183- sx , sy , syaw , sv , sa , gx , gy , gyaw , gv , ga , max_accel , dt )
195+ time , x , y , yaw , v , a , j = quinic_polynomials_planner (
196+ sx , sy , syaw , sv , sa , gx , gy , gyaw , gv , ga , max_accel , max_jerk , dt )
184197
185198 if show_animation :
186199 plt .plot (x , y , "-r" )
@@ -203,6 +216,12 @@ def main():
203216 plt .ylabel ("accel[m/ss]" )
204217 plt .grid (True )
205218
219+ plt .subplots ()
220+ plt .plot (time , j , "-r" )
221+ plt .xlabel ("Time[s]" )
222+ plt .ylabel ("jerk[m/sss]" )
223+ plt .grid (True )
224+
206225 plt .show ()
207226
208227
0 commit comments