test.py 1.07 KB
 Steve Tonneau committed Mar 14, 2017 1 ``````from spline import bezier, spline, exact_cubic, spline_constraints, spline_constraints, spline_deriv_constraint `````` Steve Tonneau committed Mar 13, 2017 2 3 4 `````` from numpy import matrix `````` Steve Tonneau committed Mar 14, 2017 5 ``````waypoints = matrix([[1.,2.,3.],[4.,5.,6.]]).transpose() `````` Steve Tonneau committed Mar 14, 2017 6 ``````time_waypoints = matrix([0.,1.]) `````` Steve Tonneau committed Mar 14, 2017 7 `````` `````` Steve Tonneau committed Mar 13, 2017 8 ``````#testing bezier curve `````` Steve Tonneau committed Mar 14, 2017 9 10 11 12 13 ``````a = bezier(waypoints) a = bezier(waypoints, -1., 3.) a.min() a.max() a(0.4) `````` Steve Tonneau committed Mar 14, 2017 14 15 16 17 ``````assert((a.derivate(0.4,0) == a(0.4)).all()) a.derivate(0.4,2) a = a.compute_derivate(100) `````` Steve Tonneau committed Mar 14, 2017 18 19 20 21 22 `````` #testing spline function a = spline(waypoints) a = spline(waypoints, -1., 3.) `````` Steve Tonneau committed Mar 13, 2017 23 24 25 ``````a.min() a.max() a(0.4) `````` Steve Tonneau committed Mar 14, 2017 26 27 ``````assert((a.derivate(0.4,0) == a(0.4)).all()) a.derivate(0.4,2) `````` Steve Tonneau committed Mar 14, 2017 28 29 30 31 32 33 34 35 `````` #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) `````` Steve Tonneau committed Mar 14, 2017 36 37 38 `````` #testing spline_deriv_constraints c = spline_constraints(); `````` Steve Tonneau committed Mar 14, 2017 39 ``````c.init_vel; `````` Steve Tonneau committed Mar 14, 2017 40 41 42 43 44 45 46 ``````c.end_vel; c.init_acc; c.end_acc; c.init_vel = matrix([0.,1.,1.]); c.end_vel = matrix([0.,1.,1.]); `````` Steve Tonneau committed Mar 14, 2017 47 ``````c.init_acc = matrix([0.,1.,1.]); `````` Steve Tonneau committed Mar 14, 2017 48 ``````c.end_acc = matrix([0.,1.,1.]); `````` Steve Tonneau committed Mar 14, 2017 49 50 51 `````` a = spline_deriv_constraint (waypoints, time_waypoints) a = spline_deriv_constraint (waypoints, time_waypoints, c)``````