BSpline

Functions

void interpolate(const InputDataSet &Input, int Num, int P, OutputDataSet *Output)

This function takes the Input structure, performs the BSpline interpolation and outputs the result into Output structure

void approximate(const InputDataSet &Input, int Num, int Q, int P, OutputDataSet *Output)

Fit a least-squares spline to the supplied waypoints.

This function takes the Input structure, performs the BSpline LS approximation and outputs the result into Output structure

Parameters:
  • Input – Waypoints and optional constraints. Each endpoint acceleration requires velocity at the same endpoint.

  • Num – Number of output samples.

  • Q – Last control-point index. Each free control point requires at least one interior waypoint.

  • P – Polynomial degree. The resulting Q - P interior knots must lie strictly between the endpoints.

  • Output – Fitted spline and sampled states.

void basisFunction(double t, const Eigen::VectorXd &U, int I, int P, double *NN, double *NN1, double *NN2)

This function calculates the basis functions NN of order P, and derivatives NN1, NN2, for a given time t and knot vector U

class InputDataSet
#include <BSpline.h>

The InputDataSet class contains the information about the points that must be interpolated. It is used as a data structure to initialize the inputs that are passed to the interpolating function.

Public Functions

InputDataSet()

This constructor initializes an Input structure for BSpline interpolation

InputDataSet(const Eigen::VectorXd &X1, const Eigen::VectorXd &X2, const Eigen::VectorXd &X3)

The constructor requires 3 N-dimensional vectors containing the coordinates of the waypoints

~InputDataSet()

Generic destructor

void setXDot_0(Eigen::Vector3d XDot_0)

Set the first derivative of the starting point (optional)

void setXDot_N(Eigen::Vector3d XDot_N)

Set the first derivative of the last point (optional)

void setXDDot_0(Eigen::Vector3d XDDot_0)

Set the second derivative of the starting point (optional)

void setXDDot_N(Eigen::Vector3d XDDot_N)

Set the second derivative of the last point (optional)

void setT(const Eigen::VectorXd &T)

Set the time tags for each waypoint (optional). Cannot be imposed together with avg velocity norm below

void setW(const Eigen::VectorXd &W)

Set the weights for each waypoint. Weights are used in the LS approximation

void setAvgXDot(double AvgXDot)

Set the average velocity norm (optional). Cannot be imposed together with time tag vector above

Public Members

double AvgXDot = 0.0

[coordinate units/s] desired average velocity norm

Eigen::VectorXd T

[s] Waypoint times, finite and strictly increasing from zero

Eigen::VectorXd W

Waypoint weights, finite and nonnegative for interior points.

Eigen::VectorXd X1

coordinate #1 of the waypoints

Eigen::VectorXd X2

coordinate #2 of the waypoints

Eigen::VectorXd X3

coordinate #3 of the waypoints

Eigen::Vector3d XDot_0 = Eigen::Vector3d::Zero()

First derivative at the starting point.

Eigen::Vector3d XDot_N = Eigen::Vector3d::Zero()

First derivative at the final point.

Eigen::Vector3d XDDot_0 = Eigen::Vector3d::Zero()

Second derivative at the starting point.

Eigen::Vector3d XDDot_N = Eigen::Vector3d::Zero()

Second derivative at the final point.

bool T_flag = false

indicates that time tags have been specified; if true, AvgXDot_flag is false

bool AvgXDot_flag = false

indicates that avg velocity norm has been specified; if true, T_flag is false

bool W_flag = false

indicates that weight vector has been specified

bool XDot_0_flag = false

indicates that first derivative at starting point has been specified

bool XDot_N_flag = false

indicates that first derivative at final point has been specified

bool XDDot_0_flag = false

indicates that second derivative at starting point has been specified

bool XDDot_N_flag = false

indicates that second derivative at final point has been specified

class OutputDataSet
#include <BSpline.h>

The OutputDataSet class is used as a data structure to contain the interpolated function and its first- and second-order derivatives, together with the time-tag vector T.

Public Functions

OutputDataSet()

This constructor initializes an Output structure for BSpline interpolation

~OutputDataSet()

Generic destructor

void getData(double t, double x[3], double xDot[3], double xDDot[3])

This method returns x, xDot and xDDot at the desired input time T

double getStates(double t, int derivative, int index)

This method returns single coordinates of x, xDot and xDDot at the desired input time T.

It is designed to be accessible from Python

Public Members

Eigen::VectorXd T

time tags for each point of the interpolated trajectory

Eigen::VectorXd X1

coordinate #1 of the interpolated trajectory

Eigen::VectorXd X2

coordinate #2 of the interpolated trajectory

Eigen::VectorXd X3

coordinate #3 of the interpolated trajectory

Eigen::VectorXd XD1

first derivative of coordinate #1 of the interpolated trajectory

Eigen::VectorXd XD2

first derivative of coordinate #2 of the interpolated trajectory

Eigen::VectorXd XD3

first derivative of coordinate #3 of the interpolated trajectory

Eigen::VectorXd XDD1

second derivative of coordinate #1 of the interpolated trajectory

Eigen::VectorXd XDD2

second derivative of coordinate #2 of the interpolated trajectory

Eigen::VectorXd XDD3

second derivative of coordinate #3 of the interpolated trajectory

int P

polynomial degree of the BSpline

Eigen::VectorXd U

knot vector of the BSpline

Eigen::VectorXd C1

coordinate #1 of the control points

Eigen::VectorXd C2

coordinate #2 of the control points

Eigen::VectorXd C3

coordinate #3 of the control points