public class TrackingController extends ControllerBase implements CompositeComponent, RenderableComponent
Terminology:
"Targets" | are trajectories of points/frames that we wish our model to follow |
"Markers" or "Sources" | are the points/frames in the model we want to follow the target trajectories |
"Excitation" | we actually mean, "activation", since we are currently ignoring the excitation dynamics |
Papers:
- Ian Stavness, JE Lloyd, and SS Fels. Automatic Prediction of Tongue Muscle
Activations Using a Finite Element Model. Journal of Biomechanics,
45(16):2841-2848, 2012.
- Ian Stavness, AG Hannam, JE Lloyd, and SS Fels. Predicting muscle patterns
for hemimandibulectomy models. Computer Methods in Biomechanics and
Biomedical Engineering, 13(4):483-491, 2010.
CompositeComponent.NavpanelDisplay
ModelComponent.NavpanelVisibility
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_DEBUG |
static double |
DEFAULT_EXCITATION_REGULARIZATION_WEIGHT |
static double |
DEFAULT_MAX_EXCITATION_JUMP |
static double |
DEFAULT_PROBE_DURATION |
static double |
DEFAULT_PROBE_INTERVAL |
static boolean |
DEFAULT_USE_INVERSE_MANAGER |
static PropertyList |
myProps |
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
TrackingController(MechSystemBase m)
Creates a tracking controller for a given mech system
|
TrackingController(MechSystemBase m,
java.lang.String name)
Creates and names a tracking controller for a given mech system
|
Modifier and Type | Method and Description |
---|---|
void |
addCostTerm(QPTerm term)
Add another term to the optimization, typically
for regularization
|
DampingTerm |
addDampingTerm()
Adds and returns a standard damping term on excitations
|
DampingTerm |
addDampingTerm(double w)
Adds and returns a standard damping term on excitations,
weighted by the supplied value
|
void |
addEqualityTerm(LeastSquaresTerm term)
Add an equality constraint to the optimization
|
void |
addExciter(double weight,
ExcitationComponent ex)
Adds an exciter to be used as a free variable in the inverse routine
|
void |
addExciter(double weight,
ExcitationComponent ex,
double gain)
Adds an exciter to be used as a free variable in the inverse routine
|
void |
addExciter(ExcitationComponent ex)
Adds an exciter to be used as a free variable in the inverse routine
|
void |
addExciter(ExcitationComponent ex,
double gain)
Adds an exciter to be used as a free variable in the inverse routine
|
void |
addForceTargetTerm(ForceTargetTerm ft) |
void |
addInequalityTerm(LeastSquaresTerm term)
Add an inequality constraint to the optimization
|
L2RegularizationTerm |
addL2RegularizationTerm()
Adds and returns a standard L2 regularization term on excitations
|
L2RegularizationTerm |
addL2RegularizationTerm(double w)
Adds and returns a standard L2 regularization term on excitations,
weighted by the supplied value
|
MotionTargetComponent |
addMotionTarget(MotionTargetComponent source)
Adds a source for the tracking and creates a corresponding target point
or frame object
|
MotionTargetComponent |
addMotionTarget(MotionTargetComponent source,
double weight)
Adds a source for the tracking and creates a corresponding target point
or frame object
|
void |
addRegularizationTerms(java.lang.Double w_l2norm,
java.lang.Double w_damping)
Adds both L2 and damping regularization terms with supplied weights
|
void |
apply(double t0,
double t1)
Applies the controller, estimating and setting the next
set of muscle activations
|
void |
clearExciters()
Clears all exciters
|
void |
componentChanged(ComponentChangeEvent e)
Notifies this composite component that a change has occured within one or
more of its descendants.
|
void |
createPanel(RootModel root)
Creates a control panel for this inverse controller
|
void |
createProbes(RootModel root) |
void |
createProbesAndPanel(RootModel root) |
void |
dispose()
Clears all terms and disposes storage
|
ModelComponent |
findComponent(java.lang.String path)
Recursively searches for a sub-component of this ModelComponent,
identified by a path of component names.
|
ModelComponent |
get(int idx)
Returns a specific sub-component of this ModelComponent, identified by
index.
|
ModelComponent |
get(java.lang.String nameOrNumber)
Returns a specific sub-component of this ModelComponent, identified by
name or string representation of the sub-component's number
|
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
ModelComponent |
getByNumber(int num)
Returns a specific sub-component of this ModelComponent, identified by
number.
|
java.util.ArrayList<QPTerm> |
getCostTerms()
Retrieves a list of all terms, including the tracking error
and any regularization terms
|
MotionForceInverseData |
getData() |
boolean |
getDebug() |
java.util.ArrayList<LeastSquaresTerm> |
getEqualityConstraints()
Retrieves a list of all equality constraints
|
int |
getExcitations(VectorNd ex,
int idx)
Fills the supplied
ex vector with current excitation
values starting at index idx |
ListView<ExcitationComponent> |
getExciters()
Gets the list of excitators used as free variables in the inverse routine
|
ForceTargetTerm |
getForceTargetTerm()
Returns the reaction force target term, responsible for force error
|
java.util.ArrayList<LeastSquaresTerm> |
getInequalityConstraints()
Retrieves a list of all inequality constraints
|
MechSystemSolver.Integrator |
getIntegrator()
Returns the integrator used by the mech system
|
double |
getMaxExcitationJump()
Gets the governor's maximum excitation jump
|
MechSystemBase |
getMech()
Gets the mechanical system used for computing forces
|
java.util.ArrayList<MotionTargetComponent> |
getMotionSources()
Returns the set of sources
|
java.util.ArrayList<MotionTargetComponent> |
getMotionTargets()
Returns the set of targets
|
MotionTargetTerm |
getMotionTargetTerm()
Returns the motion target term, responsible for trajectory error
|
VectorNd |
getMotionTargetWeights()
Returns the set of target weights
|
MotionTargetTerm |
getMotionTerm()
Returns the "motion" term, responsible for tracking error
|
MuscleExciter |
getMuscleExciter() |
CompositeComponent.NavpanelDisplay |
getNavpanelDisplay()
Returns the DisplayMode for this component.
|
int |
getNumberLimit()
Returns the current upper limit for numbers among all sub-components in
this composite.
|
double |
getProbeDuration() |
double |
getProbeUpdateInterval() |
L2RegularizationTerm |
getRegularizationTerm() |
boolean |
getSourcesVisible() |
PointList<TargetPoint> |
getTargetPoints() |
boolean |
getTargetsVisible() |
ListView<MotionTargetComponent> |
getTargetView() |
boolean |
hierarchyContainsReferences()
Returns true if the component hierarchy formed by this component and its
descendents is closed with respect to references.
|
int |
indexOf(ModelComponent comp)
Returns the index of a specified sub-component, or -1 if that the
component is not present.
|
void |
initializeExcitations()
Initialize the controller with the current excitations in the
model, allows for non-zero starting excitations
|
static boolean |
isDebugTimestep(double t0,
double t1) |
boolean |
isEnabled()
Returns whether or not the controller is enabled
|
int |
numComponents()
Returns the number of components in this CompositeComponent.
|
int |
numExcitations()
Number of exciters controlled by this controller
|
void |
postscan(java.util.Deque<ScanToken> tokens,
CompositeComponent ancestor)
Performs any required post-scanning for this component.
|
void |
prerender(RenderList list)
Called prior to rendering to allow this object to update the internal
state required for rendering (such as by caching rendering coordinates).
|
void |
removeMotionTarget(MotionTargetComponent source) |
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer.
|
void |
setDebug(boolean b)
Puts controller into debug mode, printing messages
|
void |
setEnabled(boolean enabled)
Enable or disable the controller
|
void |
setExcitationBounds(double lower,
double upper) |
void |
setExcitationRange(ExcitationComponent ex,
double lower,
double upper) |
int |
setExcitations(VectorNd ex,
int idx)
Sets excitations provided in the
ex vector
starting at index idx . |
void |
setInitialExcitations(VectorNd init)
Sets initial excitations to the supplied values
|
void |
setMaxExcitationJump(double j)
For the governor, limits jump in excitation for all exciters to the
supplied delta
|
void |
setMech(MechSystemBase m)
Set the mech system, used by the solver to compute forces
|
void |
setMotionRenderProps(RenderProps targets,
RenderProps sources)
Sets render properties for targets and sources
|
void |
setMotionTargetWeight(MotionTargetComponent comp,
double w) |
void |
setOffsetBounds(VectorNd ex,
double lower,
double upper) |
void |
setProbeDuration(double newProbeDuration) |
void |
setProbeUpdateInterval(double h) |
void |
setSourcesVisible(boolean show)
Show or hide the sources
|
void |
setTargetPositionFilename(java.lang.String filename) |
void |
setTargetsPointRadius(double radius)
Sets targets to shows a spheres with given radius
|
void |
setTargetsVisible(boolean show)
Show or hide the targets
|
void |
updateConstraints(double t)
Updates constraints in the mech system at time t, including
contacts
|
void |
updateForces(double t,
VectorNd forces,
VectorNd excitations)
Determines the set of forces given a set of excitations.
|
void |
updateNameMap(java.lang.String newName,
java.lang.String oldName,
ModelComponent comp) |
render
copy, createRenderProps, createState, getInitialState, getInitialState, getRenderHints, getRenderProps, getSelection, getState, hasState, isSelectable, numSelectionQueriesNeeded, setInitialState, setRenderProps, setState, updateBounds
finalize, getModel, initialize, isActive, setActive, setModel, setModelFromComponent, write
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getChildren, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, hasChildren, isConnectedToHierarchy, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setSelected, updateReferences
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, setFixed, setMarked, setName, setNumber, setParent, setSelected, updateReferences
getProperty
getChildren, hasChildren
isWritable, write
getSelection, isSelectable, numSelectionQueriesNeeded
getRenderHints, render, updateBounds
createRenderProps, getRenderProps, setRenderProps
getModel, initialize, isActive, setModel
createState, getInitialState, getState, setState
public static final boolean DEFAULT_USE_INVERSE_MANAGER
public static double DEFAULT_MAX_EXCITATION_JUMP
public static final double DEFAULT_EXCITATION_REGULARIZATION_WEIGHT
public static final double DEFAULT_PROBE_DURATION
public static final double DEFAULT_PROBE_INTERVAL
public static final boolean DEFAULT_DEBUG
public static PropertyList myProps
public TrackingController(MechSystemBase m)
m
- mech system, typically your "MechModel"public TrackingController(MechSystemBase m, java.lang.String name)
m
- mech system, typically your "MechModel"name
- name to give the controllerpublic static boolean isDebugTimestep(double t0, double t1)
public PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class ModelAgentBase
public MotionTargetTerm getMotionTerm()
public L2RegularizationTerm getRegularizationTerm()
public void createProbes(RootModel root)
public void createPanel(RootModel root)
public void createProbesAndPanel(RootModel root)
public void setTargetPositionFilename(java.lang.String filename)
public void apply(double t0, double t1)
apply
in interface Controller
t0
- time at start of simulation stept1
- time at end of simulation steppublic void dispose()
dispose
in interface ModelAgent
dispose
in class ModelAgentBase
public void addForceTargetTerm(ForceTargetTerm ft)
public void addEqualityTerm(LeastSquaresTerm term)
term
- the term to addpublic void addInequalityTerm(LeastSquaresTerm term)
term
- the term to addpublic void addCostTerm(QPTerm term)
term
- the term to addpublic java.util.ArrayList<QPTerm> getCostTerms()
public java.util.ArrayList<LeastSquaresTerm> getEqualityConstraints()
public java.util.ArrayList<LeastSquaresTerm> getInequalityConstraints()
public boolean isEnabled()
public void setEnabled(boolean enabled)
public void setMech(MechSystemBase m)
public MechSystemBase getMech()
public MechSystemSolver.Integrator getIntegrator()
public void updateForces(double t, VectorNd forces, VectorNd excitations)
forces
- output from the mech systemexcitations
- input muscle excitationspublic void updateConstraints(double t)
public int setExcitations(VectorNd ex, int idx)
ex
vector
starting at index idx
.ex
- vector of excitations to useidx
- start indexex
buffer idx+numExcitations()
public ListView<ExcitationComponent> getExciters()
public void addExciter(ExcitationComponent ex)
ex
- exciter to addpublic void addExciter(ExcitationComponent ex, double gain)
ex
- exciter to addgain
- the gain applied to the exciterpublic void addExciter(double weight, ExcitationComponent ex)
weight
- regularization weight to be applied to the exciterex
- exciter to addpublic void addExciter(double weight, ExcitationComponent ex, double gain)
weight
- regularization weight to be applied to the exciterex
- exciter to addgain
- the gain applied to the exciterpublic void setExcitationRange(ExcitationComponent ex, double lower, double upper)
public MuscleExciter getMuscleExciter()
public void clearExciters()
public void setExcitationBounds(double lower, double upper)
public void setOffsetBounds(VectorNd ex, double lower, double upper)
public int numExcitations()
public int getExcitations(VectorNd ex, int idx)
ex
vector with current excitation
values starting at index idx
ex
- vector of excitations to fillidx
- starting indexidx+numExcitations()
public MotionTargetComponent addMotionTarget(MotionTargetComponent source)
source
- point or frame to trackpublic void removeMotionTarget(MotionTargetComponent source)
public MotionTargetComponent addMotionTarget(MotionTargetComponent source, double weight)
source
- point or frame to trackweight
- the weight by which to scale this target's contributionpublic L2RegularizationTerm addL2RegularizationTerm()
public L2RegularizationTerm addL2RegularizationTerm(double w)
public DampingTerm addDampingTerm()
public DampingTerm addDampingTerm(double w)
public void addRegularizationTerms(java.lang.Double w_l2norm, java.lang.Double w_damping)
public void setMaxExcitationJump(double j)
public double getMaxExcitationJump()
public void setTargetsVisible(boolean show)
public void setSourcesVisible(boolean show)
public void setTargetsPointRadius(double radius)
public boolean getSourcesVisible()
public boolean getTargetsVisible()
public void setDebug(boolean b)
public boolean getDebug()
public ListView<MotionTargetComponent> getTargetView()
public ForceTargetTerm getForceTargetTerm()
public MotionTargetTerm getMotionTargetTerm()
public java.util.ArrayList<MotionTargetComponent> getMotionTargets()
public java.util.ArrayList<MotionTargetComponent> getMotionSources()
public void setMotionRenderProps(RenderProps targets, RenderProps sources)
public VectorNd getMotionTargetWeights()
public void setMotionTargetWeight(MotionTargetComponent comp, double w)
public void initializeExcitations()
public void setInitialExcitations(VectorNd init)
public double getProbeDuration()
public void setProbeDuration(double newProbeDuration)
public double getProbeUpdateInterval()
public void setProbeUpdateInterval(double h)
public PointList<TargetPoint> getTargetPoints()
public void prerender(RenderList list)
IsRenderable
list.addIfVisible (obj);
for each of the objects in question.prerender
in interface IsRenderable
prerender
in class ControllerMonitorBase
list
- list of objects to be renderedpublic ModelComponent get(java.lang.String nameOrNumber)
get
in interface CompositeComponent
nameOrNumber
- name or number of the sub-componentpublic ModelComponent get(int idx)
get
in interface CompositeComponent
get
in interface IndexedComponentList
idx
- index of the sub-componentpublic ModelComponent getByNumber(int num)
getByNumber
in interface CompositeComponent
num
- number of the sub-componentpublic int numComponents()
numComponents
in interface CompositeComponent
numComponents
in interface IndexedComponentList
public int indexOf(ModelComponent comp)
indexOf
in interface CompositeComponent
comp
- component whose index is requestedpublic ModelComponent findComponent(java.lang.String path)
findComponent
in interface CompositeComponent
path
- path leading to the sub-componentpublic int getNumberLimit()
getNumberLimit
in interface CompositeComponent
public CompositeComponent.NavpanelDisplay getNavpanelDisplay()
getNavpanelDisplay
in interface CompositeComponent
public void componentChanged(ComponentChangeEvent e)
This method should propagate the notification up the component hierarchy
by calling notifyParentOfChange
.
componentChanged
in interface ComponentChangeListener
componentChanged
in interface CompositeComponent
e
- optional argument giving specific information about the changepublic void updateNameMap(java.lang.String newName, java.lang.String oldName, ModelComponent comp)
updateNameMap
in interface CompositeComponent
public boolean hierarchyContainsReferences()
In particular, this means that one does not need to search outside the hierarchy when looking for dependencies.
hierarchyContainsReferences
in interface CompositeComponent
public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
ModelComponentBase
write
.scan
in interface ModelComponent
scan
in interface Scannable
scan
in class ModelComponentBase
rtok
- Tokenizer from which to scan the elementref
- optional reference object which can be used for resolving references to
other objectsjava.io.IOException
- if an I/O or formatting error occuredpublic void postscan(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor) throws java.io.IOException
ModelComponent
scan()
method and stored in the token queue.
The most common use of this method is to resolve the paths
of component references, which may not have been created
at the time of the initial scan()
call.postscan
in interface ModelComponent
postscan
in class ModelComponentBase
tokens
- token information that was stored during
scan()
.ancestor
- ancestor component with respect to which
reference component paths are defined.java.io.IOException
- if an error is encountered (such as a reference to a
non-existent component)public MotionForceInverseData getData()