msim.ui
Class InteractorDriver

java.lang.Object
  extended by msim.trajectory.TrajectoryActor
      extended by msim.trajectory.TrajectoryDriver
          extended by msim.ui.InteractorDriver

@ThreadSafe
public class InteractorDriver
extends TrajectoryDriver

Drives a Joint sub-transform trajectory from an InteractorDriver.JointInteractor.

Copyright (C) 2008 Marsette A. Vona, III

Author:
Marsette A. Vona, III

Nested Class Summary
protected  class InteractorDriver.JointInteractor
          Special RXSInteractor for manipulating Joint sub-transforms.
 
Field Summary
private static java.lang.String cvsid
           
static double DEF_MIN_UPDATE_TIME
          default value for getMinUpdateTime() in TrajectoryActor.clock time
protected  boolean driveFullGoal
          whether to not onlySetChangedGoalComponents()
 InteractorDriver.JointInteractor jointInteractor
          the interactor
 vona.math.RXSInterpolator jointInterpolator
          the interpolator
protected  vona.math.RX manipulationToGroundRX
          An arbitrary rigid transform taking RXSInteractor manipulation frame coordinates to Linkage ground frame.
protected  vona.math.RX restoreRX
          the original Joint sub-transform state at activate()
protected  vona.math.RX subFrameCMT
          Temp storage for transform taking the parent frame of the manipulated Joint sub-transform to world frame.
 
Fields inherited from class msim.trajectory.TrajectoryDriver
lastUpdateTime
 
Fields inherited from class msim.trajectory.TrajectoryActor
active, clock, joint, slackID, xform, xformID
 
Constructor Summary
InteractorDriver()
          Makes a new interactor driver using a default Clock (wall-clock time).
InteractorDriver(vona.time.Clock clock)
          makes a new interactor driver
 
Method Summary
 void activate()
          extends superclass impl to updateInteractor() and enable it
 int bind(java.lang.Object... specs)
          Fill the set of transforms which this TrajectoryActor reads/writes, in order.
protected  void checkBindings()
          Check that the Joint of each binding is still present.
protected  boolean compareXFormsInNeedsUpdate()
          Whether to TrajectoryActor.compareXFormsToModel() in TrajectoryDriver.needsUpdate().
 void deactivate()
          extends superclass impl to disable jointInteractor
 vona.ui.RXSInteractor getInteractor()
          get jointInteractor
 vona.math.RXSInterpolator getInterpolator()
          get jointInterpolator
 double getMinUpdateTime()
          Get the minimum time in TrajectoryActor.clock time between calls to TrajectoryDriver.needsUpdate() which return true.
protected  vona.math.RX getOriginalUnsetGoal(int i)
          Get the original goal transform to use for comparison purposes in TrajectoryActor.writeXFormsToModel().
 void modelStructureChanged()
          Called by the update thread when this TrajectoryActor is active after the model structure changes.
protected  boolean onlySetChangedGoalComponents()
          Whether to only set changed goal transform components in TrajectoryActor.writeXFormsToModel().
 boolean restore()
          restore(boolean) without jumping
 boolean restore(boolean jump)
          Restore the Joint sub-transform to its original state at activate().
 void setDriveFullGoal(boolean driveFullGoal)
          set driveFullGoal
 void setManipulationToGround(vona.math.RX rx, boolean invert)
          Set the manipulationToGroundRX transform by copy.
 void unbind()
          extends superclass impl to updateInteractor() after unbinding
protected  void updateInteractor()
          InteractorDriver.JointInteractor.bind(msim.model.Joint, int) or InteractorDriver.JointInteractor.unbind() jointInteractor, as appropriate.
 void updateManipulationFrameRX()
          Update jointInteractor's "manipulation"-to-"world" transform.
protected  void updateXForms()
          Update the TrajectoryActor.xform values from their driving source.
 
Methods inherited from class msim.trajectory.TrajectoryDriver
needsUpdate, update, updateXFormsInNeedsUpdate
 
Methods inherited from class msim.trajectory.TrajectoryActor
clampXForms, compareXFormsToModel, getBoundJoint, getBoundXForm, getConstrainedInterpolationType, getDefaultXForm, getNumBindings, getUnconstrainedInterpolationType, isActive, modelStateChanged, readXFormsFromModel, writeXFormsToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvsid

private static final java.lang.String cvsid
See Also:
Constant Field Values

DEF_MIN_UPDATE_TIME

public static final double DEF_MIN_UPDATE_TIME
default value for getMinUpdateTime() in TrajectoryActor.clock time

See Also:
Constant Field Values

jointInteractor

public final InteractorDriver.JointInteractor jointInteractor
the interactor


jointInterpolator

public final vona.math.RXSInterpolator jointInterpolator
the interpolator


driveFullGoal

protected boolean driveFullGoal
whether to not onlySetChangedGoalComponents()


restoreRX

protected final vona.math.RX restoreRX
the original Joint sub-transform state at activate()


manipulationToGroundRX

protected final vona.math.RX manipulationToGroundRX

An arbitrary rigid transform taking RXSInteractor manipulation frame coordinates to Linkage ground frame.

This is one component of the manipulation frame to RXSInteractor world frame transform, see updateManipulationFrameRX() for details.

Display uses an InteractorDriver to implement joint manipulation, and tracks manipulationToGroundRX to the rigid part of the navigation view-to-world transform. It also tracks the RXSInteractor world-to-canvas scale to the product of the Display world-to-view and view-to-canvas scales.


