OpenFrames
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
OpenFrames::Trajectory Class Reference

Holds a collection of data vectors. More...

#include <Trajectory.hpp>

Inheritance diagram for OpenFrames::Trajectory:

Classes

struct  DataSource
 

Public Types

enum  SourceType { ZERO = 0, TIME, POSOPT, ATTITUDE }
 
enum  DataLockType { READ_LOCK, WRITE_LOCK }
 
typedef double DataType
 
typedef std::vector< DataTypeDataArray
 
typedef std::vector< TrajectorySubscriber * > SubscriberArray
 

Public Member Functions

 Trajectory (unsigned int dof=3, unsigned int nopt=0)
 
void reserveMemory (unsigned int numPoints, bool usePos=true, bool useAtt=true)
 
const DataArray & getTimeList () const
 
const DataArray & getPosOptList () const
 
const DataArray & getAttList () const
 
unsigned int getNumPos () const
 
void setNumOptionals (unsigned int nopt)
 
unsigned int getNumOptionals () const
 
unsigned int getNumAtt () const
 
void setDOF (unsigned int dof)
 
unsigned int getDOF () const
 
unsigned int getBase () const
 
virtual int getTimeIndex (const DataType &t, int &index) const
 
bool isEmpty () const
 
unsigned int getNumTimes () const
 
virtual bool getTimeRange (DataType &begin, DataType &end) const
 
double getTimeDistance (const DataType &t) const
 
virtual bool addTime (const DataType &t)
 
virtual bool addPosition (const DataType &x, const DataType &y, const DataType z=0.0)
 
virtual bool addPosition (const DataType *const pos)
 
virtual bool getPosition (unsigned int n, DataType &x, DataType &y) const
 
virtual bool getPosition (unsigned int n, DataType &x, DataType &y, DataType &z) const
 
virtual bool addAttitude (const DataType &x, const DataType &y, const DataType &z, const DataType &w)
 
virtual bool addAttitude (const DataType *const att)
 
virtual bool getAttitude (unsigned int n, DataType &x, DataType &y, DataType &z, DataType &w) const
 
virtual bool setOptional (unsigned int index, const DataType &x, const DataType &y, const DataType z=0.0)
 
virtual bool setOptional (unsigned int index, const DataType *const opt)
 
virtual bool getOptional (unsigned int n, unsigned int index, DataType &x, DataType &y) const
 
virtual bool getOptional (unsigned int n, unsigned int index, DataType &x, DataType &y, DataType &z) const
 
virtual void clear ()
 
virtual void getPoint (unsigned int i, const DataSource source[], DataType val[]) const
 
virtual bool verifyData (const DataSource source[]) const
 
virtual unsigned int getNumPoints (const DataSource source[]) const
 
virtual void addSubscriber (TrajectorySubscriber *subscriber) const
 
virtual void removeSubscriber (TrajectorySubscriber *subscriber) const
 
virtual void informSubscribers ()
 
void autoInformSubscribers (bool autoinform)
 
virtual void lockData (DataLockType lockType=READ_LOCK) const
 
virtual void unlockData (DataLockType lockType=READ_LOCK) const
 

Protected Attributes

DataArray _time
 
DataArray _posopt
 
DataArray _att
 
SubscriberArray _subscribers
 
bool _autoInformSubscribers
 
unsigned int _nopt
 
unsigned int _base
 
unsigned int _numPos
 
unsigned int _numAtt
 
unsigned int _dof
 
OpenThreads::ReadWriteMutex _readWriteMutex
 

Detailed Description

Holds a collection of data vectors.

A Trajectory holds a collection of times, positions, attitudes and any number of optional data vectors. Data is inserted at the end of the trajectory, and no sorting is done during insertion. This is left to deriving classes.

Member Typedef Documentation

◆ DataType

Type of each data element in the trajectory. Make sure to change return value of getGLDataType() if you change this!

Member Enumeration Documentation

◆ SourceType

SourceType is used to specify where the data for the x/y/z component of every point is to be taken from.

Constructor & Destructor Documentation

◆ Trajectory()

OpenFrames::Trajectory::Trajectory ( unsigned int  dof = 3,
unsigned int  nopt = 0 
)

Initialize with degrees of freedom, an id, and how many optionals are at each point of the trajectory.

Member Function Documentation

◆ addAttitude()

virtual bool OpenFrames::Trajectory::addAttitude ( const DataType x,
const DataType y,
const DataType z,
const DataType w 
)
virtual

Add attitude. For pointer version, the pointer must reference 4 elements (for quaternion).

◆ addPosition()

virtual bool OpenFrames::Trajectory::addPosition ( const DataType x,
const DataType y,
const DataType  z = 0.0 
)
virtual

