Drake
PiecewisePolynomial< CoefficientType > Class Template Reference

A scalar multi-variate piecewise polynomial. More...

#include <drake/systems/trajectories/PiecewisePolynomial.h>

Inheritance diagram for PiecewisePolynomial< CoefficientType >:
Collaboration diagram for PiecewisePolynomial< CoefficientType >:

Public Types

typedef Polynomial< CoefficientType > PolynomialType
 
typedef Eigen::Matrix< PolynomialType, Eigen::Dynamic, Eigen::Dynamic > PolynomialMatrix
 
typedef Eigen::Matrix< CoefficientType, Eigen::Dynamic, Eigen::Dynamic > CoefficientMatrix
 
typedef Eigen::Ref< CoefficientMatrixCoefficientMatrixRef
 

Public Member Functions

virtual ~PiecewisePolynomial ()
 
 PiecewisePolynomial ()
 
template<typename Derived >
 PiecewisePolynomial (const Eigen::MatrixBase< Derived > &value)
 
 PiecewisePolynomial (std::vector< PolynomialMatrix > const &polynomials, std::vector< double > const &segment_times)
 
 PiecewisePolynomial (std::vector< PolynomialType > const &polynomials, std::vector< double > const &segment_times)
 
PiecewisePolynomial derivative (int derivative_order=1) const
 Takes the derivative of this PiecewisePolynomial. More...
 
PiecewisePolynomial integral (double value_at_start_time=0.0) const
 Takes the integral of this PiecewisePolynomial. More...
 
PiecewisePolynomial integral (const CoefficientMatrixRef &value_at_start_time) const
 Takes the integral of this PiecewisePolynomial. More...
 
double scalarValue (double t, Eigen::Index row=0, Eigen::Index col=0)
 
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > value (double t) const
 
const PolynomialMatrixgetPolynomialMatrix (int segment_index) const
 
const PolynomialTypegetPolynomial (int segment_index, Eigen::Index row=0, Eigen::Index col=0) const
 
virtual int getSegmentPolynomialDegree (int segment_index, Eigen::Index row=0, Eigen::Index col=0) const
 
virtual Eigen::Index rows () const
 
virtual Eigen::Index cols () const
 
PiecewisePolynomialoperator+= (const PiecewisePolynomial &other)
 
PiecewisePolynomialoperator-= (const PiecewisePolynomial &other)
 
PiecewisePolynomialoperator*= (const PiecewisePolynomial &other)
 
PiecewisePolynomialoperator+= (const CoefficientMatrix &offset)
 
PiecewisePolynomialoperator-= (const CoefficientMatrix &offset)
 
const PiecewisePolynomial operator+ (const PiecewisePolynomial &other) const
 
const PiecewisePolynomial operator- (const PiecewisePolynomial &other) const
 
const PiecewisePolynomial operator* (const PiecewisePolynomial &other) const
 
const PiecewisePolynomial operator+ (const CoefficientMatrix &offset) const
 
const PiecewisePolynomial operator- (const CoefficientMatrix &offset) const
 
bool isApprox (const PiecewisePolynomial &other, double tol) const
 Checks if a PiecewisePolynomial is approximately equal to this one. More...
 
void shiftRight (double offset)
 
void setPolynomialMatrixBlock (const PolynomialMatrix &replacement, int segment_number, Eigen::Index row_start=0, Eigen::Index col_start=0)
 
PiecewisePolynomial slice (int start_segment_index, int num_segments)
 
- Public Member Functions inherited from PiecewisePolynomialBase
 PiecewisePolynomialBase (std::vector< double > const &segment_times)
 
virtual ~PiecewisePolynomialBase ()
 
int getNumberOfCoefficients (int segment_number, Eigen::Index row=0, Eigen::Index col=0) const
 
int getTotalNumberOfCoefficients (Eigen::Index row=0, Eigen::Index col=0) const
 
- Public Member Functions inherited from PiecewiseFunction
 PiecewiseFunction (std::vector< double > const &segment_times)
 
