maspack.contact
Interface ContactSolver

All Known Implementing Classes:
FastContactSolver, TradContactSolver

public interface ContactSolver

Functional interface for a multi-point contact solver.


Field Summary
static double AUTO_EPSILON
          Indicates that numeric tolerances should be computed automatially for each solution.
static int CYCLING_DETECTED
          Return code indicating that the solver was unable to find a contact solution because Lemke's algorithm started to cycle.
static int NUMERIC_ERROR
          Return code indicating that the solver was unable to find a contact solution because Lemke's algorithm encountered a numeric error.
static int SHOW_BASIS
          Debugging flag requesting that the current basis be displayed for each pivot operation.
static int SHOW_LEXICO_MINRATIO
          Debugging flag requesting display of the numbers and pivot candidates involved in the full minimum ratio test for each pivot operation, including the breaking of ties.
static int SHOW_MINRATIO
          Debugging flag requesting display of the numbers and pivot candidates involved in the minimum ratio test for each pivot operation.
static int SOLVED
          Return code indicating that a contact solution was successfully calculated.
static int UNBOUNDED_RAY
          Return code indicating that the solver was unable to find a contact solution because Lemke's algorithm terminated with an unbounded ray.
 
Method Summary
 boolean getActivityReportingEnabled()
          Experimental method.
 boolean getBasisPresetEnabled()
          Experimental method.
 java.lang.String getBasisString()
          Returns a string describing the basis associated with the most recently computed solution.
 boolean getCoriolisEnabled()
          Returns true if coriolis forces are included in second order motion calculations.
 double getEpsilon()
          Returns the numeric tolerance that was used for the most recent contact solution.
 boolean getFrictionEnabled()
          Returns true if friction computation is enabled for this solver.
 double getMinimumSpeed()
          Experimental method.
 int getNumFrictionDirections()
          Sets the number of friction directions used by this solver.
 int getPivotCount()
          Returns the number of pivots that the solver has performed.
 boolean getRestitutionEnabled()
          Returns true if restitution computation is enabled for this solver.
 double getRestitutionThreshold()
          Gets the restitution threshold for this solver.
 int getSolutionOrder()
          Returns the order used to compute contact solutions.
 double getStabilizingDistance()
          Returns the currently stabilizing distance.
 void resetPivotCount()
          Sets the solver pivot count to 0.
 void setActivityReportingEnabled(boolean enable)
          Experimental method.
 void setBasisPresetEnabled(boolean enable)
          Experimental method.
 void setCoriolisEnabled(boolean enable)
          Enables the inclusion of coriolis forces for second order motion calculations.
 void setDebug(int flag)
          Enables the printing of debug information.
 void setEpsilon(double eps)
          Sets the numeric tolerance that should be used for contact solutions.
 void setFrictionEnabled(boolean enable)
          Enables/disables friction computation for this solver.
 void setMinimumSpeed(double minSpeed)
          Experimental method.
 void setNumFrictionDirections(int numdirs)
          Sets the number of friction directions to be used by this solver (i.e., the number of sides in the polyhedral approximation to the friction cone).
 void setRestitutionEnabled(boolean enable)
          Enables/disables restitution computation for this solver.
 void setRestitutionThreshold(double threshold)
          Sets the restitution threshold for this solver.
 void setSolutionOrder(int order)
          Sets the order used to compute contact solutions.
 void setStabilizingDistance(double dist)
          Sets the solver's stabilizing distance.
 int solve(Twist[] newVels, Contact[] contacts, int ncontacts, RigidTransform3d[] XBodiesToWorld, Twist[] vels, SpatialInertia[] inertias, Wrench[] appliedForces, double timeStep)
          Solves a multi-point contact problem for multiple rigid bodies.
 int solve(Twist newVel, Contact[] contacts, int ncontacts, RigidTransform3d XBodyToWorld, Twist vel, SpatialInertia inertia, Wrench appliedForce, double timeStep)
          Solves a multi-point contact problem for a single rigid body.
 

Field Detail

SOLVED

public static final int SOLVED
Return code indicating that a contact solution was successfully calculated.

See Also:
Constant Field Values

UNBOUNDED_RAY

public static final int UNBOUNDED_RAY
Return code indicating that the solver was unable to find a contact solution because Lemke's algorithm terminated with an unbounded ray.

