@ThreadSafe public class SequenceDriver extends TrajectoryDriver
Interpolates waypoints along a trajectory.
Copyright (C) 2009 Marsette A. Vona, III
| Modifier and Type | Class and Description | 
|---|---|
| static interface  | SequenceDriver.AdvanceHookinterface for callback on advance to next waypoint | 
| static class  | SequenceDriver.ApplyingAdvanceHookGeneric  SequenceDriver.AdvanceHookimpl that delegates to an object
 implementing anapply(Object[])method. | 
| static class  | SequenceDriver.Stateplayback state machine states | 
| protected static class  | SequenceDriver.Waypointcollection of data for a waypoint | 
| Modifier and Type | Field and Description | 
|---|---|
| protected SequenceDriver.AdvanceHook | advanceHook | 
| protected vona.math.RXSInterpolator.InterpolationType | constrainedInterpolationType(un)constrained interpolation type | 
| private static java.lang.String | cvsid | 
| protected double | interpolationStartstart/duration of current interpolation | 
| protected double | interpolationTimestart/duration of current interpolation | 
| protected vona.math.RXSInterpolator[] | interpolatorinterpolators for each bound transform | 
| protected boolean | loopwhether playback is set to cycle | 
| protected int | nextWaypointIndex of the next  SequenceDriver.Waypointinwaypointsthat will be
 played back, or equal towaypoints.size()if none. | 
| protected double | pauseTimeTrajectoryActor.clocktime whenSequenceDriver.State.PAUSEbegan | 
| protected SequenceDriver.State | statecurrent playback state | 
| protected vona.math.RXSInterpolator.InterpolationType | unconstrainedInterpolationType(un)constrained interpolation type | 
| protected java.util.Iterator<SequenceDriver.Waypoint> | waypointIteratorcurrent iterator on  waypointsduring playback | 
| protected java.util.LinkedList<SequenceDriver.Waypoint> | waypointsThe current list of waypoints. | 
lastUpdateTimeactive, clock, joint, slackID, wasOnlySetChangedGoalComponents, xform, xformID| Constructor and Description | 
|---|
| SequenceDriver()covers superclass impl | 
| SequenceDriver(vona.time.Clock clock)covers superclass impl | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | advance()Advance  interpolators to the next waypoint. | 
| void | appendWaypoint(vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
              double interpolationTime,
              double... waypoint)Inserts at end of sequence | 
| void | appendWaypoint(vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
              double interpolationTime,
              vona.math.RX... waypoint)Inserts at end of sequence | 
| int | bind(java.lang.Object... specs)Fill the set of transforms which this TrajectoryActor reads/writes, in
 order. | 
| void | clearWaypoints()Remove all current waypoints. | 
| vona.math.RXSInterpolator.InterpolationType | getConstrainedInterpolationType()get the interpolation type for constrained transforms | 
| protected double | getInterpolationCoordinate()Get the current normalized interpolation coordinate in [0.0, 1.0]. | 
| int | getNextWaypoint()get the index of the next waypoint that will be played back | 
| int | getNumWaypoints()get the current number of waypoints in the sequence | 
| SequenceDriver.State | getState()get the current playback  SequenceDriver.State | 
| vona.math.RXSInterpolator.InterpolationType | getUnconstrainedInterpolationType()get the interpolation type for unconstrained transforms | 
| boolean | insertWaypoint(int index,
              vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
              double interpolationTime,
              double... waypoint)Interprets waypoint as a packed TXEM DoF vector. | 
| boolean | insertWaypoint(int index,
              vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
              double interpolationTime,
              vona.math.RX... waypoint)Insert a new waypoint. | 
| boolean | isLoop()Check whether playback cycles back to the waypoint sequence start after
 attaining the last waypoint. | 
| boolean | needsUpdate()Called by the update thread when this TrajectoryActor is active to
 check whether  TrajectoryActor.update()needs to be called soon. | 
| void | pause()Pause any ongoing sequence playback. | 
| void | play()Begin or resume sequence playback. | 
| void | prependWaypoint(vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
               double interpolationTime,
               double... waypoint)Inserts at start of sequence. | 
| void | prependWaypoint(vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
               double interpolationTime,
               vona.math.RX... waypoint)Inserts at start of sequence. | 
| void | removeWaypoint(int index)Remove an existing waypoint from the sequence. | 
| void | rewind()convenience to  setNextWaypoint(int)to 0 | 
| SequenceDriver.AdvanceHook | setAdvanceHook(SequenceDriver.AdvanceHook hook)Register a hook to be
 called after advancing to each waypoint. | 
