Library to represent and formulate motion and trajectory planning problems with generalized splines and piece-wise polynomials.
- Generalized splines as a
GSpline
class. They can represent- Piecewise polynomial curves representation
- Piecewise Lagrange polynomials at (interpolation at Gauss-Lobatto points already implemented).
-
Analytically consistency
GSpline
provide aderivate
method which returns its derivative as a newGSpline
instance. This library provides automatic exact ($\matcal{O}(n^2)$) differentiation of the generalized splines implemented. -
Algebraic consistency: This library implements basic operations between
GSplines
inner product, norms, addition, multiplication, composition and concatenation of curves (allows only when it has mathematical sense).
- Optimization with waypoint (via-point) constraints: minimum jerk, snap, crank, etc.
- ROS 1 implementation visit this link
- MoveIt implementation visit this link
- Minimum time path-consistent stop visit this link
- Contact: Rafael A. Rojas [email protected]
-
Docker containers with this library installed
- vim awesome plugins for development and moveit rafa606/moveit-gsplines-vim-dev:noetic
- vim awesome plugins for development and awesome ros packages rafa606/ros-gsplines-vim-dev:noetic
Get your minimum-X trajectory passing through random waypoints
import numpy as np
import gsplines
import gsplines.plot
import gsplines.optimization
numberOfWaypoints = 4
dimensionOfAmbientSpace = 2
waypoints = np.random.rand(numberOfWaypoints, dimensionOfAmbientSpace)
c1 = gsplines.optimization.broken_lines_path(waypoints)
c2 = gsplines.optimization.minimum_acceleration_path(waypoints)
c3 = gsplines.optimization.minimum_jerk_path(waypoints)
c4 = gsplines.optimization.minimum_snap_path(waypoints)
c5 = gsplines.optimization.minimum_crackle_path(waypoints) # Numerically unstable !
gsplines.plot.plot2d_compare([c1, c2, c3, c4, c5], [
'green', 'blue', 'magenta', 'red', 'black'],
['min vel', 'min acceleration', 'min jerk',
'min snap', 'min crackle'])
The installation using debian packages requires to have access to the ROS 1 repos (visit this link).
The reason to use ros packages is that this library depends on ifopt
, and its deb package is available with ros.
- Install the requirements
sudo apt-get install python3-matplotlib ros-noetic-ifopt
- Download the package a install
wget https://github.com/rafaelrojasmiliani/gsplines_cpp/releases/download/master/gsplines-0.0.1-amd64.deb
sudo dpkg -i gsplines-0.0.1-amd64.deb
- Install the requirements
sudo apt-get install python3-matplotlib libgtest-dev cmake libeigen3-dev coinor-libipopt-dev python3-dev
- Install
ifopt
git clone https://github.com/ethz-adrl/ifopt.git
cd ifopt
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make -j$(nproc)
sudo make install
- Download the repo with recursive mode and compile
git clone --recursive https://github.com/rafaelrojasmiliani/gsplines_cpp.git
cd gsplines_cpp
mkdir build
cd build
cmake .. -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=/usr
make -j$(nproc)
sudo make install
-
Definition A generalized spline is a piece-wise defined curve such that in each interval it is the linear combination of certain linearly independent functions
$B_1, B_2, ... ,B_k$ -
Formal Definition
- Let
$J=[0, T]$ and consider the partition of$J$ given by$N + 1$ points$t_i\in J$ , i.e.$I_1, I_2, ... ,I_N$ with$I_i=[t_i, t_{i + 1})$ ,$t_0=0$ and$t_{N + 1}=T$ - Let
$I_0=[-1,1]$ and$B_1, B_2, ... ,B_k$ be$k$ linearly independent functions$B_i:I_0\longrightarrow \mathbb{R}$ . - Let
$s_i:I_i\longrightarrow I_0$ given by
- Let
iv. Let
v. A generalized spline from
where
The term 'generalized splines' is borrowed from E. W. Cheney's book, Introduction to Approximation Theory, where he introduces generalized polynomials.
A generalized spline is to a generalized polynomial what a spline is to a polynomial.
Essentially, a gspline is a continuous piecewise function that passes through a sequence of points
Generalized splines appear naturally in trajectory optimization problems when waypoint constraints without prescribed times are added. In other words, if we aim to optimize a motion that passes through a sequence of positions without specifying the times at which the motion meets each point, we will encounter generalized splines.
Generalized splines trajectories arising in such kind of optimization problems are uniquely characterized by the waypoints that they attain, the time at which each waypoint is meet and the speed, and possible higher order derivatives at the boundaries of the time interval, i.e,
where
The main challenge to build into a computer a trajectory optimization problems with waypoint constraints is to compute the derivatives of
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
This library is aimed to find a trajectory passing trough a sequence of waypoints
It may be proven that such a problem can be subdivided in two steps
- Find the family of optimal curves that joint waypoints
- Compute time instants
${t_0, t_1, ...,t_N, t_{N + 1}}$ where the optimal curves must be attached
The step 1. is done by solving a linear ordinary differential equation, regarless the fact that the times
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
If we stack the column vectors
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
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 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
This library provides the class gsplines::basis::Basis
which represent an arbitrary set of linearly independent functions and the class gsplines::GSpline
which implements the definition gsplines::functions::FunctionBase
and gsplines::functions::FunctionExpression
that allows to define arbitrary curves in
The abstract class gsplines::functions::FunctionBase
represents objects that can be evaluated at points of some interval of gsplines::functions::FunctionInheritanceHelper
allows to define a custom function which
The class gsplines::functions::FunctionExpression
inherits from gsplines::functions::FunctionBase
and contain an array of pointers to gsplines::functions::FunctionBase
called function_array_
. The evaluation operator of gsplines::functions::FunctionExpression
evaluate the desired algebraic operation between the functions in function_array_
.
This architecture allow to implement complex algebraic expressions by recursively calling the evaluation of each function in function_array_
.
numpy
scipy
matplotlib
coinor-libipopt-dev
ros-noetic-ifopt
libeigen3-dev
- Rojas, Rafael A., et al. "A variational approach to minimum-jerk trajectories for psychological safety in collaborative assembly stations." IEEE Robotics and Automation Letters 4.2 (2019): 823-829.
@article{rojas2019variational,
title={A variational approach to minimum-jerk trajectories for psychological safety in collaborative assembly stations},
author={Rojas, Rafael A and Garcia, Manuel A Ruiz and Wehrle, Erich and Vidoni, Renato},
journal={IEEE Robotics and Automation Letters},
volume={4},
number={2},
pages={823--829},
year={2019},
publisher={IEEE}
}
- Rojas, Rafael A., et al. "Combining safety and speed in collaborative assembly systems–An approach to time optimal trajectories for collaborative robots." Procedia CIRP 97 (2021): 308-312.
@article{rojas2021combining,
title={Combining safety and speed in collaborative assembly systems--An approach to time optimal trajectories for collaborative robots},
author={Rojas, Rafael A and Garcia, Manuel A Ruiz and Gualtieri, Luca and Rauch, Erwin},
journal={Procedia CIRP},
volume={97},
pages={308--312},
year={2021},
publisher={Elsevier}
}
- Rojas, Rafael A., and Renato Vidoni. "Designing fast and smooth trajectories in collaborative workstations." IEEE Robotics and Automation Letters 6.2 (2021): 1700-1706.
@article{rojas2021designing,
title={Designing fast and smooth trajectories in collaborative workstations},
author={Rojas, Rafael A and Vidoni, Renato},
journal={IEEE Robotics and Automation Letters},
volume={6},
number={2},
pages={1700--1706},
year={2021},
publisher={IEEE}
}
- Rojas, Rafael A., Erich Wehrle, and Renato Vidoni. "A multicriteria motion planning approach for combining smoothness and speed in collaborative assembly systems." Applied Sciences 10.15 (2020): 5086.
@article{rojas2020multicriteria,
title={A multicriteria motion planning approach for combining smoothness and speed in collaborative assembly systems},
author={Rojas, Rafael A and Wehrle, Erich and Vidoni, Renato},
journal={Applied Sciences},
volume={10},
number={15},
pages={5086},
year={2020},
publisher={Multidisciplinary Digital Publishing Institute}
}
- Rojas, Rafael A., Andrea Giusti, and Renato Vidoni. "Online Computation of Time-Optimization-Based, Smooth and Path-Consistent Stop Trajectories for Robots." Robotics 11.4 (2022): 70.
@article{rojas2022online,
title={Online Computation of Time-Optimization-Based, Smooth and Path-Consistent Stop Trajectories for Robots},
author={Rojas, Rafael A and Giusti, Andrea and Vidoni, Renato},
journal={Robotics},
volume={11},
number={4},
pages={70},
year={2022},
publisher={MDPI}
}