A concrete tool for perfroming forward dynamics simulations. More...
#include <ForwardTool.h>
Public Member Functions | |
virtual | ~ForwardTool () |
Destructor. | |
ForwardTool () | |
Default constructor. | |
ForwardTool (const std::string &aFileName, bool aUpdateFromXMLNode=true, bool aLoadModel=true) SWIG_DECLARE_EXCEPTION | |
ForwardTool (const ForwardTool &aObject) | |
Copy constructor. | |
virtual Object * | copy () const |
Virtual copy constructor. | |
ForwardTool & | operator= (const ForwardTool &aForwardTool) |
Assignment operator. | |
virtual void | updateFromXMLNode () |
Override default implementation by object to intercept and fix the XML node underneath the tool to match current version. | |
void | setManager (Manager &m) |
Set the current integration manager. | |
const Manager & | getManager () const |
Get the current integration manager. | |
const std::string & | getStatesFileName () const |
void | setStatesFileName (const std::string &aFileName) |
bool | getUseSpecifiedDt () const |
void | setUseSpecifiedDt (bool aUseSpecifiedDt) |
const std::string & | getExternalLoadsFileName () const |
void | setExternalLoadsFileName (const std::string &aFileName) |
const std::string & | getExternalLoadsModelKinematicsFileName () const |
void | setExternalLoadsModelKinematicsFileName (const std::string &aFileName) |
const std::string & | getExternalLoadsBody1 () const |
void | setExternalLoadsBody1 (const std::string &aName) |
const std::string & | getExternalLoadsBody2 () const |
void | setExternalLoadsBody2 (const std::string &aName) |
double | getLowpassCutoffFrequencyForLoadKinematics () const |
void | setLowpassCutoffFrequencyForLoadKinematics (double aLowpassCutoffFrequency) |
void | setPrintResultFiles (bool aToWrite) |
virtual bool | run () SWIG_DECLARE_EXCEPTION |
Run the investigation. | |
void | printResults () |
void | loadStatesStorage (std::string &statesFileName, Storage *&rYStore) const |
const std::string & | getParsingLog () |
Static Public Member Functions | |
static double | Step (double t, double t0, double t1) |
A smooth step-down function using cubic polynomial. | |
static double | SigmaUp (double tau, double to, double t) |
A smooth step-up function using exponentials. | |
static double | SigmaDn (double tau, double to, double t) |
A smooth step-down function using exponentials. | |
Protected Member Functions | |
void | setDesiredStatesForControllers (Storage &rYStore) |
int | determineInitialTimeFromStatesStorage (double &rTI) |
Determine initial time for a simulation and find the index into the states storage for that time. | |
void | InitializeSpecifiedTimeStepping (Storage *aYStore, Manager &aManager) |
Setup time stepping so that the integrator follows a pre-specified series of time steps. | |
void | addCorrectiveSprings (SimTK::State &s, const Storage *aYStore, const PrescribedForce *aBody1Force, const PrescribedForce *aBody2Force) |
Add corrective springs. | |
LinearSpring * | addLinearCorrectiveSpring (SimTK::State &s, const Storage &aQStore, const Storage &aUStore, const PrescribedForce &aAppliedForce) |
Add a linear corrective spring. | |
TorsionalSpring * | addTorsionalCorrectiveSpring (SimTK::State &s, const Storage &aQStore, const Storage &aUStore, Body *aBody, double aTauOn, double aTimeOn, double aTauOff, double aTimeOff) |
Add a torsional corrective spring. | |
Protected Attributes | |
PropertyStr | _statesFileNameProp |
Name of the states file. | |
std::string & | _statesFileName |
OpenSim::PropertyBool | _useSpecifiedDtProp |
If true, the time steps from the states file are used during current integration. | |
bool & | _useSpecifiedDt |
OpenSim::PropertyStr | _externalLoadsFileNameProp |
Name of the file containing the external loads applied to the model. | |
std::string & | _externalLoadsFileName |
OpenSim::PropertyStr | _externalLoadsModelKinematicsFileNameProp |
Name of the file containing the model kinematics corresponding to the external loads. | |
std::string & | _externalLoadsModelKinematicsFileName |
OpenSim::PropertyStr | _externalLoadsBody1Prop |
Name of the body to which the first set of external loads should be applied (e.g., the body name for the right foot). | |
std::string & | _externalLoadsBody1 |
OpenSim::PropertyStr | _externalLoadsBody2Prop |
Name of the body to which the second set of external loads should be applied (e.g., the body name for the left foot). | |
std::string & | _externalLoadsBody2 |
OpenSim::PropertyDbl | _lowpassCutoffFrequencyForLoadKinematicsProp |
Low-pass cut-off frequency for filtering the model kinematics corresponding to the external loads. | |
double & | _lowpassCutoffFrequencyForLoadKinematics |
OpenSim::PropertyBool | _outputDetailedResultsProp |
Flag indicating whether or not to output corrective spring loads and other quantities. | |
bool & | _outputDetailedResults |
OpenSim::PropertyBool | _body1LinSpringActiveProp |
Flag indicating whether or not to turn on a linear corrective spring for the right foot. | |
bool & | _body1LinSpringActive |
OpenSim::PropertyBool | _body1TorSpringActiveProp |
Flag indicating whether or not to turn on a torsional corrective spring for the right foot. | |
bool & | _body1TorSpringActive |
OpenSim::PropertyBool | _body2LinSpringActiveProp |
Flag indicating whether or not to turn on a linear corrective spring for the left foot. | |
bool & | _body2LinSpringActive |
OpenSim::PropertyBool | _body2TorSpringActiveProp |
Flag indicating whether or not to turn on a torsional corrective spring for the left foot. | |
bool & | _body2TorSpringActive |
PropertyDbl | _body1TorSpringTimeOnProp |
Time at which the torsional spring comes on for body1 (if the spring is active). | |
double & | _body1TorSpringTimeOn |
PropertyDbl | _body1TorSpringTimeOffProp |
Time at which the torsional spring turns off for body1 (if the spring is active). | |
double & | _body1TorSpringTimeOff |
PropertyDbl | _body2TorSpringTimeOnProp |
Time at which the torsional spring turns on for body2 (if the spring is active). | |
double & | _body2TorSpringTimeOn |
PropertyDbl | _body2TorSpringTimeOffProp |
Time at which the torsional spring turns off for body2 (if the spring is active). | |
double & | _body2TorSpringTimeOff |
PropertyDbl | _tauProp |
Rise time for scaling functions for the torsional corrective springs. | |
double & | _tau |
PropertyDbl | _tauBody1OnProp |
Scaling rise-time for the body1 torsional spring turning on. | |
double & | _tauBody1On |
PropertyDbl | _tauBody1OffProp |
Scaling rise-time for the body1 torsional spring turning off. | |
double & | _tauBody1Off |
PropertyDbl | _tauBody2OnProp |
Scaling rise-time for the body2 torsional spring turning on. | |
double & | _tauBody2On |
PropertyDbl | _tauBody2OffProp |
Scaling rise-time for the body2 torsional spring turning off. | |
double & | _tauBody2Off |
PropertyDbl | _springTransitionStartForceProp |
Force magnitude above which the linear springs start to scale in to effect. | |
double & | _springTransitionStartForce |
PropertyDbl | _springTransitionEndForceProp |
Force magnitude below which the linear springs start to scale out of effect. | |
double & | _springTransitionEndForce |
PropertyDbl | _forceThresholdProp |
Force magnitude below which no corrective linear spring forces are applied. | |
double & | _forceThreshold |
PropertyDbl | _torqueThresholdProp |
Torque mangnitude below which no corrective torsional spring foreces are applied. | |
double & | _torqueThreshold |
PropertyDblVec3 | _kLinProp |
Stiffness for linear corrective springs. | |
SimTK::Vec3 & | _kLin |
PropertyDblVec3 | _bLinProp |
Damping for linear corrective springs. | |
SimTK::Vec3 & | _bLin |
PropertyDblVec3 | _kTorProp |
Stiffness for torsional corrective springs. | |
SimTK::Vec3 & | _kTor |
PropertyDblVec3 | _bTorProp |
Damping for torsional corrective springs. | |
SimTK::Vec3 & | _bTor |
LinearSpring * | _body1Lin |
Pointer to the linear and torsional corrective springs. | |
LinearSpring * | _body2Lin |
TorsionalSpring * | _body1Tor |
TorsionalSpring * | _body2Tor |
Storage * | _yStore |
Storage for the input states. | |
bool | _printResultFiles |
Flag indicating whether or not to write to the results (GUI will set this to false). | |
Manager * | _manager |
pointer to the simulation Manager | |
std::string | _parsingLog |
A concrete tool for perfroming forward dynamics simulations.
ForwardTool::~ForwardTool | ( | ) | [virtual] |
Destructor.
ForwardTool::ForwardTool | ( | ) |
Default constructor.
OpenSim::ForwardTool::ForwardTool | ( | const std::string & | aFileName, | |
bool | aUpdateFromXMLNode = true , |
|||
bool | aLoadModel = true | |||
) |
ForwardTool::ForwardTool | ( | const ForwardTool & | aTool | ) |
Copy constructor.
Copy constructors for all Tools only copy the non-XML variable members of the object; that is, the object's DOMnode and XMLDocument are not copied but set to NULL. The reason for this is that for the object and all its derived classes to establish the correct connection to the XML document nodes, the the object would need to reconstruct based on the XML document not the values of the object's member variables.
There are three proper ways to generate an XML document for an Tool:
1) Construction based on XML file (
2) Construction by Tool(const XMLDocument *aDocument). This constructor explictly requests construction based on an XML document. In this way the proper connection between an object's node and the corresponding node within the XML document is established. This constructor is a copy constructor of sorts because all essential Tool member variables should be held within the XML document. The advantage of this style of construction is that nodes within the XML document, such as comments that may not have any associated Tool member variable, are preserved.
3) A call to generateXMLDocument(). This method generates an XML document for the Tool from scratch. Only the essential document nodes are created (that is, nodes that correspond directly to member variables.).
aTool | Object to be copied. |
void ForwardTool::addCorrectiveSprings | ( | SimTK::State & | s, | |
const Storage * | aYStore, | |||
const PrescribedForce * | aBody1Force, | |||
const PrescribedForce * | aBody2Force | |||
) | [protected] |
Add corrective springs.
LinearSpring * ForwardTool::addLinearCorrectiveSpring | ( | SimTK::State & | s, | |
const Storage & | aQStore, | |||
const Storage & | aUStore, | |||
const PrescribedForce & | aAppliedForce | |||
) | [protected] |
Add a linear corrective spring.
TorsionalSpring * ForwardTool::addTorsionalCorrectiveSpring | ( | SimTK::State & | s, | |
const Storage & | aQStore, | |||
const Storage & | aUStore, | |||
OpenSim::Body * | aBody, | |||
double | aTauOn, | |||
double | aTimeOn, | |||
double | aTauOff, | |||
double | aTimeOff | |||
) | [protected] |
Add a torsional corrective spring.
Object * ForwardTool::copy | ( | ) | const [virtual] |
Virtual copy constructor.
Reimplemented from OpenSim::Object.
Reimplemented in OpenSim::PerturbationTool.
int ForwardTool::determineInitialTimeFromStatesStorage | ( | double & | rTI | ) | [protected] |
Determine initial time for a simulation and find the index into the states storage for that time.
rTI | Requested initial time for the simulation. If the time does not match a time in the states storage exactly, the initial time is altered so that there is an exact match. |
const std::string& OpenSim::ForwardTool::getExternalLoadsBody1 | ( | ) | const [inline] |
const std::string& OpenSim::ForwardTool::getExternalLoadsBody2 | ( | ) | const [inline] |
const std::string& OpenSim::ForwardTool::getExternalLoadsFileName | ( | ) | const [inline] |
const std::string& OpenSim::ForwardTool::getExternalLoadsModelKinematicsFileName | ( | ) | const [inline] |
double OpenSim::ForwardTool::getLowpassCutoffFrequencyForLoadKinematics | ( | ) | const [inline] |
const Manager & ForwardTool::getManager | ( | ) | const |
Get the current integration manager.
const std::string& OpenSim::ForwardTool::getParsingLog | ( | ) | [inline] |
const std::string& OpenSim::ForwardTool::getStatesFileName | ( | ) | const [inline] |
bool OpenSim::ForwardTool::getUseSpecifiedDt | ( | ) | const [inline] |
void ForwardTool::InitializeSpecifiedTimeStepping | ( | Storage * | aYStore, | |
Manager & | aManager | |||
) | [protected] |
Setup time stepping so that the integrator follows a pre-specified series of time steps.
void ForwardTool::loadStatesStorage | ( | std::string & | statesFileName, | |
Storage *& | rYStore | |||
) | const |
ForwardTool & ForwardTool::operator= | ( | const ForwardTool & | aTool | ) |
Assignment operator.
Reimplemented from OpenSim::AbstractTool.
Reimplemented in OpenSim::PerturbationTool.
void ForwardTool::printResults | ( | ) |
bool ForwardTool::run | ( | ) | [virtual] |
Run the investigation.
Implements OpenSim::AbstractTool.
Reimplemented in OpenSim::PerturbationTool.
void OpenSim::ForwardTool::setDesiredStatesForControllers | ( | Storage & | rYStore | ) | [protected] |
void OpenSim::ForwardTool::setExternalLoadsBody1 | ( | const std::string & | aName | ) | [inline] |
void OpenSim::ForwardTool::setExternalLoadsBody2 | ( | const std::string & | aName | ) | [inline] |
void OpenSim::ForwardTool::setExternalLoadsFileName | ( | const std::string & | aFileName | ) | [inline] |
void OpenSim::ForwardTool::setExternalLoadsModelKinematicsFileName | ( | const std::string & | aFileName | ) | [inline] |
void OpenSim::ForwardTool::setLowpassCutoffFrequencyForLoadKinematics | ( | double | aLowpassCutoffFrequency | ) | [inline] |
void ForwardTool::setManager | ( | Manager & | m | ) |
Set the current integration manager.
m | pointer to itegration manager |
void OpenSim::ForwardTool::setPrintResultFiles | ( | bool | aToWrite | ) | [inline] |
void OpenSim::ForwardTool::setStatesFileName | ( | const std::string & | aFileName | ) | [inline] |
void OpenSim::ForwardTool::setUseSpecifiedDt | ( | bool | aUseSpecifiedDt | ) | [inline] |
double ForwardTool::SigmaDn | ( | double | tau, | |
double | to, | |||
double | t | |||
) | [static] |
A smooth step-down function using exponentials.
tau | Rise and fall time constant. | |
to | Location of the midpoint of the step. | |
t | Independent variable |
double ForwardTool::SigmaUp | ( | double | tau, | |
double | to, | |||
double | t | |||
) | [static] |
A smooth step-up function using exponentials.
tau | Rise and fall time constant. | |
to | Location of the midpoint of the step. | |
t | Independent variable |
double ForwardTool::Step | ( | double | t, | |
double | t0, | |||
double | t1 | |||
) | [static] |
A smooth step-down function using cubic polynomial.
x=0 for t<t0, x=1 for t>t1, and x=smooth step in between t0 and t1.
t | Parameter at which to evaluate step function | |
t0 | Parameter value at which step starts (result=0 to the left) | |
t1 | Parameter value at which step ends (result=1 to the right) |
void ForwardTool::updateFromXMLNode | ( | ) | [virtual] |
Override default implementation by object to intercept and fix the XML node underneath the tool to match current version.
Reimplemented from OpenSim::AbstractTool.
Reimplemented in OpenSim::PerturbationTool.
SimTK::Vec3& OpenSim::ForwardTool::_bLin [protected] |
PropertyDblVec3 OpenSim::ForwardTool::_bLinProp [protected] |
Damping for linear corrective springs.
LinearSpring* OpenSim::ForwardTool::_body1Lin [protected] |
Pointer to the linear and torsional corrective springs.
bool& OpenSim::ForwardTool::_body1LinSpringActive [protected] |
Flag indicating whether or not to turn on a linear corrective spring for the right foot.
TorsionalSpring* OpenSim::ForwardTool::_body1Tor [protected] |
bool& OpenSim::ForwardTool::_body1TorSpringActive [protected] |
Flag indicating whether or not to turn on a torsional corrective spring for the right foot.
double& OpenSim::ForwardTool::_body1TorSpringTimeOff [protected] |
Time at which the torsional spring turns off for body1 (if the spring is active).
double& OpenSim::ForwardTool::_body1TorSpringTimeOn [protected] |
Time at which the torsional spring comes on for body1 (if the spring is active).
LinearSpring * OpenSim::ForwardTool::_body2Lin [protected] |
bool& OpenSim::ForwardTool::_body2LinSpringActive [protected] |
Flag indicating whether or not to turn on a linear corrective spring for the left foot.
TorsionalSpring * OpenSim::ForwardTool::_body2Tor [protected] |
bool& OpenSim::ForwardTool::_body2TorSpringActive [protected] |
Flag indicating whether or not to turn on a torsional corrective spring for the left foot.
double& OpenSim::ForwardTool::_body2TorSpringTimeOff [protected] |
Time at which the torsional spring turns off for body2 (if the spring is active).
double& OpenSim::ForwardTool::_body2TorSpringTimeOn [protected] |
Time at which the torsional spring turns on for body2 (if the spring is active).
SimTK::Vec3& OpenSim::ForwardTool::_bTor [protected] |
PropertyDblVec3 OpenSim::ForwardTool::_bTorProp [protected] |
Damping for torsional corrective springs.
std::string& OpenSim::ForwardTool::_externalLoadsBody1 [protected] |
Name of the body to which the first set of external loads should be applied (e.g., the body name for the right foot).
std::string& OpenSim::ForwardTool::_externalLoadsBody2 [protected] |
Name of the body to which the second set of external loads should be applied (e.g., the body name for the left foot).
std::string& OpenSim::ForwardTool::_externalLoadsFileName [protected] |
Name of the file containing the external loads applied to the model.
std::string& OpenSim::ForwardTool::_externalLoadsModelKinematicsFileName [protected] |
Name of the file containing the model kinematics corresponding to the external loads.
double& OpenSim::ForwardTool::_forceThreshold [protected] |
PropertyDbl OpenSim::ForwardTool::_forceThresholdProp [protected] |
Force magnitude below which no corrective linear spring forces are applied.
This allows an unperturbed forward integration to execute with minimal drift.
SimTK::Vec3& OpenSim::ForwardTool::_kLin [protected] |
PropertyDblVec3 OpenSim::ForwardTool::_kLinProp [protected] |
Stiffness for linear corrective springs.
SimTK::Vec3& OpenSim::ForwardTool::_kTor [protected] |
PropertyDblVec3 OpenSim::ForwardTool::_kTorProp [protected] |
Stiffness for torsional corrective springs.
double& OpenSim::ForwardTool::_lowpassCutoffFrequencyForLoadKinematics [protected] |
Low-pass cut-off frequency for filtering the model kinematics corresponding to the external loads.
A negative value results in no filtering. The default value is -1.0, so no filtering.
Manager* OpenSim::ForwardTool::_manager [protected] |
pointer to the simulation Manager
bool& OpenSim::ForwardTool::_outputDetailedResults [protected] |
Flag indicating whether or not to output corrective spring loads and other quantities.
std::string OpenSim::ForwardTool::_parsingLog [protected] |
bool OpenSim::ForwardTool::_printResultFiles [protected] |
Flag indicating whether or not to write to the results (GUI will set this to false).
double& OpenSim::ForwardTool::_springTransitionEndForce [protected] |
Force magnitude below which the linear springs start to scale out of effect.
double& OpenSim::ForwardTool::_springTransitionStartForce [protected] |
Force magnitude above which the linear springs start to scale in to effect.
std::string& OpenSim::ForwardTool::_statesFileName [protected] |
PropertyStr OpenSim::ForwardTool::_statesFileNameProp [protected] |
Name of the states file.
The states file must at a minimum contain the initial states for a simulation. If a complete set of states is available, the time stamps can be used to specify the integration steps and corrective springs, which allow perturbations, can be added to the simulation.
double& OpenSim::ForwardTool::_tau [protected] |
double& OpenSim::ForwardTool::_tauBody1Off [protected] |
PropertyDbl OpenSim::ForwardTool::_tauBody1OffProp [protected] |
Scaling rise-time for the body1 torsional spring turning off.
double& OpenSim::ForwardTool::_tauBody1On [protected] |
PropertyDbl OpenSim::ForwardTool::_tauBody1OnProp [protected] |
Scaling rise-time for the body1 torsional spring turning on.
double& OpenSim::ForwardTool::_tauBody2Off [protected] |
PropertyDbl OpenSim::ForwardTool::_tauBody2OffProp [protected] |
Scaling rise-time for the body2 torsional spring turning off.
double& OpenSim::ForwardTool::_tauBody2On [protected] |
PropertyDbl OpenSim::ForwardTool::_tauBody2OnProp [protected] |
Scaling rise-time for the body2 torsional spring turning on.
PropertyDbl OpenSim::ForwardTool::_tauProp [protected] |
Rise time for scaling functions for the torsional corrective springs.
double& OpenSim::ForwardTool::_torqueThreshold [protected] |
Torque mangnitude below which no corrective torsional spring foreces are applied.
This allows an unperturbed forward integration to execute with minimal drift.
bool& OpenSim::ForwardTool::_useSpecifiedDt [protected] |
If true, the time steps from the states file are used during current integration.
Storage* OpenSim::ForwardTool::_yStore [protected] |
Storage for the input states.