| void | setConstrainedInterpolationType(vona.math.RXSInterpolator.InterpolationType interpolationType)set the interpolation type for constrained transforms | 
| void | setLoop(boolean loop)Set whether playback cycles back to the waypoint sequence start after
 attaining the last waypoint. | 
| void | setNextWaypoint(int index)Set the index of the first waypoint to be played back. | 
| void | setUnconstrainedInterpolationType(vona.math.RXSInterpolator.InterpolationType interpolationType)set the interpolation type for unconstrained transforms | 
| void | stop()Stop any ongoing sequence playback. | 
| void | unbind()Clear the set of transforms which this TrajectoryActor reads/writes. | 
| void | update()Read/write transform state from/to model. | 
| protected void | updateXForms()Update the  TrajectoryActor.xformvalues from their driving source. | 
| protected void | updateXForms(double interpolationCoordinate)Updates  TrajectoryActor.xforms frominterpolators given
 interpolationCoordinate. | 
activate, compareXFormsInNeedsUpdate, deactivate, getMinUpdateTime, updateXFormsInNeedsUpdatecheckBindings, clampXForms, compareXFormsToModel, getBoundJoint, getBoundXForm, getDefaultXForm, getNumBindings, getOriginalUnsetGoal, isActive, modelStateChanged, modelStructureChanged, onlySetChangedGoalComponents, readXFormsFromModel, writeXFormsToModelprivate static final java.lang.String cvsid
protected SequenceDriver.State state
protected java.util.LinkedList<SequenceDriver.Waypoint> waypoints
The current list of waypoints.
This is only mutable when in playback state SequenceDriver.State.IDLE.
Any existing waypoints will be checked for compatiblity with a new
 bind(java.lang.Object...).
protected int nextWaypoint
Index of the next SequenceDriver.Waypoint in waypoints that will be
 played back, or equal to waypoints.size() if none.
protected java.util.Iterator<SequenceDriver.Waypoint> waypointIterator
waypoints during playbackprotected double interpolationStart
protected double interpolationTime
protected double pauseTime
TrajectoryActor.clock time when SequenceDriver.State.PAUSE beganprotected boolean loop
protected vona.math.RXSInterpolator[] interpolator
protected vona.math.RXSInterpolator.InterpolationType constrainedInterpolationType
protected vona.math.RXSInterpolator.InterpolationType unconstrainedInterpolationType
protected SequenceDriver.AdvanceHook advanceHook
public SequenceDriver(vona.time.Clock clock)
public SequenceDriver()
public void play()
Begin or resume sequence playback.
This can be called from any state.
The state will automatically return to SequenceDriver.State.IDLE after the
 last waypoint (unless looping) or if there are no waypoints.
public void pause()
Pause any ongoing sequence playback.
Interpolation stops immediately.
public void stop()
Stop any ongoing sequence playback.
Interpolation continues until the current waypoint is attained.
public void rewind()
setNextWaypoint(int) to 0public SequenceDriver.State getState()
SequenceDriver.Statepublic void setLoop(boolean loop)
Set whether playback cycles back to the waypoint sequence start after attaining the last waypoint.
java.lang.IllegalStateException - if called when not in SequenceDriver.State.IDLEpublic boolean isLoop()
Check whether playback cycles back to the waypoint sequence start after attaining the last waypoint.
public void setNextWaypoint(int index)
Set the index of the first waypoint to be played back.
index - the index of the first waypoint to be played back, negative
 treated as 0, greater than or equal to waypoints.size()waypoints.size()-1java.lang.IllegalStateException - if called when not in SequenceDriver.State.IDLEpublic int getNextWaypoint()
public boolean insertWaypoint(int index,
                     vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
                     double interpolationTime,
                     vona.math.RX... waypoint)
Insert a new waypoint.
The passed transforms will be clamped to the current limits of the corresponding bound joints, where appliccable.
index - the index of the new waypoint (existing waypoints at this and
 hider indices will have their indices incremented), negative treated as 0,
 greater than waypoints.size()waypoints.size()interpolationTime - the time in seconds to spend interpolating to
 this waypoint, not NaN and not negativejava.lang.IllegalArgumentException - if the number of passed transforms
 does not equal the number of currently bound transformsjava.lang.IllegalStateException - if called when not in SequenceDriver.State.IDLEpublic boolean insertWaypoint(int index,
                     vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
                     double interpolationTime,
                     double... waypoint)
Interprets waypoint as a packed TXEM DoF vector.
public void appendWaypoint(vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
                  double interpolationTime,
                  vona.math.RX... waypoint)
