Computed Muscle Control (CMC) is an optimization-based control technique designed specifically for controlling dynamic models that are actuated by redundant sets of actuators whose force-generating properties may be nonlinear and goverend by differential equaitions (as so have delays in force production). More...
#include <CMC.h>
Public Member Functions | |
CMC () | |
Default Constructor. | |
CMC (Model *aModel, CMC_TaskSet *aTaskSet) | |
Contructor. | |
CMC (const CMC &aCmc) | |
Copy constructor. | |
CMC (const std::string &aFileName, bool aUpdateFromXMLNode=true) | |
Constructor from an XML Document. | |
virtual | ~CMC () |
Destructor. | |
void | setNull () |
Set NULL values for all member variables. | |
CMC & | operator= (const CMC &aCmc) |
Assignment operator. | |
void | copyData (const CMC &aCmc) |
Copy the member variables of the specified controller. | |
virtual Object * | copy () const |
Copy this CMC controller and return a pointer to the copy. | |
Array< int > * | getParameterList () |
Get the list of parameters in the control set that the controller is using to control the simulation. | |
SimTK::Optimizer * | getOptimizer () const |
Get the optimizer. | |
OptimizationTarget * | setOptimizationTarget (OptimizationTarget *aTarget, SimTK::Optimizer *aOptimizer) |
Set the optimization target for this controller. | |
OptimizationTarget * | getOptimizationTarget () const |
Get the optimization target for this controller. | |
void | setDT (double aDT) |
Set the requested integrator time step size. | |
double | getDT () const |
Get the requested integrator time step size. | |
void | setTargetTime (double aTime) |
Set the target time (or final time) for the controller. | |
double | getTargetTime () const |
Get the target time. | |
void | setTargetDT (double aDT) |
Set the target time step size. | |
double | getTargetDT () const |
Get the target time step size. | |
void | setCheckTargetTime (bool aTrueFalse) |
Set whether or not to check the target time. | |
bool | getCheckTargetTime () const |
Get whether or not to check the target time. | |
void | setActuatorForcePredictor (VectorFunctionForActuators *aPredictor) |
Set the predictor for actuator forces. | |
VectorFunctionForActuators * | getActuatorForcePredictor () |
Get the predictor for actuator forces. | |
Storage * | getPositionErrorStorage () const |
Get the storage object for position errors. | |
Storage * | getVelocityErrorStorage () const |
Get the storage object for velocity errors. | |
Storage * | getStressTermWeightStorage () const |
Get the storage object for stress term weights. | |
bool | getUseReflexes () const |
void | setUseVerbosePrinting (bool aTrueFalse) |
Set whether or not to use verbose printing. | |
bool | getUseVerbosePrinting () const |
void | setUseCurvatureFilter (bool aTrueFalse) |
Set whether or not a curvature filter should be applied to the controls. | |
bool | getUseCurvatureFilter () const |
Get whether or not a curvature filter should be applied to the controls. | |
const CMC_TaskSet & | getTaskSet () const |
CMC_TaskSet & | updTaskSet () const |
ControlSet & | updControlSet () |
void | restoreConfiguration (SimTK::State &s, const SimTK::State &initialState) |
A utility method used to restore the coordinates and speeds to initial values. | |
void | obtainActuatorEquilibrium (SimTK::State &s, double tiReal, double dtReal, const Array< double > &x, bool hold) |
Obtain actuator equilibrium. | |
virtual void | computeInitialStates (SimTK::State &s, double &rTI) |
Compute the initial states for a simulation. | |
virtual void | computeControls (SimTK::State &s, ControlSet &rX) |
Compute the controls for a simulation. | |
virtual double | computeControl (const SimTK::State &s, int index) const |
Note that this method is "pure virtual", which means that the Controller class does not implement it, and that subclasses must implement it. | |
virtual void | setActuators (Set< Actuator > &actuators) |
virtual void | setup (Model &model) |
virtual void | setupProperties () |
Connect properties to local pointers. | |
virtual void | setupSystem (SimTK::MultibodySystem &system) |
virtual void | initState (SimTK::State &s) |
Static Public Member Functions | |
static void | FilterControls (const SimTK::State &s, const ControlSet &aControlSet, double aDT, OpenSim::Array< double > &rControls, bool aVerbosePrinting) |
Filter the controls. | |
Protected Attributes | |
SimTK::Optimizer * | _optimizer |
Optimizer. | |
OptimizationTarget * | _target |
Optimization target for computing the controls. | |
double | _dt |
Next integration step size that is to be taken by the integrator. | |
double | _lastDT |
Last integration step size that was taken before a new integration step size was set in order to step exactly to the target time. | |
bool | _restoreDT |
Flag indicating when the last integration step size should be restored. | |
double | _tf |
The target time is the time in the future (in normalized units) for which the controls have been calculated. | |
double | _targetDT |
The step size used to generate a new target time, once the old target time has been reached. | |
bool | _checkTargetTime |
Whether or not to check the target time. | |
Storage * | _pErrStore |
Storage object for the position errors. | |
Storage * | _vErrStore |
Storage object for the velocity errors. | |
Storage * | _stressTermWeightStore |
Storage object for the stress term weight. | |
ControlSet | _controlSet |
Array< int > | _paramList |
List of parameters in the control set that are serving as the controls in the optimization problem. | |
bool | _verbose |
Flag to indicate whether to use verbose printing. | |
bool | _useCurvatureFilter |
CMC_TaskSet * | _taskSet |
VectorFunctionForActuators * | _predictor |
Vector function for estimating actuator forces over a specified time interval. | |
Array< double > | _f |
Array of actuator forces for achieving the desired accelerations. |
Computed Muscle Control (CMC) is an optimization-based control technique designed specifically for controlling dynamic models that are actuated by redundant sets of actuators whose force-generating properties may be nonlinear and goverend by differential equaitions (as so have delays in force production).
The cannonical example of such a dynamic system is the musculoskeletal system (human or animal), hence the name Computed Muscle Control.
For a complete description of the CMC algorithm consult the following references:
Anderson FC (2004). Method and system for dynamically filtering the motion of articulated bodies. Realistic Dynamics, Inc., US Patent No. 6,750,866 (Issue date: June 15, 2004).
DG, Anderson FC (2006). Using computed muscle control to generate forward dynamic simulations of human walking from experimental data. J Biomech 39: 1107-15.
DG, Anderson FC, Delp SL (2003). Generating forward dynamic simulations of movement using computed muscle control. J Biomech 36: 321-8.
CMC::CMC | ( | ) |
Default Constructor.
CMC::CMC | ( | Model * | aModel, | |
CMC_TaskSet * | aTaskSet | |||
) |
CMC::CMC | ( | const CMC & | aCmc | ) |
Copy constructor.
CMC::CMC | ( | const std::string & | aFileName, | |
bool | aUpdateFromXMLNode = true | |||
) |
Constructor from an XML Document.
CMC::~CMC | ( | ) | [virtual] |
Destructor.
double CMC::computeControl | ( | const SimTK::State & | s, | |
int | index | |||
) | const [virtual] |
Note that this method is "pure virtual", which means that the Controller class does not implement it, and that subclasses must implement it.
s | system state | |
rControlSet | Control set used for the simulation. This method alters the control set in order to control the simulation. |
Implements OpenSim::TrackingController.
void CMC::computeControls | ( | SimTK::State & | s, | |
ControlSet & | controlSet | |||
) | [virtual] |
Compute the controls for a simulation.
The caller should send in an initial guess.
s | state of system model | |
rDT | Integration time step in normalized time that is to be taken next. Note that the controller can change the value of rDT. | |
aT | Current time in normalized time. | |
rControlSet | Control set used for the simulation. This method alters the control set in order to control the simulation. |
void CMC::computeInitialStates | ( | SimTK::State & | s, | |
double & | rTI | |||
) | [virtual] |
Compute the initial states for a simulation.
The caller should send in an initial guess. The Qs and Us are set based on the desired trajectories. The actuator states are set by sovling for a desired set of actuator forces, and then letting the states come to equilibrium for those forces.
rTI | Initial time in normalized time. Note this is changed to the time corresponding to the new initial states on return. | |
s | Initial states. |
Object * CMC::copy | ( | ) | const [virtual] |
Copy this CMC controller and return a pointer to the copy.
The copy constructor for this class is used. This method is called when a description of this controller is read in from an XML file.
Reimplemented from OpenSim::Object.
void CMC::copyData | ( | const CMC & | aController | ) |
Copy the member variables of the specified controller.
This method is called by the copy constructor of the Controller class.
aController | The controller whose data is to be copied. |
Reimplemented from OpenSim::TrackingController.
void CMC::FilterControls | ( | const SimTK::State & | s, | |
const ControlSet & | aControlSet, | |||
double | aDT, | |||
OpenSim::Array< double > & | rControls, | |||
bool | aVerbosePrinting | |||
) | [static] |
Filter the controls.
This method was introduced as a means of attempting to reduce the sizes of residuals. Unfortunately, the approach was generally unsuccessful because the desired accelerations were not achieved.
VectorFunctionForActuators * CMC::getActuatorForcePredictor | ( | ) |
Get the predictor for actuator forces.
bool CMC::getCheckTargetTime | ( | ) | const |
Get whether or not to check the target time.
double CMC::getDT | ( | ) | const |
Get the requested integrator time step size.
OptimizationTarget * CMC::getOptimizationTarget | ( | ) | const |
Get the optimization target for this controller.
SimTK::Optimizer * CMC::getOptimizer | ( | ) | const |
Get the optimizer.
OpenSim::Array< int > * CMC::getParameterList | ( | ) |
Get the list of parameters in the control set that the controller is using to control the simulation.
Storage * CMC::getPositionErrorStorage | ( | ) | const |
Get the storage object for position errors.
Storage * CMC::getStressTermWeightStorage | ( | ) | const |
Get the storage object for stress term weights.
double CMC::getTargetDT | ( | ) | const |
Get the target time step size.
The target time step size is the step size used to compute a new target time, once the former target time has been reached by the integrator.
double CMC::getTargetTime | ( | ) | const |
Get the target time.
The target time is the time in the future for which the controls have been calculated. If an integrator is taking time steps prior to the target time, the controls should not have to be computed again.
const CMC_TaskSet & CMC::getTaskSet | ( | ) | const |
bool CMC::getUseCurvatureFilter | ( | ) | const |
Get whether or not a curvature filter should be applied to the controls.
bool OpenSim::CMC::getUseReflexes | ( | ) | const |
bool CMC::getUseVerbosePrinting | ( | ) | const |
Storage * CMC::getVelocityErrorStorage | ( | ) | const |
Get the storage object for velocity errors.
void CMC::initState | ( | SimTK::State & | s | ) | [virtual] |
Reimplemented from OpenSim::Controller.
void CMC::obtainActuatorEquilibrium | ( | SimTK::State & | s, | |
double | tiReal, | |||
double | dtReal, | |||
const Array< double > & | x, | |||
bool | hold | |||
) |
Obtain actuator equilibrium.
A series of long (e.g., 200 msec) integrations are performed to allow time-dependent actuators forces to reach equilibrium values.
Assignment operator.
aController | The controller to be copied. |
Reimplemented from OpenSim::TrackingController.
void CMC::restoreConfiguration | ( | SimTK::State & | s, | |
const SimTK::State & | initialState | |||
) |
A utility method used to restore the coordinates and speeds to initial values.
The states associated with actuators are not changed.
nqnu | Sum of the number of coordinates and speeds (nq + nu). | |
s | current state. | |
initialState | initial state to be restored. |
void CMC::setActuatorForcePredictor | ( | VectorFunctionForActuators * | aPredictor | ) |
Set the predictor for actuator forces.
Reimplemented from OpenSim::Controller.
void CMC::setCheckTargetTime | ( | bool | aTrueFalse | ) |
Set whether or not to check the target time.
aTrueFalse | If true, the target time will be checked. If false, the target time will not be checked. |
void CMC::setDT | ( | double | aDT | ) |
Set the requested integrator time step size.
aDT | Step size (0.0 <= aDT). |
void CMC::setNull | ( | void | ) |
Set NULL values for all member variables.
Reimplemented from OpenSim::TrackingController.
OptimizationTarget * CMC::setOptimizationTarget | ( | OptimizationTarget * | aTarget, | |
SimTK::Optimizer * | aOptimizer | |||
) |
Set the optimization target for this controller.
aTarget | Optimization target. |
void CMC::setTargetDT | ( | double | aDT | ) |
Set the target time step size.
The target time step size is the step size used to compute a new target time, once the former target time has been reached by the integrator.
aDT | Target time step size. Must be greater than 1.0e-8. |
void CMC::setTargetTime | ( | double | aTargetTime | ) |
Set the target time (or final time) for the controller.
The function of the controller is to compute a set of controls that are appropriate from the current time in a simulation to the target time of the controller. If an integrator is taking time steps prior to the target time, the controls should not have to be computed again.
aTargetTime | Time in the furture for which the controls have been computed. |
void CMC::setup | ( | Model & | model | ) | [virtual] |
Reimplemented from OpenSim::Controller.
void CMC::setupProperties | ( | void | ) | [virtual] |
Connect properties to local pointers.
Reimplemented from OpenSim::TrackingController.
void CMC::setupSystem | ( | SimTK::MultibodySystem & | system | ) | [virtual] |
Reimplemented from OpenSim::Controller.
void CMC::setUseCurvatureFilter | ( | bool | aTrueFalse | ) |
Set whether or not a curvature filter should be applied to the controls.
aTrueFalse | If true, controls will filtered based on their curvature. If false, they will not be filtered. |
void CMC::setUseVerbosePrinting | ( | bool | aTrueFalse | ) |
Set whether or not to use verbose printing.
aTrueFalse | If true, print verbose information. If false, print only critical information. |
ControlSet& OpenSim::CMC::updControlSet | ( | ) | [inline] |
CMC_TaskSet & CMC::updTaskSet | ( | ) | const |
bool OpenSim::CMC::_checkTargetTime [protected] |
Whether or not to check the target time.
ControlSet OpenSim::CMC::_controlSet [protected] |
double OpenSim::CMC::_dt [protected] |
Next integration step size that is to be taken by the integrator.
Array<double> OpenSim::CMC::_f [protected] |
Array of actuator forces for achieving the desired accelerations.
double OpenSim::CMC::_lastDT [protected] |
Last integration step size that was taken before a new integration step size was set in order to step exactly to the target time.
SimTK::Optimizer* OpenSim::CMC::_optimizer [protected] |
Optimizer.
Array<int> OpenSim::CMC::_paramList [protected] |
List of parameters in the control set that are serving as the controls in the optimization problem.
Storage* OpenSim::CMC::_pErrStore [protected] |
Storage object for the position errors.
VectorFunctionForActuators* OpenSim::CMC::_predictor [protected] |
Vector function for estimating actuator forces over a specified time interval.
bool OpenSim::CMC::_restoreDT [protected] |
Flag indicating when the last integration step size should be restored.
Normally it is restored only following a change to the integration step size that was made to step exactly to the end of a target interval.
Storage* OpenSim::CMC::_stressTermWeightStore [protected] |
Storage object for the stress term weight.
OptimizationTarget* OpenSim::CMC::_target [protected] |
Optimization target for computing the controls.
double OpenSim::CMC::_targetDT [protected] |
The step size used to generate a new target time, once the old target time has been reached.
CMC_TaskSet* OpenSim::CMC::_taskSet [protected] |
double OpenSim::CMC::_tf [protected] |
The target time is the time in the future (in normalized units) for which the controls have been calculated.
If an integrator is taking steps prior to the target time, the controls should not have to be computed again.
bool OpenSim::CMC::_useCurvatureFilter [protected] |
bool OpenSim::CMC::_verbose [protected] |
Flag to indicate whether to use verbose printing.
Storage* OpenSim::CMC::_vErrStore [protected] |
Storage object for the velocity errors.