Solve for the coordinates (degrees-of-freedom) of the model that satisfy the set of constraints imposed on the model as well as set of desired coordinate values. More...
#include <AssemblySolver.h>
Public Member Functions | |
virtual | ~AssemblySolver () |
AssemblySolver (const Model &model, SimTK::Array_< CoordinateReference > &coordinateReferences, double constraintWeight=SimTK::Infinity) | |
Construct an Assembly solver with the coordinate references as the goal of the assembly and (optional)constraint weight. | |
void | setAccuracy (double accuracy) |
Set the unitless accuracy of the assembly solution, which is dictates to how many significant digits the solution should be resolved to. | |
void | setConstraintWeight (double weight) |
Set the relative weighting for constraints. | |
const SimTK::Array_ < CoordinateReference > & | getCoordinateReferences () const |
Specify which coordinates to match, each with a desired value and a relative weighting. | |
void | updateCoordinateReference (const std::string &coordName, double value, double weight=1.0) |
Once a set of coordinates has been specified its reference value and weight can be updated directly. | |
virtual void | assemble (SimTK::State &s) |
Assemble a model configuration that meets the assembly conditions (desired values and constraints) starting from an initial state that does not have to satisfy the constraints. | |
virtual void | track (SimTK::State &s) |
Obtain a model configuration that meets the assembly conditions (desired values and constraints) given a state that satisfies or is close to satisfying the constraints. | |
Protected Member Functions | |
virtual void | setupGoals (SimTK::State &s) |
Internal method to convert the CoordinateReferences into goals of the assembly solver. | |
virtual void | updateGoals (const SimTK::State &s) |
Internal method to update the time, reference values and/or their weights that define the goals, based on the passed in state. | |
Protected Attributes | |
double | _accuracy |
double | _constraintWeight |
SimTK::Array_ < CoordinateReference > & | _coordinateReferences |
SimTK::Assembler * | _assembler |
SimTK::Array_< SimTK::QValue * > | _coordinateAssemblyConditions |
Solve for the coordinates (degrees-of-freedom) of the model that satisfy the set of constraints imposed on the model as well as set of desired coordinate values.
The AssembleSolver provides the option to convert the problem to an approximate one where the constraint violations are treated as penalties to to be minimized rather than strictly enforced. This can speed up the time solution and can be used to seed the constrained problem near to a solution.
The assembly objective: min A = sum(Wq_i*(q_i-qd_i)^2)) + [Wc*sum(c_err)^2] iff Wc == Infinity, second term is not included, but A is subject to the constraint equations: G(q)-Go = 0
When the model (and the number of goals) is guaranteed not to change and the the initial state is close to the assembly solution (from initial assembly(), then track() is a efficient method for updating the configuration to track the small change to the desired coorindate value.
See SimTK::Assembler for more algorithmic details of the underlying solver.
OpenSim::AssemblySolver::~AssemblySolver | ( | ) | [virtual] |
OpenSim::AssemblySolver::AssemblySolver | ( | const Model & | model, | |
SimTK::Array_< CoordinateReference > & | coordinateReferences, | |||
double | constraintWeight = SimTK::Infinity | |||
) |
Construct an Assembly solver with the coordinate references as the goal of the assembly and (optional)constraint weight.
An implementation of the AssemblySolver.
Defual is infitinet constraint weighting (i.e. rigidly enforced) during assembly.
model | to assemble |
void OpenSim::AssemblySolver::assemble | ( | SimTK::State & | s | ) | [virtual] |
Assemble a model configuration that meets the assembly conditions (desired values and constraints) starting from an initial state that does not have to satisfy the constraints.
Assemble the model such that it satisfies configuration goals and constraints The input state is used to initialize the assembly and then is updated to return the resulting assembled configuration.
const SimTK::Array_<CoordinateReference>& OpenSim::AssemblySolver::getCoordinateReferences | ( | ) | const [inline] |
Specify which coordinates to match, each with a desired value and a relative weighting.
void OpenSim::AssemblySolver::setAccuracy | ( | double | accuracy | ) | [inline] |
Set the unitless accuracy of the assembly solution, which is dictates to how many significant digits the solution should be resolved to.
void OpenSim::AssemblySolver::setConstraintWeight | ( | double | weight | ) | [inline] |
Set the relative weighting for constraints.
Use Infinity to identify the strict enforcement of constraints, otherwise any positive weighting will append the constraint errors to the assembly cost which the solver will minimize.
void OpenSim::AssemblySolver::setupGoals | ( | SimTK::State & | s | ) | [protected, virtual] |
Internal method to convert the CoordinateReferences into goals of the assembly solver.
Subclasses, can add and override to include other goals such as point of interest matching (Marker tracking). This method is automatically called by assemble.
Subclasses, override and call base to include other goals such as point of interest matching (Marker tracking). This method is automatically called by assemble.
Reimplemented in OpenSim::InverseKinematicsSolver.
void OpenSim::AssemblySolver::track | ( | SimTK::State & | s | ) | [virtual] |
Obtain a model configuration that meets the assembly conditions (desired values and constraints) given a state that satisfies or is close to satisfying the constraints.
Note there can be no change in the number of constrainst or desired coordinates. Desired coordinate values can and should be updated between repeated calls to track a desired trajectory of coordinate values.
void OpenSim::AssemblySolver::updateCoordinateReference | ( | const std::string & | coordName, | |
double | value, | |||
double | weight = 1.0 | |||
) |
Once a set of coordinates has been specified its reference value and weight can be updated directly.
Once a set of coordinates has been specified its target value can be updated directly.
void OpenSim::AssemblySolver::updateGoals | ( | const SimTK::State & | s | ) | [protected, virtual] |
Internal method to update the time, reference values and/or their weights that define the goals, based on the passed in state.
This method is called at the end of setupGoals() and beginning of track()
Reimplemented in OpenSim::InverseKinematicsSolver.
double OpenSim::AssemblySolver::_accuracy [protected] |
SimTK::Assembler* OpenSim::AssemblySolver::_assembler [protected] |
double OpenSim::AssemblySolver::_constraintWeight [protected] |
SimTK::Array_<SimTK::QValue*> OpenSim::AssemblySolver::_coordinateAssemblyConditions [protected] |
SimTK::Array_<CoordinateReference>& OpenSim::AssemblySolver::_coordinateReferences [protected] |