test_BSpline
- test_BSpline.test_BSpline(show_plots, P, XDot_flag, XDDot_flag, accuracy)[source]
Validation Test Description
This unit test script tests the capability of the BSpline function to correctly interpolate a series of points in 3 dimensions. The coordinates of these 7 points are stored in 3 numpy arrays:
X1 = np.array([0, 1, 2, 3, 4, 5, 6])
X2 = np.array([5, 4, 3, 2, 1, 0, 1])
X3 = np.array([3, 2, 1, 2, 3, 4, 5]).
The input arrays are initialized through
Input = BSpline.InputDataSet(X1, X2, X3). The time tags at which each waypoint is to be hit are provided throughInput.setT([0, 2, 3, 5, 7, 8, 10]). Alternatively, it is possible to specify the average velocity norm throughInput.setAvgXDot(). The endpoint derivatives are specified through the methods:Input.setXDot_0()for starting point first-order derivative;Input.setXDot_N()for last point first-order derivative;Input.setXDDot_0()for starting point second-order derivative;Input.setXDDot_N()for last point second-order derivative.
Each method to specify the derivatives takes in a 3-dimensional numpy array. The output data structure is created with
Output = BSpline.OutputDataSet(). The interpolation happens calling the methodBSpline.interpolate(Input, N, P, Output)where:N is the desired number of equally spaced data points in the interpolated function;
P is the polynomial order of the B-Spline function. The order should be at least 3 when first-order derivatives are specified, and 5 when second-order derivatives are specified. The maximum oder is P = n + k - 1, with n being the number of waypoints and k being the number of endpoint derivatives that are being specified.
Test Parameters
As this is a parameterized unit test, note that the test case parameters values are shown automatically in the pytest HTML report. This sample script has the parameters param1 and param 2. Provide a description of what each parameter controls. This is a convenient location to include the accuracy variable used in the validation test.
- Parameters:
P (int) – polynomial order of the B-Spline curve;
XDot_flag (bool) – whether the first-order end point derivatives should be specified;
XDDot_flag (bool) – whether the second-order end point derivatives should be specified;
accuracy (float) – absolute accuracy value used in the validation tests.
Description of Variables Being Tested
This unit test checks the correctness of the interpolated function: - a check is performed on whether or not each waypoint is hit at the specified time; - when the derivatives are specified, it checks whether the starting point derivative actually matches the input derivative.
- test_BSpline.test_approximate_acceleration_requires_velocity_at_same_endpoint(endpoint)[source]
Require velocity at the accelerated endpoint even if the other velocity is set.
- test_BSpline.test_approximate_endpoint_constraints(start_derivative_order, end_derivative_order)[source]
Check positions and requested derivatives at both approximation endpoints.
Each endpoint independently constrains position only, position and velocity, or position, velocity, and acceleration. Distinct nonzero vector components expose incorrect constraint-vector indexing, including GitHub issue 1563. Nonuniform time tags also exercise derivative scaling by the total duration.
- Parameters:
start_derivative_order – Highest derivative constrained at the start.
end_derivative_order – Highest derivative constrained at the end.
- test_BSpline.test_approximate_free_control_point_limit()[source]
One interior waypoint can determine one free control point.
- test_BSpline.test_approximate_interior_knots()[source]
Reject a knot at the clamped start or without bracketing times, then fit a valid layout.
- test_BSpline.test_approximate_interior_weights()[source]
A symmetric quadratic gives both interior samples their weighted mean.
- test_BSpline.test_approximate_zero_weight_waypoints(offset)[source]
Ignore a zero-weight outlier and reject weights that leave a control point undetermined.
- test_BSpline.test_default_input_flags_and_weight_lengths()[source]
Fit manually supplied coordinates with optional inputs disabled and validate active weights.
- test_BSpline.test_public_fit_waypoint_lengths(fit, args)[source]
Reject invalid lengths before changing the output and fit again after correction.