Inserts at end of sequence
public void appendWaypoint(vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
                  double interpolationTime,
                  double... waypoint)
Inserts at end of sequence
public void prependWaypoint(vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
                   double interpolationTime,
                   vona.math.RX... waypoint)
Inserts at start of sequence.
public void prependWaypoint(vona.math.RXSInterpolator.InterpolationProfile interpolationProfile,
                   double interpolationTime,
                   double... waypoint)
Inserts at start of sequence.
public void removeWaypoint(int index)
Remove an existing waypoint from the sequence.
index - the index of the waypoint to remove, negative treated as 0,
 greater than or equal to waypoints.size()waypoints.size()-1java.lang.IllegalStateException - if called when not in SequenceDriver.State.IDLEpublic void clearWaypoints()
Remove all current waypoints.
java.lang.IllegalStateException - if called when not in SequenceDriver.State.IDLEpublic int getNumWaypoints()
public void setConstrainedInterpolationType(vona.math.RXSInterpolator.InterpolationType interpolationType)
public vona.math.RXSInterpolator.InterpolationType getConstrainedInterpolationType()
getConstrainedInterpolationType in class TrajectoryActorpublic void setUnconstrainedInterpolationType(vona.math.RXSInterpolator.InterpolationType interpolationType)
public vona.math.RXSInterpolator.InterpolationType getUnconstrainedInterpolationType()
getUnconstrainedInterpolationType in class TrajectoryActorpublic int bind(java.lang.Object... specs)
Fill the set of transforms which this TrajectoryActor reads/writes, in order.
This impl extends superclass impl to allocate interpolator.
bind in class TrajectoryActorspecs - a set of Joint sub-transform specifiers, in order,
 each of the the form (joint, name, or path, sub-transform
 ID...).  If no sub-transform IDs are given then TrajectoryActor.getDefaultXForm() is implied.  If more than one sub-transform ID is given
 then more than one binding is specified.java.lang.IllegalStateException - if called when not in SequenceDriver.State.IDLEjava.lang.IllegalStateException - if there are existing waypoints and they
 are not compatible with the new bindings (the driver will be left unbound)public void unbind()
Clear the set of transforms which this TrajectoryActor reads/writes.
This impl extends superclass impl to deallocate interpolator.
unbind in class TrajectoryActorjava.lang.IllegalStateException - if called when not in SequenceDriver.State.IDLEpublic void update()
Read/write transform state from/to model.
This is called automatically by the update thread whenever this TrajectoryActor is active. See class header doc for details.
This impl sets TrajectoryDriver.lastUpdateTime, TrajectoryDriver.updateXForms(), and then
 TrajectoryActor.writeXFormsToModel().
This impl marks TrajectoryDriver.lastUpdateTime, and then updateXForms()
 and TrajectoryActor.writeXFormsToModel() iff playback state is SequenceDriver.State.PLAY
 or SequenceDriver.State.STOPPING.  Also handles advance()ing from waypoint
 to waypoint, and stopping playback when finished.
update in class TrajectoryDriverpublic boolean needsUpdate()
Called by the update thread when this TrajectoryActor is active to
 check whether TrajectoryActor.update() needs to be called soon.
This impl does TrajectoryDriver.updateXForms() then returns the opposite of
 TrajectoryActor.compareXFormsToModel() iff TrajectoryDriver.lastUpdateTime is NaN or is
 at least as long ago as TrajectoryDriver.getMinUpdateTime().
The comparison is skipped if not TrajectoryDriver.compareXFormsInNeedsUpdate(),
 and otherwise the update is skipped if not TrajectoryDriver.updateXFormsInNeedsUpdate().
This impl returns true if it's been at least TrajectoryDriver.getMinUpdateTime()
 since the last update() and playback state is SequenceDriver.State.PLAY or
 SequenceDriver.State.STOPPING.
needsUpdate in class TrajectoryDriverpublic SequenceDriver.AdvanceHook setAdvanceHook(SequenceDriver.AdvanceHook hook)
Register a hook to be called after advancing to each waypoint.
protected void updateXForms()
Update the TrajectoryActor.xform values from their driving source.
This impl calls updateXForms(double) with getInterpolationCoordinate().
updateXForms in class TrajectoryDriverprotected void updateXForms(double interpolationCoordinate)
Updates TrajectoryActor.xforms from interpolators given
 interpolationCoordinate.
protected double getInterpolationCoordinate()
Get the current normalized interpolation coordinate in [0.0, 1.0].
protected void advance()
Advance interpolators to the next waypoint.