Track< ValueT > Class Template Reference

A track represents the timeline of a single value, identified by a track ID. More...

#include <RobotAPI/libraries/SimpleTrajectory/Track.h>

Classes

struct  KeyframeProxy
 A proxy allowing for adding keyframes by: track[time] = value; More...
 

Public Types

using UpdateFunc = std::function< void(ValueT)>
 The update function type. More...
 

Public Member Functions

void addKeyframe (const Keyframe< ValueT > &keyframe)
 Add a keyframe to this track. More...
 
void addKeyframe (float time, const ValueT &value)
 Add a keyframe to this track. More...
 
ValueT at (float time) const
 Get the interpolated value at the given time. More...
 
void clear ()
 Clear the track of all keyframes. More...
 
bool empty () const
 Indicate whether this track does not contain any keyframes. More...
 
KeyframeProxy operator[] (float time)
 Add a keyframe by assignment: track[time] = value; More...
 
 Track (const TrackID &id)
 Construct a track with given ID (and no update function). More...
 
 Track (const TrackID &id, UpdateFunc updateFunc)
 Construct a track with given ID and update function. More...
 
void update (float time, bool ignoreIfEmpty=false)
 Call the update function with the interpolated value at the given time. More...
 

Friends

template<typename V >
std::ostream & operator<< (std::ostream &os, const Track< V > &track)
 

Detailed Description

template<typename ValueT>
class armarx::trajectory::Track< ValueT >

A track represents the timeline of a single value, identified by a track ID.

A track is comprised of a sequence of keyframes and used to call a single update function.

Definition at line 34 of file Track.h.

Member Typedef Documentation

◆ UpdateFunc

using UpdateFunc = std::function<void(ValueT)>

The update function type.

Definition at line 38 of file Track.h.

Constructor & Destructor Documentation

◆ Track() [1/2]

Track ( const TrackID id)
inline

Construct a track with given ID (and no update function).

Definition at line 45 of file Track.h.

◆ Track() [2/2]

Track ( const TrackID id,
UpdateFunc  updateFunc 
)
inline

Construct a track with given ID and update function.

Definition at line 50 of file Track.h.

Member Function Documentation

◆ addKeyframe() [1/2]

void addKeyframe ( const Keyframe< ValueT > &  keyframe)

Add a keyframe to this track.

◆ addKeyframe() [2/2]

void addKeyframe ( float  time,
const ValueT &  value 
)

Add a keyframe to this track.

◆ at()

V at ( float  time) const

Get the interpolated value at the given time.

Exceptions
<tt>error::EmptyTrack</tt>If the track is empty.

Definition at line 195 of file Track.h.

+ Here is the call graph for this function:

◆ clear()

void clear

Clear the track of all keyframes.

Definition at line 144 of file Track.h.

◆ empty()

bool empty

Indicate whether this track does not contain any keyframes.

Definition at line 138 of file Track.h.

◆ operator[]()

auto operator[] ( float  time)

Add a keyframe by assignment: track[time] = value;

Definition at line 164 of file Track.h.

◆ update()

void update ( float  time,
bool  ignoreIfEmpty = false 
)

Call the update function with the interpolated value at the given time.

Parameters
ignoreIfEmptyIf true and the track is empty, the method does nothing.
Exceptions
<tt>error::EmptyTrack</tt>If the track is empty and ignoreIfEmpty is false.

Definition at line 235 of file Track.h.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Track< V > &  track 
)
friend

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