virtual ~PiecewiseFunction ()
 
int getNumberOfSegments () const
 
double getStartTime (int segment_number) const
 
double getEndTime (int segment_number) const
 
double getDuration (int segment_number) const
 
double getStartTime () const
 
double getEndTime () const
 
int getSegmentIndex (double t) const
 
const std::vector< double > & getSegmentTimes () const
 
void segmentNumberRangeCheck (int segment_number) const
 

Static Public Member Functions

static PiecewisePolynomial random (Eigen::Index rows, Eigen::Index cols, Eigen::Index num_coefficients_per_polynomial, const std::vector< double > &segment_times)
 Obtains a random PiecewisePolynomial of the specified size. More...
 
- Static Public Member Functions inherited from PiecewiseFunction
static std::vector< doublerandomSegmentTimes (int num_segments, std::default_random_engine &generator)
 

Protected Member Functions

double segmentValueAtGlobalAbscissa (int segment_index, double t, Eigen::Index row, Eigen::Index col) const
 
- Protected Member Functions inherited from PiecewisePolynomialBase
 PiecewisePolynomialBase ()
 
- Protected Member Functions inherited from PiecewiseFunction
bool segmentTimesEqual (const PiecewiseFunction &b, double tol) const
 
void checkScalarValued () const
 
 PiecewiseFunction ()
 

Additional Inherited Members

- Protected Attributes inherited from PiecewiseFunction
std::vector< doublesegment_times
 

Detailed Description

template<typename CoefficientType = double>
class PiecewisePolynomial< CoefficientType >

A scalar multi-variate piecewise polynomial.

PiecewisePolynomial represents a list of contiguous segments in time with a Polynomial defined for each segment.

An example of a piecewise function is the absolute value function:

int abs(int x)
{
if (x<0) {
return -x;
}
else return x;
}

PiecewisePolynomials can be added, subtracted, and multiplied. They cannot be divided because Polynomials are not closed under division.

Member Typedef Documentation

typedef Eigen::Matrix<CoefficientType, Eigen::Dynamic, Eigen::Dynamic> CoefficientMatrix
typedef Eigen::Matrix<PolynomialType, Eigen::Dynamic, Eigen::Dynamic> PolynomialMatrix
typedef Polynomial<CoefficientType> PolynomialType

Constructor & Destructor Documentation

virtual ~PiecewisePolynomial ( )
inlinevirtual
PiecewisePolynomial ( const Eigen::MatrixBase< Derived > &  value)
inlineexplicit
PiecewisePolynomial ( std::vector< PolynomialMatrix > const &  polynomials,
std::vector< double > const &  segment_times 
)

Here is the call graph for this function:

PiecewisePolynomial ( std::vector< PolynomialType > const &  polynomials,
std::vector< double > const &  segment_times 
)

Member Function Documentation

Eigen::Index cols ( ) const
virtual

Implements PiecewiseFunction.

Here is the caller graph for this function:

PiecewisePolynomial< CoefficientType > derivative ( int  derivative_order = 1) const

Takes the derivative of this PiecewisePolynomial.

Returns a PiecewisePolynomial where each segment is the derivative of the segment in the input PiecewisePolynomial. Any rules or limitations of Polynomial::derivative also apply to this function.

If derivative_order is given, takes the nth derivative of this PiecewisePolynomial.

Here is the call graph for this function:

Here is the caller graph for this function:

const Polynomial< CoefficientType > & getPolynomial ( int  segment_index,
Eigen::Index  row = 0,
Eigen::Index  col = 0 
) const

Here is the call graph for this function:

Here is the caller graph for this function:

const PiecewisePolynomial< CoefficientType >::PolynomialMatrix & getPolynomialMatrix ( int  segment_index) const

Here is the caller graph for this function:

int getSegmentPolynomialDegree ( int  segment_index,
Eigen::Index  row = 0,
Eigen::Index  col = 0 
) const
virtual

Implements PiecewisePolynomialBase.

Here is the call graph for this function:

Here is the caller graph for this function:

