Skip to content

BSpline

python_motion_planning.curve_generation.bspline_curve.BSpline

Bases: Curve

Class for B-Spline curve generation.

Parameters:

Name Type Description Default
step float

Simulation or interpolation size

required
k int

Degree of curve

required

Examples:

Python Console Session
>>> from python_motion_planning.curve_generation import BSpline
>>>     points = [(0, 0, 0), (10, 10, -90), (20, 5, 60)]
>>> generator = BSpline(step, k)
>>> generator.run(points)

approximation(points, param, knot)

Given a set of N data points, D0, D1, ..., Dn, a degree k, and a number H, where N > H > k >= 1, find a B-spline curve of degree k defined by H control points that satisfies the following conditions: 1. this curve contains the first and last data points; 2. this curve approximates the data polygon in the sense of least square

Parameters:

Name Type Description Default
points list[tuple]

path points

required
param list[float]

The parameters of given points

required
knot list[float]

The knot vector

Returns: control_points (np.ndarray): The control points

required

baseFunction(i, k, t, knot)

Calculate base function using Cox-deBoor function.

Parameters:

Name Type Description Default
i int

The index of base function

required
k int

The degree of curve

required
t float

parameter

required
knot list[float]

knot vector

required

Returns:

Name Type Description
Nik_t float

The value of base function Nik(t)

generation(t, k, knot, control_pts)

Generate the B-spline curve.

Parameters:

Name Type Description Default
t ndarray

The parameter values

required
k int

The degree of the B-spline curve

required
knot list[float]

The knot vector

required
control_pts ndarray

The control points

required

Returns:

Name Type Description
curve ndarray

The B-spline curve

interpolation(points, param, knot)

Given a set of N data points, D0, D1, ..., Dn and a degree k, find a B-spline curve of degree k defined by N control points that passes all data points in the given order.

Parameters:

Name Type Description Default
points list[tuple]

path points

required
param list[float]

The parameters of given points

required
knot list[float]

The knot vector

required

Returns:

Name Type Description
control_points ndarray

The control points

knotGeneration(param, n)

Generate knot vector.

Parameters:

Name Type Description Default
param list[float]

The parameters of given points

required
n int

The number of data points

Returns: knot (list[float]): The knot vector

required

paramSelection(points)

Calculate parameters using the uniform spaced or chrod length or centripetal method.

Parameters:

Name Type Description Default
points list[tuple]

path points

Returns: Parameters (list[float]): The parameters of given points

required

run(points, display=True)

Running both generation and animation.

Parameters:

Name Type Description Default
points list[tuple]

path points

required