Skip to content
Snippets Groups Projects
test.py 1009 B
Newer Older
from spline import bezier, spline, exact_cubic, spline_constraints, spline_constraints, spline_deriv_constraint

from numpy import matrix

waypoints = matrix([[1.,2.,3.],[4.,5.,6.]]).transpose()
Steve Tonneau's avatar
Steve Tonneau committed
time_waypoints = matrix([0.,1.])
a = bezier(waypoints)
a = bezier(waypoints, -1., 3.)
a.min()
a.max()
a(0.4)


#testing spline function
a = spline(waypoints)
a = spline(waypoints, -1., 3.)
assert((a.derivate(0.4,0) == a(0.4)).all())
a.derivate(0.4,2)
Steve Tonneau's avatar
Steve Tonneau committed

#testing exact_cubic function
a = exact_cubic(waypoints, time_waypoints)
a.min()
a.max()
a(0.4)
assert((a.derivate(0.4,0) == a(0.4)).all())
a.derivate(0.4,2)

#testing spline_deriv_constraints
c = spline_constraints();
Steve Tonneau's avatar
Steve Tonneau committed
c.init_vel; 
c.end_vel;
c.init_acc;
c.end_acc;


c.init_vel = matrix([0.,1.,1.]);
c.end_vel  = matrix([0.,1.,1.]);
c.init_acc = matrix([0.,1.,1.]);
c.end_acc  = matrix([0.,1.,1.]);

a = spline_deriv_constraint (waypoints, time_waypoints)
a = spline_deriv_constraint (waypoints, time_waypoints, c)