PiecewisePolynomial< CoefficientType > integral ( double  value_at_start_time = 0.0) const

Takes the integral of this PiecewisePolynomial.

Returns a PiecewisePolynomial that is the indefinite integral of this one. Any rules or limitations of Polynomial::integral also apply to this function.

If value_at_start_time is given, it does the following only for the first segment: adds that constant as the constant term (zeroth-order coefficient) of the resulting Polynomial.

Here is the call graph for this function:

Here is the caller graph for this function:

PiecewisePolynomial integral ( const CoefficientMatrixRef value_at_start_time) const

Takes the integral of this PiecewisePolynomial.

Returns a PiecewisePolynomial that is the indefinite integral of this one. Any rules or limitations of Polynomial::integral also apply to this function.

If value_at_start_time is given, it does the following only for the first segment: adds value_at_start_time(row,col) as the constant term (zeroth-order coefficient) of the resulting Polynomial.

bool isApprox ( const PiecewisePolynomial< CoefficientType > &  other,
double  tol 
) const

Checks if a PiecewisePolynomial is approximately equal to this one.

Checks that every coefficient of other is within tol of the corresponding coefficient of this PiecewisePolynomial. Throws an exception if any Polynomial in either PiecewisePolynomial is not univariate.

Here is the call graph for this function:

const PiecewisePolynomial< CoefficientType > operator* ( const PiecewisePolynomial< CoefficientType > &  other) const

Here is the call graph for this function:

PiecewisePolynomial< CoefficientType > & operator*= ( const PiecewisePolynomial< CoefficientType > &  other)

Here is the call graph for this function:

const PiecewisePolynomial< CoefficientType > operator+ ( const PiecewisePolynomial< CoefficientType > &  other) const

Here is the caller graph for this function:

const PiecewisePolynomial operator+ ( const CoefficientMatrix offset) const
PiecewisePolynomial< CoefficientType > & operator+= ( const PiecewisePolynomial< CoefficientType > &  other)

Here is the call graph for this function:

Here is the caller graph for this function:

PiecewisePolynomial& operator+= ( const CoefficientMatrix offset)
const PiecewisePolynomial< CoefficientType > operator- ( const PiecewisePolynomial< CoefficientType > &  other) const

Here is the caller graph for this function:

const PiecewisePolynomial operator- ( const CoefficientMatrix offset) const
PiecewisePolynomial< CoefficientType > & operator-= ( const PiecewisePolynomial< CoefficientType > &  other)

Here is the call graph for this function:

PiecewisePolynomial& operator-= ( const CoefficientMatrix offset)
PiecewisePolynomial< CoefficientType > random ( Eigen::Index  rows,
Eigen::Index  cols,
Eigen::Index  num_coefficients_per_polynomial,
const std::vector< double > &  segment_times 
)
static

Obtains a random PiecewisePolynomial of the specified size.

Obtains a PiecewisePolynomial with the given segment_times. Each segment will have a matrix of random Polynomials of the specified size.

Here is the call graph for this function:

Here is the caller graph for this function:

Eigen::Index rows ( ) const
virtual

Implements PiecewiseFunction.

Here is the caller graph for this function:

double scalarValue ( double  t,
Eigen::Index  row = 0,
Eigen::Index  col = 0 
)

Here is the call graph for this function:

Here is the caller graph for this function:

double segmentValueAtGlobalAbscissa ( int  segment_index,
double  t,
Eigen::Index  row,
Eigen::Index  col 
) const
protected

Here is the call graph for this function:

Here is the caller graph for this function:

void setPolynomialMatrixBlock ( const PolynomialMatrix replacement,
int  segment_number,
Eigen::Index  row_start = 0,
Eigen::Index  col_start = 0 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void shiftRight ( double  offset)

Here is the caller graph for this function:

PiecewisePolynomial< CoefficientType > slice ( int  start_segment_index,
int  num_segments 
)

Here is the call graph for this function:

Here is the caller graph for this function:

Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > value ( double  t) const

Here is the call graph for this function:

Here is the caller graph for this function:


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