subFrameCMT

protected final vona.math.RX subFrameCMT

Temp storage for transform taking the parent frame of the manipulated Joint sub-transform to world frame.

Used in updateManipulationFrameRX().

Constructor Detail

InteractorDriver

public InteractorDriver(vona.time.Clock clock)
makes a new interactor driver


InteractorDriver

public InteractorDriver()

Makes a new interactor driver using a default Clock (wall-clock time).

Method Detail

bind

public int bind(java.lang.Object... specs)

Fill the set of transforms which this TrajectoryActor reads/writes, in order.

This impl extends the superclass impl to ensure that at most one transform is bound.

Overrides:
bind in class TrajectoryActor
Parameters:
specs - 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.
Returns:
the number of transforms bound

unbind

public void unbind()
extends superclass impl to updateInteractor() after unbinding

Overrides:
unbind in class TrajectoryActor

activate

public void activate()
extends superclass impl to updateInteractor() and enable it

Overrides:
activate in class TrajectoryDriver

deactivate

public void deactivate()
extends superclass impl to disable jointInteractor

Overrides:
deactivate in class TrajectoryDriver

modelStructureChanged

public void modelStructureChanged()

Called by the update thread when this TrajectoryActor is active after the model structure changes.

Default impl calls TrajectoryActor.checkBindings().

This impl chains to the superclass impl and then does updateInteractor().

Overrides:
modelStructureChanged in class TrajectoryActor

restore

public boolean restore(boolean jump)

Restore the Joint sub-transform to its original state at activate().

Returns:
true iff the current state was different than the original

restore

public boolean restore()
restore(boolean) without jumping


checkBindings

protected void checkBindings()

Check that the Joint of each binding is still present.

Extends superclass impl with additional checks.

Overrides:
checkBindings in class TrajectoryActor
Throws:
java.lang.IllegalStateException - if manipulating mobility and either goal becomes set
java.lang.IllegalStateException - if manipulating mobility and joint becomes a closure
java.lang.IllegalStateException - if manipulating posture and target becomes set

updateXForms

protected void updateXForms()

Update the TrajectoryActor.xform values from their driving source.

This impl reads the current transform from jointInteractor.

Specified by:
updateXForms in class TrajectoryDriver

compareXFormsInNeedsUpdate

protected boolean compareXFormsInNeedsUpdate()

Whether to TrajectoryActor.compareXFormsToModel() in TrajectoryDriver.needsUpdate().

Default impl returns true.

This impl returns false.

Overrides:
compareXFormsInNeedsUpdate in class TrajectoryDriver

updateInteractor

protected void updateInteractor()

InteractorDriver.JointInteractor.bind(msim.model.Joint, int) or InteractorDriver.JointInteractor.unbind() jointInteractor, as appropriate.

We also re-read TrajectoryActor.xform (and restoreRX if the joint or transform id changed) from the bound sub-transform, and we jump the interactor to this initial state.


getMinUpdateTime

public double getMinUpdateTime()

Get the minimum time in TrajectoryActor.clock time between calls to TrajectoryDriver.needsUpdate() which return true.

Default impl returns 0.

This impl returns DEF_MIN_UPDATE_TIME.

Overrides:
getMinUpdateTime in class TrajectoryDriver

getInteractor

public vona.ui.RXSInteractor getInteractor()
get jointInteractor


getInterpolator

public vona.math.RXSInterpolator getInterpolator()
get jointInterpolator


setManipulationToGround

public void setManipulationToGround(vona.math.RX rx,
                                    boolean invert)

Set the manipulationToGroundRX transform by copy.

Parameters:
invert - whether to invert manipulationToGroundRX after setting it

updateManipulationFrameRX

public void updateManipulationFrameRX()

Update jointInteractor's "manipulation"-to-"world" transform.

The interactor's manipulation frame is actually the Display view frame, and the interactor's "world" frame is the parent frame of the manipulated transform, which will in general be a sub-frame of the manipulated joint. The full transform chain in order is

  1. the view-to-ground transform, as set to manipulationToGroundRX by Display
  2. the inverse of the bound joint's CMT
  3. the inverse of the sub-frame transform for the manipulated sub-transform (see Joint.getSubFrameRX(int, RX))

This is called automatically for all active InteractorDrivers whose interactor is currently controlling in manipulation frame by the update thread.


setDriveFullGoal

public void setDriveFullGoal(boolean driveFullGoal)
set driveFullGoal


onlySetChangedGoalComponents

protected boolean onlySetChangedGoalComponents()

Whether to only set changed goal transform components in TrajectoryActor.writeXFormsToModel().

Also see TrajectoryActor.getOriginalUnsetGoal(int).

Default impl returns false.

This impl returns the opposite of driveFullGoal.

Overrides:
onlySetChangedGoalComponents in class TrajectoryActor

getOriginalUnsetGoal

protected vona.math.RX getOriginalUnsetGoal(int i)

Get the original goal transform to use for comparison purposes in TrajectoryActor.writeXFormsToModel().

This is used to implement TrajectoryActor.onlySetChangedGoalComponents().

Return null to use the current value of the goal transform of TrajectoryActor.joint i.

Default impl returns null.

This impl returns restoreRX.

Overrides:
getOriginalUnsetGoal in class TrajectoryActor