parameters: (self,
              waypointTrajectory: Trajectory,
              preventOvershoot: bool = True,
              loop: bool = False
          )
docstring: Computes natural velocities for a standard configuration-
          space Trajectory to make it smoother.
docstring_summary: Computes natural velocities for a standard configuration-
          space Trajectory to make it smoother.
docstring_tokens: Computes natural velocities for a standard configuration - space Trajectory to make it smoother .
function: def makeSpline(self,
              waypointTrajectory: Trajectory,
              preventOvershoot: bool = True,
              loop: bool = False
          ) -> None:
          """Computes natural velocities for a standard configuration-
          space Trajectory to make it smoother."""
          if loop and waypointTrajectory.milestones[-1] != waypointTrajectory.milestones[0]:
              raise ValueError("Asking for a loop trajectory but the endpoints don't match up")
          velocities = []
          t = waypointTrajectory
          d = len(t.milestones[0])
          if len(t.milestones)==1:
              velocities.append([0]*d)
          elif len(t.milestones)==2:
              if loop:
                  v = [0]*d
              else:
                  s = (1.0/(t.times[1]-t.times[0]) if (t.times[1]-t.times[0]) != 0 else 0)
                  v = vectorops.mul(vectorops.sub(t.milestones[1],t.milestones[0]),s) 
              velocities.append(v)
              velocities.append(v)
          else:
              third = 1.0/3.0
              N = len(waypointTrajectory.milestones)
              if loop:
                  timeiter = zip([-2]+list(range(N-1)),range(0,N),list(range(1,N))+[1])
              else:
                  timeiter = zip(range(0,N-2),range(1,N-1),range(2,N))
              for p,i,n in timeiter:
                  if p < 0:
                      dtp = t.times[-1] - t.times[-2]
                  else:
                      dtp = t.times[i] - t.times[p]
                  if n <= i:
                      dtn = t.times[1]-t.times[0]
                  else:
                      dtn = t.times[n]-t.times[i]
                  assert dtp >= 0 and dtn >= 0
                  s = (1.0/(dtp+dtn) if (dtp+dtn) != 0 else 0)
                  v = vectorops.mul(vectorops.sub(t.milestones[n],t.milestones[p]),s)
                  if preventOvershoot:
                      for j,(x,a,b) in enumerate(zip(t.milestones[i],t.milestones[p],t.milestones[n])):
                          if x <= min(a,b):
                              v[j] = 0.0
                          elif x >= max(a,b):
                              v[j] = 0.0
                          elif v[j] < 0 and x - v[j]*third*dtp >= a:
                              v[j] = 3.0/dtp*(x-a)
                          elif v[j] > 0 and x - v[j]*third*dtp <= a:
                              v[j] = 3.0/dtp*(x-a)
                          elif v[j] < 0 and x + v[j]*third*dtn < b:
                              v[j] = 3.0/dtn*(b-x)
                          elif v[j] > 0 and x + v[j]*third*dtn > b:
                              v[j] = 3.0/dtn*(b-x)
                          
                  velocities.append(v)
              if not loop:
                  #start velocity as quadratic
                  x2 = vectorops.madd(t.milestones[1],velocities[0],-third*(t.times[1]-t.times[0]))
                  x1 = vectorops.madd(x2,vectorops.sub(t.milestones[1],t.milestones[0]),-third)
                  v0 = vectorops.mul(vectorops.sub(x1,t.milestones[0]),3.0/(t.times[1]-t.times[0]))
                  #terminal velocity as quadratic
                  xn_2 = vectorops.madd(t.milestones[-2],velocities[-1],third*(t.times[-1]-t.times[-2]))
                  xn_1 = vectorops.madd(xn_2,vectorops.sub(t.milestones[-1],t.milestones[-2]),third)
                  vn = vectorops.mul(vectorops.sub(t.milestones[-1],xn_1),3.0/(t.times[-1]-t.times[-2]))
                  velocities = [v0]+velocities+[vn]
          self.__init__(waypointTrajectory.times[:],waypointTrajectory.milestones,velocities)
