Trajectory Class Reference

This class is used to update entities based on trajectory defined by keyframes. More...

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

Public Member Functions

void addKeyframe (const TrackID &id, const VariantKeyframe &keyframe)
 Add a keyframe to the specified track. More...
 
void addKeyframe (const TrackID &id, float time, const VariantValue &value)
 Add a keyframe to the specified track. More...
 
VariantTrackaddTrack (const TrackID &id)
 Add track with the given ID (and no update function). More...
 
VariantTrackaddTrack (const TrackID &id, const VariantTrack::UpdateFunc &updateFunc)
 Add track with the given ID and update function. More...
 
void clear ()
 Clear the trajectory of all tracks. More...
 
VariantTrackoperator[] (const TrackID &id)
 Get the track with the given ID. More...
 
const VariantTrackoperator[] (const TrackID &id) const
 Get the track with the given ID. More...
 
 Trajectory ()
 Constructor. More...
 
void update (float time, bool ignoreEmptyTracks=false)
 Update all tracks for the given time. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Trajectory &trajectory)
 

Detailed Description

This class is used to update entities based on trajectory defined by keyframes.

A Trajectory is a collection of tracks, where each track represents a timeline of a single value. A track is composed of keyframes, where each keyframe represents a value at a specific time on the timeline.

See also
Track

Definition at line 21 of file Trajectory.h.

Constructor & Destructor Documentation

◆ Trajectory()

Constructor.

Definition at line 7 of file Trajectory.cpp.

Member Function Documentation

◆ addKeyframe() [1/2]

void addKeyframe ( const TrackID id,
const VariantKeyframe keyframe 
)

Add a keyframe to the specified track.

Exceptions
<tt>error::NoTrackWithID</tt>if there is not track with the given ID

Definition at line 25 of file Trajectory.cpp.

+ Here is the caller graph for this function:

◆ addKeyframe() [2/2]

void addKeyframe ( const TrackID id,
float  time,
const VariantValue value 
)

Add a keyframe to the specified track.

Exceptions
<tt>error::NoTrackWithID</tt>if there is not track with the given ID

Definition at line 30 of file Trajectory.cpp.

+ Here is the call graph for this function:

◆ addTrack() [1/2]

VariantTrack & addTrack ( const TrackID id)

Add track with the given ID (and no update function).

If there is already a track with the given ID, it is overwritten.

Definition at line 15 of file Trajectory.cpp.

◆ addTrack() [2/2]

VariantTrack & addTrack ( const TrackID id,
const VariantTrack::UpdateFunc updateFunc 
)

Add track with the given ID and update function.

If there is already a track with the given ID, it is overwritten.

Definition at line 20 of file Trajectory.cpp.

◆ clear()

void clear ( )

Clear the trajectory of all tracks.

Definition at line 10 of file Trajectory.cpp.

◆ operator[]() [1/2]

VariantTrack & operator[] ( const TrackID id)

Get the track with the given ID.

Exceptions
<tt>error::NoTrackWithID</tt>if there is not track with the given ID

Definition at line 43 of file Trajectory.cpp.

◆ operator[]() [2/2]

const VariantTrack & operator[] ( const TrackID id) const

Get the track with the given ID.

Exceptions
<tt>error::NoTrackWithID</tt>if there is not track with the given ID

Definition at line 55 of file Trajectory.cpp.

◆ update()

void update ( float  time,
bool  ignoreEmptyTracks = false 
)

Update all tracks for the given time.

Parameters
ignoreEmptyTracksIf true, empty tracks are ignored.
Exceptions
<tt>error::EmptyTrack</tt>If ignoreEmptyTracks is false and a track is empty.

Definition at line 35 of file Trajectory.cpp.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Trajectory trajectory 
)
friend

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