@ThreadSafe
public abstract class TrajectoryActor
extends java.lang.Object
Base class for drivers and observers of Joint
sub-transform
trajectories.
A trajectory maps time to the values of a set of Joint
sub-transforms. Time is derived from a clock
, which may provide
wall-clock time, simulation time, or another time of the implementation's
choosing. The set of joint sub-transforms is mutable (bind(java.lang.Object...)
), and is
initially empty.
Trajectory actors are not initially active. activate()
enables
the actor for scheduling in the update thread, and deactivate()
disables it. update()
will be called as soon as possible whenever
needsUpdate()
returns true while active.
Controller.LOCK
guards all state. Normally methods are called
from the update thread, e.g. by scheduling an update task.
Copyright (C) 2008 Marsette A. Vona, III
Modifier and Type | Field and Description |
---|---|
protected boolean |
active
whether this actor is currently activated for scheduling
|
vona.time.Clock |
clock
the time base for this TrajectoryActor
|
private static java.lang.String |
cvsid |
protected Joint[] |
joint
The Joints containing the transforms which this TrajectoryActor
reads/writes, in order.
|
int |
slackID
If non-negative, hold the overall Joint transform when modifying a
chain-subtransform in
writeXFormsToModel() by putting the slack
in this chain subtransform. |
protected boolean |
wasOnlySetChangedGoalComponents
Whether
onlySetChangedGoalComponents() was true during last
writeXFormsToModel() . |
protected vona.math.RX[] |
xform
Sub-transform values read/written by
readXFormsFromModel() /writeXFormsToModel() . |
protected int[] |
xformID
The sub-transform identifiers which this TrajectoryActor
reads/writes, in order.
|
Constructor and Description |
---|
TrajectoryActor()
Makes a new trajectory actor using a default
Clock (wall-clock
time). |
TrajectoryActor(vona.time.Clock clock)
Creates a new trajectory actor with the given clock.
|
Modifier and Type | Method and Description |
---|---|
void |
activate()
Enable this TrajectoryActor for scheduling by the update thread.
|
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. |
boolean |
clampXForms()
Clamp current
xform values associated with Joint
Joint.RX_MOBILITY , Joint.RX_TARGET , or Joint.RX_POSTURE sub-transforms to the current limits for that Joint . |
protected boolean |
compareXFormsToModel()
|
void |
deactivate()
Disable this TrajectoryActor for scheduling by the model update
thread.
|
Joint |
getBoundJoint(int index)
get the
Joint of the indicated binding |
int |
getBoundXForm(int index)
get the
Joint sub-transform ID of the indicated binding |
protected vona.math.RXSInterpolator.InterpolationType |
getConstrainedInterpolationType()
Hook to get the preferred
RXSInterpolator interpolation type
for constrained transforms. |
protected int |
getDefaultXForm()
Get the default sub-transform identifier for
bind(java.lang.Object...) . |
int |
getNumBindings()
Get the size of the set of transforms which this TrajectoryActor
reads/writes.
|
protected vona.math.RX |
getOriginalUnsetGoal(int i)
Get the original goal transform to use for comparison purposes in
writeXFormsToModel() . |
protected vona.math.RXSInterpolator.InterpolationType |
getUnconstrainedInterpolationType()
Hook to get the preferred
RXSInterpolator interpolation type
for unconstrained transforms. |
boolean |
isActive()
Check whether this TrajectoryActor is enabled for scheduling by the
update thread.
|
void |
modelStateChanged()
Called by the update thread when this TrajectoryActor is active after
the model state changes, and after that state change has been otherwise
handled, including one
Solver iteration. |
void |
modelStructureChanged()
Called by the update thread when this TrajectoryActor is active after
the model structure changes.
|
abstract boolean |
needsUpdate()
Called by the update thread when this TrajectoryActor is active to
check whether
update() needs to be called soon. |
protected boolean |
onlySetChangedGoalComponents()
Whether to only set changed goal transform components in
writeXFormsToModel() . |
protected void |
readXFormsFromModel()
|
void |
unbind()
Clear the set of transforms which this TrajectoryActor reads/writes.
|
abstract void |
update()
Read/write transform state from/to model.
|
protected boolean |
writeXFormsToModel()
|
private static final java.lang.String cvsid
public final vona.time.Clock clock
protected Joint[] joint
The Joints containing the transforms which this TrajectoryActor reads/writes, in order.
protected int[] xformID
The sub-transform identifiers which this TrajectoryActor reads/writes, in order.
protected vona.math.RX[] xform
Sub-transform values read/written by readXFormsFromModel()
/writeXFormsToModel()
.
protected boolean active
protected boolean wasOnlySetChangedGoalComponents
Whether onlySetChangedGoalComponents()
was true during last
writeXFormsToModel()
.
public volatile int slackID
If non-negative, hold the overall Joint transform when modifying a
chain-subtransform in writeXFormsToModel()
by putting the slack
in this chain subtransform.
Ignored if negative, if not Joint.isChainSubtransform(int)
, or if
equal to the particular xformID
of any given binding.
public TrajectoryActor(vona.time.Clock clock)
Creates a new trajectory actor with the given clock.
public TrajectoryActor()
Makes a new trajectory actor using a default Clock
(wall-clock
time).
public int bind(java.lang.Object... specs)
Fill the set of transforms which this TrajectoryActor reads/writes, in order.
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 getDefaultXForm()
is implied. If more than one sub-transform ID is given
then more than one binding is specified.public void unbind()
Clear the set of transforms which this TrajectoryActor reads/writes.
public int getNumBindings()
Get the size of the set of transforms which this TrajectoryActor reads/writes.
public int getBoundXForm(int index)
Joint
sub-transform ID of the indicated bindingpublic void activate()
Enable this TrajectoryActor for scheduling by the update thread.
java.lang.IllegalStateException
- if any of the currently bound transforms
is not presentpublic void deactivate()
Disable this TrajectoryActor for scheduling by the model update thread.
public boolean isActive()
Check whether this TrajectoryActor is enabled for scheduling by the update thread.
public void modelStateChanged()
Called by the update thread when this TrajectoryActor is active after
the model state changes, and after that state change has been otherwise
handled, including one Solver
iteration.
Default impl does nothing.
public void modelStructureChanged()
Called by the update thread when this TrajectoryActor is active after the model structure changes.
Default impl calls checkBindings()
.
java.lang.IllegalStateException
- if any of the currently bound transforms
is not presentpublic abstract 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.
public abstract boolean needsUpdate()
Called by the update thread when this TrajectoryActor is active to
check whether update()
needs to be called soon.
protected int getDefaultXForm()
Get the default sub-transform identifier for bind(java.lang.Object...)
.
Default impl returns Joint.RX_MOBILITY
.
protected vona.math.RXSInterpolator.InterpolationType getUnconstrainedInterpolationType()
Hook to get the preferred RXSInterpolator
interpolation type
for unconstrained transforms.
Default impl returns RXSInterpolator.InterpolationType.SCREW
.
protected vona.math.RXSInterpolator.InterpolationType getConstrainedInterpolationType()
Hook to get the preferred RXSInterpolator
interpolation type
for constrained transforms.
Default impl returns RXSInterpolator.InterpolationType.LINEAR_TXEM
.
protected void checkBindings()
Check that the Joint
of each binding is still present.
java.lang.IllegalStateException
- if any of the currently bound transforms
is no longer presentprotected void readXFormsFromModel()
protected boolean writeXFormsToModel()
protected boolean onlySetChangedGoalComponents()
Whether to only set changed goal transform components in writeXFormsToModel()
.
Also see getOriginalUnsetGoal(int)
.
Default impl returns false.
protected vona.math.RX getOriginalUnsetGoal(int i)
Get the original goal transform to use for comparison purposes in
writeXFormsToModel()
.
This is used to implement onlySetChangedGoalComponents()
.
Return null to use the current value of the goal transform of joint
i.
Default impl returns null.
public boolean clampXForms()
Clamp current xform
values associated with Joint
Joint.RX_MOBILITY
, Joint.RX_TARGET
, or Joint.RX_POSTURE
sub-transforms to the current limits for that Joint
.
protected boolean compareXFormsToModel()