function_tokens: def makeSpline ( self , waypointTrajectory : Trajectory , preventOvershoot : bool = True , loop : bool = False ) -> None : if loop and waypointTrajectory . milestones [ - 1 ] != waypointTrajectory . milestones [ 0 ] : raise ValueError ( "Asking for a loop trajectory but the endpoints don't match up" ) velocities = [ ] t = waypointTrajectory d = len ( t . milestones [ 0 ] ) if len ( t . milestones ) == 1 : velocities . append ( [ 0 ] * d ) elif len ( t . milestones ) == 2 : if loop : v = [ 0 ] * d else : s = ( 1.0 / ( t . times [ 1 ] - t . times [ 0 ] ) if ( t . times [ 1 ] - t . times [ 0 ] ) != 0 else 0 ) v = vectorops . mul ( vectorops . sub ( t . milestones [ 1 ] , t . milestones [ 0 ] ) , s ) velocities . append ( v ) velocities . append ( v ) else : third = 1.0 / 3.0 N = len ( waypointTrajectory . milestones ) if loop : timeiter = zip ( [ - 2 ] + list ( range ( N - 1 ) ) , range ( 0 , N ) , list ( range ( 1 , N ) ) + [ 1 ] ) else : timeiter = zip ( range ( 0 , N - 2 ) , range ( 1 , N - 1 ) , range ( 2 , N ) ) for p , i , n in timeiter : if p < 0 : dtp = t . times [ - 1 ] - t . times [ - 2 ] else : dtp = t . times [ i ] - t . times [ p ] if n <= i : dtn = t . times [ 1 ] - t . times [ 0 ] else : dtn = t . times [ n ] - t . times [ i ] assert dtp >= 0 and dtn >= 0 s = ( 1.0 / ( dtp + dtn ) if ( dtp + dtn ) != 0 else 0 ) v = vectorops . mul ( vectorops . sub ( t . milestones [ n ] , t . milestones [ p ] ) , s ) if preventOvershoot : for j , ( x , a , b ) in enumerate ( zip ( t . milestones [ i ] , t . milestones [ p ] , t . milestones [ n ] ) ) : if x <= min ( a , b ) : v [ j ] = 0.0 elif x >= max ( a , b ) : v [ j ] = 0.0 elif v [ j ] < 0 and x - v [ j ] * third * dtp >= a : v [ j ] = 3.0 / dtp * ( x - a ) elif v [ j ] > 0 and x - v [ j ] * third * dtp <= a : v [ j ] = 3.0 / dtp * ( x - a ) elif v [ j ] < 0 and x + v [ j ] * third * dtn < b : v [ j ] = 3.0 / dtn * ( b - x ) elif v [ j ] > 0 and x + v [ j ] * third * dtn > b : v [ j ] = 3.0 / dtn * ( b - x ) velocities . append ( v ) if not loop : #start velocity as quadratic x2 = vectorops . madd ( t . milestones [ 1 ] , velocities [ 0 ] , - third * ( t . times [ 1 ] - t . times [ 0 ] ) ) x1 = vectorops . madd ( x2 , vectorops . sub ( t . milestones [ 1 ] , t . milestones [ 0 ] ) , - third ) v0 = vectorops . mul ( vectorops . sub ( x1 , t . milestones [ 0 ] ) , 3.0 / ( t . times [ 1 ] - t . times [ 0 ] ) ) #terminal velocity as quadratic xn_2 = vectorops . madd ( t . milestones [ - 2 ] , velocities [ - 1 ] , third * ( t . times [ - 1 ] - t . times [ - 2 ] ) ) xn_1 = vectorops . madd ( xn_2 , vectorops . sub ( t . milestones [ - 1 ] , t . milestones [ - 2 ] ) , third ) vn = vectorops . mul ( vectorops . sub ( t . milestones [ - 1 ] , xn_1 ) , 3.0 / ( t . times [ - 1 ] - t . times [ - 2 ] ) ) velocities = [ v0 ] + velocities + [ vn ] self . __init__ ( waypointTrajectory . times [ : ] , waypointTrajectory . milestones , velocities )