Add position. For pointer version, the DOF determines how many elements will be copied.

◆ addSubscriber()

virtual void OpenFrames::Trajectory::addSubscriber ( TrajectorySubscriber subscriber) const
virtual

Register a subscriber with this trajectory. The subscriber will be notified whenever the trajectory changes.

◆ addTime()

virtual bool OpenFrames::Trajectory::addTime ( const DataType t)
virtual

Add a point with the given time to the end of the time list.

◆ clear()

virtual void OpenFrames::Trajectory::clear ( )
virtual

Remove all points from this trajectory

◆ getBase()

unsigned int OpenFrames::Trajectory::getBase ( ) const
inline

Get number of data elements taken up by each position&optional group. A data element is of type DataType.

◆ getNumAtt()

unsigned int OpenFrames::Trajectory::getNumAtt ( ) const
inline

Get the total number of attitude points. This will always be less than or equal to the number of times in the time list.

◆ getNumPoints()

virtual unsigned int OpenFrames::Trajectory::getNumPoints ( const DataSource  source[]) const
virtual

Get the maximum number of points that can be obtained by the Trajectory's data using the given sources. If each of the source's components is ZERO, then this function returns UINT_MAX.

◆ getNumPos()

unsigned int OpenFrames::Trajectory::getNumPos ( ) const
inline

Get total number of position/optional groups. This will always be less then or equal to the number of times in the time list.

◆ getPoint()

virtual void OpenFrames::Trajectory::getPoint ( unsigned int  i,
const DataSource  source[],
DataType  val[] 
) const
virtual

Get data point i from the Trajectory. The DataSource defines where in in the trajectory the corresponding (x/y/z) data component comes from.
The resulting point is stored in the supplied 'val' 3-element vector. NOTE: This function does NOT do error checking on it's inputs! You should use verifyData() and getNumPoints() to make sure that the data exists in the trajectory before calling getPoint().

◆ getTimeDistance()

double OpenFrames::Trajectory::getTimeDistance ( const DataType t) const

Get the "distance" from given time to this trajectory's time range. Possible return values: = DBL_MAX: No times in trajectory

0.0: Out of range, either after or before time range

= 0.0: At start or end of time range < 0.0: Between start and end of time range

◆ getTimeIndex()

virtual int OpenFrames::Trajectory::getTimeIndex ( const DataType t,
int &  index 
) const
virtual

Find the lower bounding index (in the time list) for the given time. Returns -2 if the requested time could not be found after a reasonable number of iterations. In this case, index is the last value computed before quitting the search. Returns -1 if the requested time is out of the time list's bounds: index = -1: Requested time before first time index = numTimes: Requested time after last time Returns 0 if the requested time is at the list's bounds: index = 0: Requested time is at start of time list index = numTimes-1: Requested time is at end of time list Otherwise returns number of iterations required to find the index such that times[index] <= t < times[index+1]. In this case it is guaranteed that 0 <= index <= numTimes-2.

◆ getTimeList()

const DataArray& OpenFrames::Trajectory::getTimeList ( ) const
inline

Get lists.

◆ lockData()

virtual void OpenFrames::Trajectory::lockData ( DataLockType  lockType = READ_LOCK) const
virtual

Synchronization routines which prevent Trajectory's data from being moved around in memory while the data is being read.

◆ reserveMemory()

void OpenFrames::Trajectory::reserveMemory ( unsigned int  numPoints,
bool  usePos = true,
bool  useAtt = true 
)

Reserve enough memory for specified number of points. This helps avoid unnecessary memory reallocations while adding points. NOTE: Regardless of this setting, any number of points can be added to a Trajectory. Properly reserving based on estimated upper-bound number of points helps in memory management, but is not required.

◆ setDOF()

void OpenFrames::Trajectory::setDOF ( unsigned int  dof)

Set/Get number of degrees of freedom for each position&optional. Note that the trajectory will be cleared if its DOF is changed.

◆ setNumOptionals()

void OpenFrames::Trajectory::setNumOptionals ( unsigned int  nopt)

Set/Get number of optionals for each position. Note that the trajectory will be cleared if the number of optionals is changed.

◆ setOptional()

virtual bool OpenFrames::Trajectory::setOptional ( unsigned int  index,
const DataType x,
const DataType y,
const DataType  z = 0.0 
)
virtual

Set the optional with the given index. For pointer version, the DOF determines how many elements will be copied. The index must be in the range [0 ... _nopt-1].

◆ verifyData()

virtual bool OpenFrames::Trajectory::verifyData ( const DataSource  source[]) const
virtual

Verify whether the data specified by the source 3-vector is contained in this trajectory.


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