/gsplines

Generalized splines library

Primary LanguagePythonMIT LicenseMIT

General Splines Library

This is a library to compute generalized splines passing through a series of points given a sequence of intervals.

Motivation

Generalized splines appear naturally in problems of trajectory optimization when waypoint constraints are added. In other words, if we desire to optimize a motion which pass trough a sequence of positions we will meet with generalized splines.

Generalized splines trajectories arising in such kind of optimization problems are uniquely characterized by the waypoints that they attain, the time intervals between waypoints and the speed, and possible higher order derivatives at the boundaries. Moreover, such a relation is synthesised in the expression of the type

where is a matrix which depends on the time intervals , is a column vector which depends on the waypoints , the speed, and possible higher order derivatives at the boundaries, and is a column vector which represents uniquely the curve at each interval.

The main challenge to build into a computer a trajectory optimization problems with waypoint constraints is to compute the derivatives of with respect to .

This library provides a uniform and simple interface to formulate gradient-based optimization problems for waypoint-constrained trajectory planning. The library leverage on the representation (0) to compute the "derivatives of the splines" with respect to the time intervals (and possibly the waypoints) as the corresponding derivatives of

Background

This library is aimed to find a trajectory passing trough a sequence of waypoints such that the following integral is minized

It may be proven that such a problem can be subdivided in two steps
  1. Find the family of optimal curves that joint waypoints
  2. Compute time instants where the optimal curves must be attached

The step 1. is done by solving a linear ordinary differential equation. One method to achieve 2. is to formulate an optimization problem (e.g. a gradient based one).

Optimal curves

We underline that this library leverages on the general theory of linear ODEs. It may be proven that any optimal of (1) solves the following linear ODE, which turn out to be the Euler-Lagrange equations at each interval

with the following boundary conditions

Because the ODE (2) is linear, we can compute its general suction depending on the value of the coefficients

.

In fact, the general solution of (2) may be written as a piecewise function defined at each interval as

where , depend on the coefficients and are column vectors in which represents the curve uniquely at the interval .

If we stack the column vectors in a suitable way we obtain the column vector used in (0). In fact, the equation (0) is obtained after applying to (4) the waypoint constrains and the boundary conditions.

After substituting (4) in (1) we obtain the following expression

Finally we can substitute (0) in (5) to obtain the representation of (1) subject to the waypoint constrains as a function of real variables:

Software architecture

From the formalization of the optimization problem, we derive that a flexible and uniform methodology for the construction of the problem of optimizing (1) consists in designing an abstract representation of the basis in (4) capable of building in an automatic fashion the constraint (0), the cost function (5) and their derivatives.

In fact, note that the input of any gradient-based optimizer is the expression (6) and its derivatives. This library provides a template class to represent the basis and a series of procedures which utilizes these basis as an input and then generate (0), (6) and their derivatives.

Implemented basis

Up to now we have implemented tree types of basis

  • Basis for the minimum jerk problems, called cBasis0010, because their optimize the L2-norm of the jerk

  • Basis for the weighed speed-jerk problems, called cBasis1010, because their optimize convex combination of the L2-norm of the speed and the L2 norm of the jerk

Requirements

  • numpy
  • scipy
  • matplotlib