See Also:
Constant Field Values

CYCLING_DETECTED

public static final int CYCLING_DETECTED
Return code indicating that the solver was unable to find a contact solution because Lemke's algorithm started to cycle.

See Also:
Constant Field Values

AUTO_EPSILON

public static final double AUTO_EPSILON
Indicates that numeric tolerances should be computed automatially for each solution.

See Also:
Constant Field Values

SHOW_BASIS

public static final int SHOW_BASIS
Debugging flag requesting that the current basis be displayed for each pivot operation.

See Also:
Constant Field Values

SHOW_MINRATIO

public static final int SHOW_MINRATIO
Debugging flag requesting display of the numbers and pivot candidates involved in the minimum ratio test for each pivot operation.

See Also:
Constant Field Values

SHOW_LEXICO_MINRATIO

public static final int SHOW_LEXICO_MINRATIO
Debugging flag requesting display of the numbers and pivot candidates involved in the full minimum ratio test for each pivot operation, including the breaking of ties.

See Also:
Constant Field Values

NUMERIC_ERROR

public static final int NUMERIC_ERROR
Return code indicating that the solver was unable to find a contact solution because Lemke's algorithm encountered a numeric error.

See Also:
Constant Field Values
Method Detail

getEpsilon

public double getEpsilon()
Returns the numeric tolerance that was used for the most recent contact solution.

Returns:
most recently used value of epsilon
See Also:
setEpsilon(double)

setEpsilon

public void setEpsilon(double eps)
Sets the numeric tolerance that should be used for contact solutions. A value of AUTO_EPSILON indicates that the tolerance should be computed automatically whenever a solution is computed, after which it may be queried using getEpsilon.

Parameters:
eps - numeric tolerance

setDebug

public void setDebug(int flag)
Enables the printing of debug information.

Parameters:
flag - debugging flag. Should be one of SHOW_BASIS, SHOW_MINRATIO, or SHOW_LEXICO_MINRATIO.

getPivotCount

public int getPivotCount()
Returns the number of pivots that the solver has performed. This count is cumulative across solution calls.

Returns:
solver pivot count
See Also:
resetPivotCount()

resetPivotCount

public void resetPivotCount()
Sets the solver pivot count to 0.

See Also:
getPivotCount()

getSolutionOrder

public int getSolutionOrder()
Returns the order used to compute contact solutions.

Returns:
solution order
See Also:
setSolutionOrder(int)

setSolutionOrder

public void setSolutionOrder(int order)
Sets the order used to compute contact solutions. This should be either 1 or 2, where 1 corresponds to first order physics (force proportional to velocity), and 2 corresponds to the usual second order physics (force proportional to acceleration).

Parameters:
order - desired solution order (1 or 2)
See Also:
getSolutionOrder()

getStabilizingDistance

public double getStabilizingDistance()
Returns the currently stabilizing distance.

Returns:
stabilizing distance
See Also:
setStabilizingDistance(double)

setStabilizingDistance

public void setStabilizingDistance(double dist)
Sets the solver's stabilizing distance. By default, this quantity is zero, but if it is set to a positive value, and the solver is performing second order motions, then it will try to apply appropriate impulses to the bodies to maintain a separation of dist units at each of the contact points.

Parameters:
dist - stabilizing distance

solve

public int solve(Twist[] newVels,
                 Contact[] contacts,
                 int ncontacts,
                 RigidTransform3d[] XBodiesToWorld,
                 Twist[] vels,
                 SpatialInertia[] inertias,
                 Wrench[] appliedForces,
                 double timeStep)
Solves a multi-point contact problem for multiple rigid bodies. Information about each contact point should be supplied in the contact array.

Information for each contact includes indices identifiying the two bodies associated with it. These indices should correspond to the indices the body with respect to newVels, XBodiesToWorld, etc. For contacts between a body and a fixed object, the first body index should reflect the body in question, and the second body index should be set to -1.

Parameters:
newVels - returns the updated velocities calculated for each rigid body, in body coordinates
contacts - array of information about each contact
ncontacts - number of contacts
XBodiesToWorld - spatial body-to-world transform for each rigid body
vels - initial spatial velocity for each rigid body, in body coordinates (only used if the order of the solution is 2)
inertias - spatial inertia for each rigid body, in body coordinates
appliedForces - external forces applied to each rigid body, in body coordinates
timeStep - time step size associated with the motion (only applicable if the order of the solution is 2)

