MoveIt Pro API
Core Behaviors for MoveIt Pro
Loading...
Searching...
No Matches
SplineTrajectory Class Reference

SplineTrajectory fits piecewise splines to target positions by minimizing a specified cost function via convex optimization. The constructor sets up all the memory needed for running the optimization in the fit function and querying new points using the evaluate function. More...

#include <spline_trajectory.hpp>

Public Member Functions

 SplineTrajectory (size_t num_points, size_t num_coefficients)
 The constructor initializes all memory needed for the optimization and evaluation.
 
void fit (const moveit_pro_controllers::Trajectory &points, const SplineOptimizationParameters &optimization_parameters, double scaled_time_base=1.05)
 Fits the piecewise spline to the given trajectory points.
 
const moveit_pro_controllers::TimedJointState & evaluate (double ti)
 Evaluates the spline at a given time point.
 
const std::vector< double > & getKnots () const
 Returns the vector of knot time points used in the spline trajectory.
 

Detailed Description

SplineTrajectory fits piecewise splines to target positions by minimizing a specified cost function via convex optimization. The constructor sets up all the memory needed for running the optimization in the fit function and querying new points using the evaluate function.

The cost function to minimize is the $\int (\dot{x}^2 + \ddot{x}^2 + \dddot{x}^2) \, dt$, where $x = \sum_{i=0}^{\text{num\_coefficients}} x_i \cdot t^i$.

Constructor & Destructor Documentation

◆ SplineTrajectory()

SplineTrajectory::SplineTrajectory ( size_t  num_points,
size_t  num_coefficients 
)

The constructor initializes all memory needed for the optimization and evaluation.

Parameters
num_pointsThe number of points to fit the spline to.
num_coefficientsThe number of polynomial terms to use per piecewise spline.

Member Function Documentation

◆ evaluate()

const moveit_pro_controllers::TimedJointState & SplineTrajectory::evaluate ( double  ti)

Evaluates the spline at a given time point.

Parameters
tiThe time from start at which to evaluate the spline.
Returns
The joint state (position, velocity, acceleration) at the specified time.

◆ fit()

void SplineTrajectory::fit ( const moveit_pro_controllers::Trajectory &  points,
const SplineOptimizationParameters optimization_parameters,
double  scaled_time_base = 1.05 
)

Fits the piecewise spline to the given trajectory points.

Exceptions
std::runtime_errorThrown if:
  • The provided points have zero dimensions.
  • The number of dimensions in the provided points does not match the dimensions specified in the spline optimization parameters.
  • The velocity limits must all be positive and match the number of dimensions in the points.
  • The acceleration limits must all be positive and match the number of dimensions in the points.
  • The velocity limits, if provided, must each be greater than the corresponding start and end velocity for their dimension.
  • The acceleration limits, if provided, must each be greater than the corresponding start and end acceleration for their dimension.
Parameters
pointsThe trajectory points to fit the spline to.
optimization_parametersParameters for spline optimization, including weights and constraints.
scaled_time_baseThe multiplier to iteratively scale time if the inequality dynamic constraints are not met.

◆ getKnots()

const std::vector< double > & SplineTrajectory::getKnots ( ) const

Returns the vector of knot time points used in the spline trajectory.

Returns
A const reference to the vector of knot times.

The documentation for this class was generated from the following files: