artisynth.core.inverse
Class MotionTargetTerm

java.lang.Object
  extended by artisynth.core.inverse.LeastSquaresTermBase
      extended by artisynth.core.inverse.MotionTargetTerm
All Implemented Interfaces:
LeastSquaresTerm, HasProperties

public class MotionTargetTerm
extends LeastSquaresTermBase

Tracking error term for the TrackingController

Author:
Ian Stavness, with modifications by Antonio Sanchez

Field Summary
static double DEFAULT_K
           
static boolean DEFAULT_NORMALIZE_H
           
static PropertyList myProps
           
 
Fields inherited from class artisynth.core.inverse.LeastSquaresTermBase
defaultWeight
 
Constructor Summary
MotionTargetTerm(TrackingController trackingController)
           
 
Method Summary
 MotionTargetComponent addTarget(MotionTargetComponent target)
          Adds a target to track
 MotionTargetComponent addTarget(MotionTargetComponent source, double weight)
          Adds a target to track
 void clearTargets()
          Removes targets
 void dispose()
           
 PropertyList getAllPropertyInfo()
          Returns a list giving static information about all properties exported by this object.
 VectorNd getCurrentVel()
           
 boolean getNormalizeH()
          Returns whether or not we're normalizing this term's contribution to H and b.
 RenderProps getSourceRenderProps()
          Render props for the sources
 java.util.ArrayList<MotionTargetComponent> getSources()
          Returns list of source points/frames that are part of the model that will move to the targets
 RenderProps getTargetRenderProps()
          Render props for targets
 java.util.ArrayList<MotionTargetComponent> getTargets()
          Returns list of target points/frames
 int getTargetSize()
          Returns complete size of velocity vector (not number of targets)
 double getTargetVelocityFactor()
          Returns the velocity factor.
 int getTargetVelSize()
           
 VectorNd getTargetWeights()
          Returns target weights, one per target point.
 void getTargetWeights(VectorNd out)
          Gets weights for targets.
 int getTerm(MatrixNd H, VectorNd b, int rowoff, double t0, double t1)
          Fills H and b with this motion term
 SparseBlockMatrix getVelocityJacobian()
          Returns the velocity Jacobian, creates if null
 void initSourceRenderProps()
           
 void initTargetRenderProps()
           
 boolean isEnabled()
           
 void setEnabled(boolean enabled)
           
 void setNormalizeH(boolean set)
          Sets whether or not to normalize the contribution to H and b by the Frobenius norm of this term's H block.
 void setSourceRenderProps(RenderProps rend)
          Sets render props for sources
 void setTargetRenderProps(RenderProps rend)
          Sets render props for the target points/frames
 void setTargetVelocityFactor(double k)
          Sets a scaling factor to use when computing target velocities.
 void setTargetWeights(VectorNd wgts)
          Sets weights for targets.
 void setWeight(double w)
          Weight used to scale the contribution of this term in the quadratic optimization problem
 void updateTarget(double t0, double t1)
           
 
Methods inherited from class artisynth.core.inverse.LeastSquaresTermBase
getProperty, getWeight
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_K

public static double DEFAULT_K

DEFAULT_NORMALIZE_H

public static boolean DEFAULT_NORMALIZE_H

myProps

public static PropertyList myProps
Constructor Detail

MotionTargetTerm

public MotionTargetTerm(TrackingController trackingController)
Method Detail

getAllPropertyInfo

public PropertyList getAllPropertyInfo()
Description copied from interface: HasProperties
Returns a list giving static information about all properties exported by this object.

Specified by:
getAllPropertyInfo in interface HasProperties
Overrides:
getAllPropertyInfo in class LeastSquaresTermBase
Returns:
static information for all exported properties

updateTarget

public void updateTarget(double t0,
                         double t1)

dispose

public void dispose()

isEnabled

public boolean isEnabled()

setEnabled

public void setEnabled(boolean enabled)

getCurrentVel

public VectorNd getCurrentVel()

