OpenFrames
|
Holds a collection of data vectors. More...
#include <Trajectory.hpp>
Classes | |
struct | DataSource |
Public Types | |
enum | SourceType { ZERO = 0, TIME, POSOPT, ATTITUDE } |
enum | DataLockType { READ_LOCK, WRITE_LOCK } |
typedef double | DataType |
typedef std::vector< DataType > | DataArray |
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 |
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.
typedef double OpenFrames::Trajectory::DataType |
Type of each data element in the trajectory. Make sure to change return value of getGLDataType() if you change this!
SourceType is used to specify where the data for the x/y/z component of every point is to be taken from.
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.
|
virtual |
Add attitude. For pointer version, the pointer must reference 4 elements (for quaternion).
|
virtual |
Add position. For pointer version, the DOF determines how many elements will be copied.
|
virtual |
Register a subscriber with this trajectory. The subscriber will be notified whenever the trajectory changes.
|
virtual |
Add a point with the given time to the end of the time list.
|
virtual |
Remove all points from this trajectory
|
inline |
Get number of data elements taken up by each position&optional group. A data element is of type DataType.
|
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.
|
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.
|
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.
|
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().
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
|
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.
|
inline |
Get lists.
|
virtual |
Synchronization routines which prevent Trajectory's data from being moved around in memory while the data is being read.
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.
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.
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.
|
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].
|
virtual |
Verify whether the data specified by the source 3-vector is contained in this trajectory.