solve

public int solve(Twist newVel,
                 Contact[] contacts,
                 int ncontacts,
                 RigidTransform3d XBodyToWorld,
                 Twist vel,
                 SpatialInertia inertia,
                 Wrench appliedForce,
                 double timeStep)
Solves a multi-point contact problem for a single rigid body. Information about each contact should be supplied in the contacts array. For each contact, the first body index is assumed to correspond to the rigid body in question and should be set to 0, and the second body index is assumed to correspond to a fixed object and should be set to -1.

Parameters:
newVel - returns the updated velocity calculated in body coordinates
contacts - array of information about each contact
ncontacts - number of contacts
XBodyToWorld - spatial body-to-world transform for the rigid body
vel - initial spatial velocity the rigid body, in body coordinates (only used if the order of the solution is 2)
inertia - spatial inertia for the rigid body, in body coordinates
appliedForce - external forces applied to the rigid body, in body coordinates
timeStep - time step associated with the motion (only applicable if the order of the solution is 2)

setFrictionEnabled

public void setFrictionEnabled(boolean enable)
Enables/disables friction computation for this solver. Friction computation is enabled by default.

Parameters:
enable - enables friction computation if true
See Also:
getFrictionEnabled()

getFrictionEnabled

public boolean getFrictionEnabled()
Returns true if friction computation is enabled for this solver.

Returns:
true if friction computation is enabled
See Also:
setFrictionEnabled(boolean)

setRestitutionEnabled

public void setRestitutionEnabled(boolean enable)
Enables/disables restitution computation for this solver. Resitution is only computed for second order solutions, and involves computing a restoring velocity at each contact, as determined by the restitution coefficient specified for that contact.

Parameters:
enable - enables restitution computation if true
See Also:
getRestitutionEnabled()

getRestitutionEnabled

public boolean getRestitutionEnabled()
Returns true if restitution computation is enabled for this solver.

Returns:
true if restitution computation is enabled
See Also:
setRestitutionEnabled(boolean)

setRestitutionThreshold

public void setRestitutionThreshold(double threshold)
Sets the restitution threshold for this solver. This is the minimum speed along a contact normal below which no restitution is calculated (assuming restitution is enabled).

Parameters:
threshold - minimum normal speed
See Also:
setRestitutionEnabled(boolean)

getRestitutionThreshold

public double getRestitutionThreshold()
Gets the restitution threshold for this solver.

Returns:
restitution threshold
See Also:
setRestitutionThreshold(double)

setNumFrictionDirections

public void setNumFrictionDirections(int numdirs)
Sets the number of friction directions to be used by this solver (i.e., the number of sides in the polyhedral approximation to the friction cone). The default is 4.

Parameters:
numdirs - number of friction directions
See Also:
getNumFrictionDirections()

getNumFrictionDirections

public int getNumFrictionDirections()
Sets the number of friction directions used by this solver.

Returns:
number of friction directions
See Also:
setNumFrictionDirections(int)

setBasisPresetEnabled

public void setBasisPresetEnabled(boolean enable)
Experimental method.


getBasisPresetEnabled

public boolean getBasisPresetEnabled()
Experimental method.


getActivityReportingEnabled

public boolean getActivityReportingEnabled()
Experimental method.


setActivityReportingEnabled

public void setActivityReportingEnabled(boolean enable)
Experimental method.


getCoriolisEnabled

public boolean getCoriolisEnabled()
Returns true if coriolis forces are included in second order motion calculations.

Returns:
true if coriolis force calculation is enabled

setCoriolisEnabled

public void setCoriolisEnabled(boolean enable)
Enables the inclusion of coriolis forces for second order motion calculations.

Parameters:
enable - if true, enables coriolis force calculation

setMinimumSpeed

public void setMinimumSpeed(double minSpeed)
Experimental method.


getMinimumSpeed

public double getMinimumSpeed()
Experimental method.


getBasisString

public java.lang.String getBasisString()
Returns a string describing the basis associated with the most recently computed solution.

Returns:
string showing most recently calculated basis.