initTargetRenderProps

public void initTargetRenderProps()

initSourceRenderProps

public void initSourceRenderProps()

addTarget

public MotionTargetComponent addTarget(MotionTargetComponent source,
                                       double weight)
Adds a target to track

Parameters:
source - point or frame on the model you wish to drive to a target position
weight - used in error tracking
Returns:
the created point or frame that will be used as a target

addTarget

public MotionTargetComponent addTarget(MotionTargetComponent target)
Adds a target to track

Parameters:
target - point or frame on the model you wish to drive to a target position
Returns:
the created point or frame that will be used as a target

clearTargets

public void clearTargets()
Removes targets


getTargets

public java.util.ArrayList<MotionTargetComponent> getTargets()
Returns list of target points/frames


getSources

public java.util.ArrayList<MotionTargetComponent> getSources()
Returns list of source points/frames that are part of the model that will move to the targets


getTargetVelSize

public int getTargetVelSize()

getVelocityJacobian

public SparseBlockMatrix getVelocityJacobian()
Returns the velocity Jacobian, creates if null


getTargetSize

public int getTargetSize()
Returns complete size of velocity vector (not number of targets)


getTerm

public int getTerm(MatrixNd H,
                   VectorNd b,
                   int rowoff,
                   double t0,
                   double t1)
Fills H and b with this motion term

Parameters:
H - LHS matrix to fill
b - RHS vector to fill
rowoff - row offset to start filling term
t0 - starting time of time step
t1 - ending time of time step
Returns:
next row offset

setWeight

public void setWeight(double w)
Weight used to scale the contribution of this term in the quadratic optimization problem

Specified by:
setWeight in interface LeastSquaresTerm
Overrides:
setWeight in class LeastSquaresTermBase

setTargetWeights

public void setTargetWeights(VectorNd wgts)
Sets weights for targets. This allows you to weight more heavily the points you deem to be more important. If wgts.size() equals the number of targets, each target will use a single weight. If wgts.size() equals the full size of the target velocity vector, then this directly scales the rows of H (allows you to scale x,y,z components of velocity separately).

Parameters:
wgts - weights vector

getTargetWeights

public void getTargetWeights(VectorNd out)
Gets weights for targets. If wgts.size() equals the number of targets, returns the set of single weights used per target. If wgts.size() equals the full size of the target velocity vector, then returns the direct scaling vector.

Parameters:
out - weights vector

getTargetRenderProps

public RenderProps getTargetRenderProps()
Render props for targets


getTargetWeights

public VectorNd getTargetWeights()
Returns target weights, one per target point. Used by properties so can be get/set through interface


setTargetRenderProps

public void setTargetRenderProps(RenderProps rend)
Sets render props for the target points/frames


getSourceRenderProps

public RenderProps getSourceRenderProps()
Render props for the sources


setSourceRenderProps

public void setSourceRenderProps(RenderProps rend)
Sets render props for sources


setTargetVelocityFactor

public void setTargetVelocityFactor(double k)
Sets a scaling factor to use when computing target velocities. By default, this factor is 1, which means we compute the velocity required to reach the target in a single time step. However, in some models, this leads to overshoots and unstable oscillations. The velocity factor k can be used to scale down the velocity so we only reach a fraction of the distance by the next time step.


getTargetVelocityFactor

public double getTargetVelocityFactor()
Returns the velocity factor. See setTargetVelocityFactor(double).

Returns:
velocity factor

setNormalizeH

public void setNormalizeH(boolean set)
Sets whether or not to normalize the contribution to H and b by the Frobenius norm of this term's H block. This is for scaling purposes when damping is important. If set to false, then the damping term's scale will depend on the time and spatial scales. However, if set to true, we will likely scale this term differently every time step.

Parameters:
set -

getNormalizeH

public boolean getNormalizeH()
Returns whether or not we're normalizing this term's contribution to H and b. See setNormalizeH(boolean)

Returns:
true if we're normalizing this term's contribution to H and b