Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
MotionSequenceEngine Class ReferenceA handy class for storing a sequence of keyframed movements. More...
Inheritance diagram for MotionSequenceEngine:
Detailed DescriptionA handy class for storing a sequence of keyframed movements. Each outputs is handled independently. It's easy to add keyframes which modify all of the outputs, but since each output is tracked individually, OutputCmd's with 0 weight can be used to not affect other motions. For instance, if you want to pan the head left to right while moving the right leg up and down several times, you won't have to specify the intermediary position of the head in its motion at each of the leg motion keyframes. Be aware that the 0 time frame will be replaced on a call to play() with the current body posture from state. However, this only applies to outputs which have a non-zero weighted frame defined at some point. The weights, of the 0 time frame will remain unchanged. These weights are initially set to 0, so that it's possible to 'fade in' the first frame of the motion sequence from whereever the body happens to be (or already doing) To fade out at the end, set a frame with 0 weight for everything. Otherwise it will simply die suddenly. When a joint reaches its last keyframe, if hold is set (the default) it will hold its last value until the MotionSequence is reset or stopped. If hold is false, then the joint is treated as 0 weight once it reaches its last frame. Currently, MotionSequenceEngine is intended mainly for building, not editing. It's easy to add keyframes, but hard/impossible to delete them. The MotionSequenceEngine base class is an abstract class so that you can create memory efficient motion sequences and simply refer to them by the common base class instead of having to worry about the actual size allocated in the template, MotionSequenceMC.
The file format used is as follows: ('<' and '>' are not meant literally)
Lines beginning with '#' are ignored as comments. Be aware if you load the file and then save it again, these comments will be lost. Example 1: This motion sequence will straighten out the head, panning from right to left.
This graph illustrates the motion of the tilt and pan joints in example 1: Notice how the joint will move from wherever it is initally to the first keyframe for that joint. Specifying the tilt joint a second time at the end of the motion forces the tilt joint to be held at that position throughout the motion, regardless of the hold setting at the time the sequence is run. Example 2: This example will straighten the head and the tail, pan the head left to right, and then pan the tail left to right.
These graphs illustrate the motion of the pan joint for the head and the tail: The head's motion should be straightforward. The thing to note in the tail's graph is why the second After loading a motion sequence, the playtime is left at the end. This is to make it easy to append/overlay motion sequences. However, the playhead will be reset to the beginning on the first call to updateOutputs() if isPlaying() returns true. You can also create a motion sequence dynamically at run time: //This code sample will stand up, point the head forward and up 0.1 radians, //and then autoprune //First declare the MotionSequence itself: SharedObject< MotionSequenceMC<MotionSequenceEngine::SizeSmall> > stand; //Over the course of the first 700 milliseconds, go to standing posture: standSit->setTime(700); standSit->setPose(PostureEngine("stand.pos")); // could also use standSit->loadFile("stand.pos") //Then take another 700 milliseconds to straighten out the head: standSit->advanceTime(700); //We'll set joints individually this time, instead of loading a posture file: standSit->setOutputCmd(HeadOffset+PanOffset,0); standSit->setOutputCmd(HeadOffset+RollOffset,0); standSit->setOutputCmd(HeadOffset+TiltOffset,0.1); //look up .1 radians //Add to MotionManager: motman->addPrunableMotion(standSit); //Playback will now begin automatically, and region deallocated when done By default, playing is true. Thus, when you add a MotionSequenceMC to the MotionManager, it will begin executing automatically. If you do not want this behavior, simply call pause() before adding the sequence. When the sequence reaches the end, isAlive() will return false. If the motion was added with MotionManager::addPrunableMotion, the motion sequence will then autoprune itself from the MotionManager. However, you can either call MotionManager::addPersistentMotion() to add it, or call setAutoPrune(false), if you want to retain the same instantiation between executions.
Definition at line 182 of file MotionSequenceEngine.h.
Member Typedef Documentation
type for indexes to move structures in subclass's storage Definition at line 240 of file MotionSequenceEngine.h. Constructor & Destructor Documentation
constructor, will start playing immediately Definition at line 13 of file MotionSequenceEngine.cc. Referenced by DynamicMotionSequence::DynamicMotionSequence().
destructor Definition at line 187 of file MotionSequenceEngine.h. Member Function Documentation
advance the play/edit index by x milliseconds, and then returns the new getTime() Definition at line 208 of file MotionSequenceEngine.h. Referenced by overlayMotion().
Does the actual calculation of position information. Perhaps replace with a Bezier or spline or something? Definition at line 274 of file MotionSequenceEngine.h. Referenced by compress(), getOutputCmd(), and MotionSequenceMC< MAXMOVE >::updateOutputs().
empties out the sequence (constant time operation - faster than a series of pops) Implemented in DynamicMotionSequence, and MotionSequenceMC< MAXMOVE >.
compresses the sequence by eliminating sequences of moves which are identical Definition at line 451 of file MotionSequenceEngine.cc.
causes subclass to mark the corresponding Move structure as free Implemented in DynamicMotionSequence, and MotionSequenceMC< MAXMOVE >. Referenced by compress().
inherited, returns the size used to save the sequence Implements LoadSave. Definition at line 53 of file MotionSequenceEngine.cc.
returns the length of the motion sequence (in milliseconds) Definition at line 229 of file MotionSequenceEngine.h. Referenced by overlayMotion().
return hold Definition at line 234 of file MotionSequenceEngine.h.
returns the Move struct corresponding to x in the subclass's actual data structure Implemented in DynamicMotionSequence, and MotionSequenceMC< MAXMOVE >.
returns the Move struct corresponding to x in the subclass's actual data structure Implemented in DynamicMotionSequence, and MotionSequenceMC< MAXMOVE >. Referenced by compress(), getBinSize(), getOutputCmd(), makeSafe(), overlayMotion(), resume(), saveBuffer(), setNextFrameTime(), setOutputCmd(), and setTime().
returns the maximum number of key frames (Move's) which can be stored, determined by the instantiating MotionSequenceMC's template parameter Implemented in DynamicMotionSequence, and MotionSequenceMC< MAXMOVE >.
gets the value of output i at the playhead Definition at line 40 of file MotionSequenceEngine.cc. Referenced by getPose(), and MotionSequenceMC< MAXMOVE >::updateOutputs().
returns the index for the output named in the string or NumOutputs if not found, begins search through RobotInfo::outputName's at index i Definition at line 571 of file MotionSequenceEngine.cc. Referenced by loadBuffer().
stores the set of OutputCmd's at the current playhead into the specified PostureEngine Definition at line 378 of file MotionSequenceEngine.cc.
returns the set of OutputCmd's at the current playhead as a PostureEngine Definition at line 372 of file MotionSequenceEngine.cc.
returns the playback speed Definition at line 231 of file MotionSequenceEngine.h.
returns the current position of the playback (in milliseconds), see setTime() Definition at line 228 of file MotionSequenceEngine.h. Referenced by overlayMotion().
returns the number of used key frames (Move's) which have been stored by the instantiation MotionSequenceEngine subclass Implemented in DynamicMotionSequence, and MotionSequenceMC< MAXMOVE >.
returns true if currently playing restarts playback from beginning Definition at line 508 of file MotionSequenceEngine.cc. Referenced by MotionSequenceMC< MAXMOVE >::isDirty(), MotionSequenceMC< MAXMOVE >::updateOutputs(), updateOutputs(), and DynamicMotionSequence::updateOutputs().
returns true if will store angles as degrees on future saves Definition at line 200 of file MotionSequenceEngine.h.
returns true if will store angles as degrees on future saves Definition at line 202 of file MotionSequenceEngine.h. Referenced by getBinSize(), and saveBuffer().
inherited, doesn't clear before loading - call clear yourself if you want to reset, otherwise it will overlay. Leaves playtime at end of load. Implements LoadSave. Definition at line 87 of file MotionSequenceEngine.cc.
inherited, doesn't clear before loading - call clear yourself if you want to reset, otherwise it will overlay. Leaves playtime at end of load. Definition at line 312 of file MotionSequenceEngine.cc. Referenced by MotionSequenceMC< MAXMOVE >::MotionSequenceMC(), overlayMotion(), and DynamicMotionSequence::~DynamicMotionSequence(). will insert time into the motion where needed to keep the joint velocities at or below the speeds given in vels * margin Definition at line 478 of file MotionSequenceEngine.cc.
causes subclass to create a new Move structure, returns its index Implemented in DynamicMotionSequence, and MotionSequenceMC< MAXMOVE >. Referenced by overlayMotion(), and setOutputCmd().
applies each keyframe of ms to this, leaves playhead at the end (in other words, advances playhead to end of ms)
This is not a particularly well implemented function -- it will interleave ms's keyframes with any pre-existing ones, but will clobber frames which coincide with ms's own. Probably will not give the desired effect when the motion is actually overlaying something, but it will work for basic usage cases. Definition at line 398 of file MotionSequenceEngine.cc.
loads msFile from disk and calls overlayMotion(const MotionSequenceEngine&) with it, returns the duration of msFile (0 if there was an error) Definition at line 383 of file MotionSequenceEngine.cc. Referenced by loadBuffer().
pauses playback until another call to play() or resume() Definition at line 226 of file MotionSequenceEngine.h.
returns true if currently playing restarts playback from beginning Definition at line 513 of file MotionSequenceEngine.cc. Referenced by updateOutputs().
reads a line from a file, parsing it into variables, returns ending position Definition at line 555 of file MotionSequenceEngine.cc. Referenced by loadBuffer().
begins playback from the current playtime Definition at line 521 of file MotionSequenceEngine.cc. Referenced by play().
inherited, saves the motion sequence - will save a flat file - doesn't remember references to other files which were loaded Implements LoadSave. Definition at line 246 of file MotionSequenceEngine.cc.
inherited, saves the motion sequence - will save a flat file - doesn't remember references to other files which were loaded Definition at line 315 of file MotionSequenceEngine.cc.
calls setOutputCmd on each of the OutputCmds in pose, even if they are zero-weight (can be used to fade joints in/out with other conflicting motions) Definition at line 367 of file MotionSequenceEngine.cc. Referenced by loadBuffer().
Sets hold - if this is set to false, it will allow a persistent motion to behave the same as a pruned motion, without being pruned. Definition at line 233 of file MotionSequenceEngine.h.
sets playtime to next time for which any output has a keyframe, -1 if none exists Definition at line 537 of file MotionSequenceEngine.cc. Referenced by getBinSize(), makeSafe(), and saveBuffer().
will insert a keyframe for the given output, or change an existing one Definition at line 334 of file MotionSequenceEngine.cc. Referenced by loadBuffer(), setExplicitPose(), and setPose().
calls setOutputCmd for all non-zero weighted OutputCmds in pose (if you wish to set from a file, use loadFile) Definition at line 361 of file MotionSequenceEngine.cc. Referenced by loadBuffer().
Sets prev and next to the appropriate values for the given time and output index, return true if there was a change. Implemented in DynamicMotionSequence, and MotionSequenceMC< MAXMOVE >. Referenced by setNextFrameTime(), and setTime().
deprecated, use radians instead; calling this will store angles as degrees on future saves
Definition at line 320 of file MotionSequenceEngine.cc.
will store angles as radians on future saves Definition at line 201 of file MotionSequenceEngine.h. Referenced by loadBuffer().
sets the playback speed (e.g. 1=regular, 0.5=half speed, -1=backwards) Definition at line 230 of file MotionSequenceEngine.h.
set the time for both playback and editing (in milliseconds) Definition at line 322 of file MotionSequenceEngine.cc. Referenced by advanceTime(), MotionSequenceMC< MAXMOVE >::clear(), loadBuffer(), MotionSequenceMC< MAXMOVE >::MotionSequenceMC(), play(), updateOutputs(), and DynamicMotionSequence::~DynamicMotionSequence().
similar to the MotionCommand::updateOutputs, although this isn't a motion command, and doesn't make any calls on MotionManager - merely updates lasttime, expects subclasses to do the work of sending new commands to the system Reimplemented in DynamicMotionSequence, and MotionSequenceMC< MAXMOVE >. Definition at line 22 of file MotionSequenceEngine.cc. Member Data Documentation
merely a cache of current values (if computed, see curstamps) Definition at line 257 of file MotionSequenceEngine.h. Referenced by getOutputCmd().
timestamp of corresponding value in curs Definition at line 258 of file MotionSequenceEngine.h. Referenced by getOutputCmd(), makeSafe(), MotionSequenceEngine(), overlayMotion(), and setOutputCmd().
max of moves's Move::starttime's Definition at line 261 of file MotionSequenceEngine.h. Referenced by MotionSequenceMC< MAXMOVE >::clear(), getEndTime(), isPlaying(), overlayMotion(), play(), and setOutputCmd().
if set to true, the posture will be kept active; otherwise joints will be marked unused after each posture is achieved (as if the posture was pruned); set through setHold() Definition at line 264 of file MotionSequenceEngine.h. Referenced by getHold(), getOutputCmd(), setHold(), and MotionSequenceMC< MAXMOVE >::updateOutputs().
used to mark the ends of the Move linked lists Definition at line 241 of file MotionSequenceEngine.h. Referenced by MotionSequenceMC< MAXMOVE >::clear(), compress(), getOutputCmd(), makeSafe(), MotionSequenceMC< MAXMOVE >::newKeyFrame(), overlayMotion(), resume(), setNextFrameTime(), setOutputCmd(), MotionSequenceMC< MAXMOVE >::setRange(), and MotionSequenceMC< MAXMOVE >::updateOutputs().
the time of the last update Definition at line 260 of file MotionSequenceEngine.h. Referenced by resume(), and updateOutputs().
1 to use radians, M_PI/180 for degrees during a save Definition at line 266 of file MotionSequenceEngine.h. Referenced by getBinSize(), isSaveDegrees(), isSaveRadians(), loadBuffer(), saveBuffer(), setSaveDegrees(), and setSaveRadians().
the upcoming frame (the starttime for this frame will always be greater than playtime) Definition at line 256 of file MotionSequenceEngine.h. Referenced by MotionSequenceMC< MAXMOVE >::clear(), getOutputCmd(), overlayMotion(), setOutputCmd(), setTime(), and MotionSequenceMC< MAXMOVE >::updateOutputs().
true if playing, false if paused Definition at line 263 of file MotionSequenceEngine.h. Referenced by isPlaying(), pause(), and resume().
multiplies the difference between current time and starttime, negative will cause play backwards Definition at line 262 of file MotionSequenceEngine.h. Referenced by getSpeed(), MotionSequenceMC< MAXMOVE >::isAlive(), isPlaying(), play(), setNextFrameTime(), setSpeed(), setTime(), and updateOutputs().
the current time of playback, 0 is start of sequence Definition at line 259 of file MotionSequenceEngine.h. Referenced by advanceTime(), getOutputCmd(), getTime(), isPlaying(), loadBuffer(), setOutputCmd(), setTime(), MotionSequenceMC< MAXMOVE >::updateOutputs(), and updateOutputs().
the previous frame (the starttime for this frame will always be less than or equal to playtime) Definition at line 255 of file MotionSequenceEngine.h. Referenced by MotionSequenceMC< MAXMOVE >::clear(), getOutputCmd(), overlayMotion(), setOutputCmd(), setTime(), and MotionSequenceMC< MAXMOVE >::updateOutputs().
the beginning frame for each output animation Definition at line 254 of file MotionSequenceEngine.h. Referenced by MotionSequenceMC< MAXMOVE >::clear(), compress(), getBinSize(), makeSafe(), overlayMotion(), resume(), and saveBuffer(). The documentation for this class was generated from the following files: |
Tekkotsu v5.1CVS |
Generated Mon May 9 04:59:13 2016 by Doxygen 1.6.3 |