LocalGuidance
A library that generates velocity references to follow a path.
robot_utils::catmull_rom::CatmullRomSpline< T > Class Template Reference

#include <CatmullRomSpline.hpp>

Public Types

typedef T Type
 

Public Member Functions

 CatmullRomSpline (void)
 
 CatmullRomSpline (CatmullRomSpline< T > &other)
 
 CatmullRomSpline (const CatmullRomSpline< T > &other)
 
CatmullRomSpline< T > & operator= (const CatmullRomSpline< T > &other)
 
virtual ~CatmullRomSpline (void)
 
evaluate_linear (double t)
 
void evaluate_catmull_rom_traj (const int nPoints, std::vector< double > &tArray, std::vector< T > &valArray)
 
evaluate (double t)
 
evaluate_catmull_rom (double t)
 
const T & getKnotValue (int i) const
 
T & getKnotValue (int i)
 
double getKnotPosition (int i) const
 
void setKnotValue (int i, const T &val)
 
void setKnotPosition (int i, double pos)
 
double getMinPosition ()
 
double getMaxPosition ()
 
int getKnotCount () const
 
void addKnot (double t, T val)
 
void removeKnot (int i)
 
void clear ()
 
void simplify_catmull_rom (double maxError, int nbSamples=100)
 
void copy (CatmullRomSpline< T > &other)
 
void copy (const CatmullRomSpline< T > &other)
 

Protected Member Functions

int getFirstLargerIndex (double t)
 

Protected Attributes

std::vector< double > tValues
 
std::vector< T > values
 
volatile int lastIndex
 

Detailed Description

template<class T>
class robot_utils::catmull_rom::CatmullRomSpline< T >

This class is used to represent generic trajectories. The class parameter T can be anything that provides basic operation such as addition and subtraction. We'll define a trajectory that can be parameterized by a one-d parameter (called t). Based on a set of knots ( tuples <t, T>), we can evaluate the trajectory at any t, through interpolation. This is not used for extrapolation. Outside the range of the knots, the closest known value is returned instead.

Member Typedef Documentation

template<class T>
typedef T robot_utils::catmull_rom::CatmullRomSpline< T >::Type

Constructor & Destructor Documentation

template<class T>
robot_utils::catmull_rom::CatmullRomSpline< T >::CatmullRomSpline ( void  )
inline
template<class T>
robot_utils::catmull_rom::CatmullRomSpline< T >::CatmullRomSpline ( CatmullRomSpline< T > &  other)
inline
template<class T>
robot_utils::catmull_rom::CatmullRomSpline< T >::CatmullRomSpline ( const CatmullRomSpline< T > &  other)
inline
template<class T>
virtual robot_utils::catmull_rom::CatmullRomSpline< T >::~CatmullRomSpline ( void  )
inlinevirtual

Member Function Documentation

template<class T>
void robot_utils::catmull_rom::CatmullRomSpline< T >::addKnot ( double  t,
val 
)
inline

This method is used to insert a new knot in the current trajectory

template<class T>
void robot_utils::catmull_rom::CatmullRomSpline< T >::clear ( )
inline

This method removes everything from the trajectory.

template<class T>
void robot_utils::catmull_rom::CatmullRomSpline< T >::copy ( CatmullRomSpline< T > &  other)
inline
template<class T>
void robot_utils::catmull_rom::CatmullRomSpline< T >::copy ( const CatmullRomSpline< T > &  other)
inline
template<class T>
T robot_utils::catmull_rom::CatmullRomSpline< T >::evaluate ( double  t)
inline
template<class T>
T robot_utils::catmull_rom::CatmullRomSpline< T >::evaluate_catmull_rom ( double  t)
inline

This method interprets the trajectory as a Catmul-Rom spline, and evaluates it at the point t

template<class T>
void robot_utils::catmull_rom::CatmullRomSpline< T >::evaluate_catmull_rom_traj ( const int  nPoints,
std::vector< double > &  tArray,
std::vector< T > &  valArray 
)
inline
template<class T>
T robot_utils::catmull_rom::CatmullRomSpline< T >::evaluate_linear ( double  t)
inline

This method performs linear interpolation to evaluate the trajectory at the point t

template<class T>
int robot_utils::catmull_rom::CatmullRomSpline< T >::getFirstLargerIndex ( double  t)
inlineprotected

This method returns the index of the first knot whose value is larger than the parameter value t. If no such index exists (t is larger than any of the values stored), then values.size() is returned.

template<class T>
int robot_utils::catmull_rom::CatmullRomSpline< T >::getKnotCount ( ) const
inline

returns the number of knots in this trajectory

template<class T>
double robot_utils::catmull_rom::CatmullRomSpline< T >::getKnotPosition ( int  i) const
inline

Returns the position of the ith knot. It is assumed that i is within the correct range.

template<class T>
const T& robot_utils::catmull_rom::CatmullRomSpline< T >::getKnotValue ( int  i) const
inline

Returns the value of the ith knot. It is assumed that i is within the correct range.

template<class T>
T& robot_utils::catmull_rom::CatmullRomSpline< T >::getKnotValue ( int  i)
inline
template<class T>
double robot_utils::catmull_rom::CatmullRomSpline< T >::getMaxPosition ( )
inline

Return the largest tValue or -infinity if none

template<class T>
double robot_utils::catmull_rom::CatmullRomSpline< T >::getMinPosition ( )
inline

Return the smallest tValue or infinity if none

template<class T>
CatmullRomSpline<T>& robot_utils::catmull_rom::CatmullRomSpline< T >::operator= ( const CatmullRomSpline< T > &  other)
inline
template<class T>
void robot_utils::catmull_rom::CatmullRomSpline< T >::removeKnot ( int  i)
inline

This method is used to remove a knot from the current trajectory. It is assumed that i is within the correct range.

template<class T>
void robot_utils::catmull_rom::CatmullRomSpline< T >::setKnotPosition ( int  i,
double  pos 
)
inline

Sets the position of the ith knot to pos. It is assumed that i is within the correct range.

template<class T>
void robot_utils::catmull_rom::CatmullRomSpline< T >::setKnotValue ( int  i,
const T &  val 
)
inline

Sets the value of the ith knot to val. It is assumed that i is within the correct range.

template<class T>
void robot_utils::catmull_rom::CatmullRomSpline< T >::simplify_catmull_rom ( double  maxError,
int  nbSamples = 100 
)
inline

Simplify the curve by iteratively adding knots

Member Data Documentation

template<class T>
volatile int robot_utils::catmull_rom::CatmullRomSpline< T >::lastIndex
protected
template<class T>
std::vector<double> robot_utils::catmull_rom::CatmullRomSpline< T >::tValues
protected
template<class T>
std::vector<T> robot_utils::catmull_rom::CatmullRomSpline< T >::values
protected

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