@@ -101,7 +101,7 @@ def qd(self):
101101 @property
102102 def qdd (self ):
103103 """
104- Velocity trajectory
104+ Acceleration trajectory
105105
106106 :return: trajectory acceleration with one row per timestep, one column per axis
107107 :rtype: ndarray(n,m)
@@ -180,15 +180,23 @@ def plot(self, block=False, plotargs=None, textargs=None):
180180 ax .plot (self .t [k ], self .s [k ], color = "green" , ** plotopts )
181181 k = np .where (k )[0 ][0 ]
182182 ax .plot (
183- self .t [k - 1 : k + 1 ], self .s [k - 1 : k + 1 ], color = "green" , label = "linear" , ** plotopts
183+ self .t [k - 1 : k + 1 ],
184+ self .s [k - 1 : k + 1 ],
185+ color = "green" ,
186+ label = "linear" ,
187+ ** plotopts ,
184188 )
185189
186190 # decel phase
187191 k = self .t > (tf - self .tblend )
188192 ax .plot (self .t [k ], self .s [k ], color = "blue" , ** plotopts )
189193 k = np .where (k )[0 ][0 ]
190194 ax .plot (
191- self .t [k - 1 : k + 1 ], self .s [k - 1 : k + 1 ], color = "blue" , label = "deceleration" , ** plotopts
195+ self .t [k - 1 : k + 1 ],
196+ self .s [k - 1 : k + 1 ],
197+ color = "blue" ,
198+ label = "deceleration" ,
199+ ** plotopts ,
192200 )
193201
194202 ax .grid (True )
@@ -317,11 +325,11 @@ def quintic_func(q0, qf, T, qd0=0, qdf=0):
317325 # solve for the polynomial coefficients using least squares
318326 X = [
319327 [0 , 0 , 0 , 0 , 0 , 1 ],
320- [T ** 5 , T ** 4 , T ** 3 , T ** 2 , T , 1 ],
328+ [T ** 5 , T ** 4 , T ** 3 , T ** 2 , T , 1 ],
321329 [0 , 0 , 0 , 0 , 1 , 0 ],
322- [5 * T ** 4 , 4 * T ** 3 , 3 * T ** 2 , 2 * T , 1 , 0 ],
330+ [5 * T ** 4 , 4 * T ** 3 , 3 * T ** 2 , 2 * T , 1 , 0 ],
323331 [0 , 0 , 0 , 2 , 0 , 0 ],
324- [20 * T ** 3 , 12 * T ** 2 , 6 * T , 2 , 0 , 0 ],
332+ [20 * T ** 3 , 12 * T ** 2 , 6 * T , 2 , 0 , 0 ],
325333 ]
326334 coeffs , resid , rank , s = np .linalg .lstsq (
327335 X , np .r_ [q0 , qf , qd0 , qdf , 0 , 0 ], rcond = None
@@ -340,10 +348,12 @@ def quintic_func(q0, qf, T, qd0=0, qdf=0):
340348
341349# -------------------------------------------------------------------------- #
342350
351+
343352def lspb (* args , ** kwargs ):
344353 warnings .warn ("lsp is deprecated, use trapezoidal" , FutureWarning )
345354 return trapezoidal (* args , ** kwargs )
346355
356+
347357def trapezoidal (q0 , qf , t , V = None ):
348358 """
349359 Scalar trapezoidal trajectory
@@ -459,7 +469,7 @@ def trapezoidalfunc(t):
459469 pddk = 0
460470 elif tk <= tb :
461471 # initial blend
462- pk = q0 + a / 2 * tk ** 2
472+ pk = q0 + a / 2 * tk ** 2
463473 pdk = a * tk
464474 pddk = a
465475 elif tk <= (tf - tb ):
@@ -469,7 +479,7 @@ def trapezoidalfunc(t):
469479 pddk = 0
470480 elif tk <= tf :
471481 # final blend
472- pk = qf - a / 2 * tf ** 2 + a * tf * tk - a / 2 * tk ** 2
482+ pk = qf - a / 2 * tf ** 2 + a * tf * tk - a / 2 * tk ** 2
473483 pdk = a * tf - a * tk
474484 pddk = - a
475485 else :
@@ -567,7 +577,7 @@ def jtraj(q0, qf, t, qd0=None, qd1=None):
567577
568578 # n = len(q0)
569579
570- tt = np .array ([ts ** 5 , ts ** 4 , ts ** 3 , ts ** 2 , ts , np .ones (ts .shape )]).T
580+ tt = np .array ([ts ** 5 , ts ** 4 , ts ** 3 , ts ** 2 , ts , np .ones (ts .shape )]).T
571581 coeffs = np .array ([A , B , C , np .zeros (A .shape ), E , F ]) # 6xN
572582
573583 qt = tt @ coeffs
@@ -580,7 +590,7 @@ def jtraj(q0, qf, t, qd0=None, qd1=None):
580590 coeffs = np .array (
581591 [np .zeros (A .shape ), np .zeros (A .shape ), 20 * A , 12 * B , 6 * C , np .zeros (A .shape )]
582592 )
583- qddt = tt @ coeffs / tscal ** 2
593+ qddt = tt @ coeffs / tscal ** 2
584594
585595 return Trajectory ("jtraj" , tv , qt , qdt , qddt , istime = True )
586596
@@ -648,8 +658,6 @@ def mtraj(tfunc, q0, qf, t):
648658 return Trajectory ("mtraj" , x , y , yd , ydd , istime )
649659
650660
651-
652-
653661# -------------------------------------------------------------------------- #
654662
655663
@@ -1012,7 +1020,8 @@ def mrange(start, stop, step):
10121020 # t.plot(block=True)
10131021
10141022 from roboticstoolbox import *
1023+
10151024 puma = models .DH .Puma560 ()
10161025
10171026 traj = jtraj (puma .qz , puma .qr , 100 )
1018- traj .plot (block = True )
1027+ traj .plot (block = True )
0 commit comments