A base class that specifies the interface for a musculoskeletal model. More...
#include <Model.h>
Public Member Functions | |
Model () | |
Default constructor. | |
Model (const std::string &aFileName) SWIG_DECLARE_EXCEPTION | |
Constructor from an XML file. | |
Model (const Model &aModel) | |
Copy constructor. | |
virtual | ~Model () |
Destructor. | |
virtual void | updateFromXMLNode () |
Override of the default implementation to account for versioning. | |
virtual Object * | copy () const |
Copy this Model and return a pointer to the copy. | |
void | copyData (const Model &aModel) |
Copy the member variables of the model. | |
void | setupProperties () |
Connect properties to local pointers. | |
Model * | clone () |
Dynamic casting across JNI is messy. | |
virtual void | setup () SWIG_DECLARE_EXCEPTION |
Perform some set up functions that happen after the object has been deserialized. | |
void | cleanup () |
Perform some clean up functions that are normally done from the destructor however this gives the GUI a way to proactively do the cleaning without waiting for garbage collection to do the actual cleanup. | |
SimTK::State & | initSystem () SWIG_DECLARE_EXCEPTION |
This must be called after the Model is fully created but before starting a simulation. | |
void | invalidateSystem () |
Mark the computational system as invalid. | |
void | setDefaultsFromState (const SimTK::State &state) |
Given a State, set all default values for this Model to match those found in the State. | |
void | formStateStorage (const Storage &originalStorage, Storage &statesStorage) |
create a storage (statesStorage) that has same label order as model's states with values populated from originalStorage, 0.0 for those states unspecified in the originalStorage. | |
void | formQStorage (const Storage &originalStorage, Storage &qStorage) |
Model::formStateStorage is intended to take any storage and populate qStorage. | |
void | equilibrateMuscles (SimTK::State &state) |
Update the state of all Muscles so they are in equilibrium. | |
bool | builtOK () |
Indicates whether or not problems were encountered during model setup(). | |
const OpenSimForceSubsystem & | getForceSubsystem () const |
const SimTK::SimbodyMatterSubsystem & | getMatterSubsystem () const |
SimTK::SimbodyMatterSubsystem & | updMatterSubsystem () |
const SimTK::Force::UniformGravity & | getGravitySubsystem () const |
const SimTK::GeneralForceSubsystem & | getUserForceSubsystem () const |
SimTK::GeneralForceSubsystem & | updUserForceSubsystem () |
virtual void | createSystem () |
Create the multibody system. | |
virtual void | addBody (Body *aBody) |
Add ModelComponents to the Model. | |
virtual void | addConstraint (Constraint *aConstraint) |
Add a constraint to the Model. | |
virtual void | addForce (Force *aForce) |
Add a force to the Model. | |
virtual void | addContactGeometry (ContactGeometry *aContactGeometry) |
Add a contact geometry to the Model. | |
virtual const std::string & | getInputFileName () const |
Get the XML file name used to construct the model. | |
virtual void | setInputFileName (const std::string &fileName) |
Set the XML file name used to construct the model. | |
virtual const std::string & | getCredits () const |
Get the credits (e.g., model author names) associated with the model. | |
virtual void | setAuthors (const std::string &aCredits) |
Set the credits (e.g., model author names) associated with the model. | |
virtual const std::string & | getPublications () const |
Get the publications associated with the model. | |
virtual void | setPublications (const std::string &aPublications) |
Set the publications associated with the model. | |
virtual const Units & | getLengthUnits () const |
Get the length units associated with the model. | |
virtual const Units & | getForceUnits () const |
Get the force units associated with the model. | |
virtual SimTK::MultibodySystem & | getMultibodySystem () |
virtual void | setMultibodySystem (SimTK::MultibodySystem &system) |
virtual void | getGravity (SimTK::Vec3 &rGrav) const |
Get the gravity vector in the gloabl frame. | |
virtual bool | setGravity (const SimTK::Vec3 &aGrav) |
Set the gravity vector in the gloabl frame. | |
virtual int | getNumStates () const |
Add a joint and associated child body. | |
virtual int | getNumMarkers () const |
Get the number of controls in the model. | |
virtual int | getNumContactGeometries () const |
Get the number of ContactGeometries in the model. | |
virtual int | getNumBodies () const |
Get the total number of bodies in the model. | |
virtual int | getNumJoints () const |
Get the total number of joints in the model. | |
virtual int | getNumCoordinates () const |
Get the total number of coordinates in the model. | |
virtual int | getNumSpeeds () const |
Get the total number of speeds in the model. | |
const Set< Actuator > & | getActuators () const |
Get the subset of Forces in the model which are actuators. | |
Set< Actuator > & | updActuators () |
const ForceSet & | getForceSet () const |
ForceSet & | updForceSet () |
virtual int | getNumAnalyses () const |
Get the number of analyses in the model. | |
int | getNumConfigurations () const |
Get the number of configurations in the model. | |
bool | isControlled () const |
Get a flag indicating if the model needs controls to operate its actuators. | |
virtual void | storeControls (const SimTK::State &s, int step) |
virtual void | printControlStorage (const std::string &fileName) const |
virtual const ControllerSet & | getControllerSet () const |
virtual ControllerSet & | updControllerSet () |
virtual bool | getAllControllersEnabled () const |
virtual void | setAllControllersEnabled (bool enabled) |
virtual void | applyDefaultConfiguration (SimTK::State &s) |
Apply the default configuration to the model. | |
const SimbodyEngine & | getSimbodyEngine () const |
Get the model's dynamics engine. | |
SimbodyEngine & | updSimbodyEngine () |
virtual void | setTimeNormConstant (double aNormConst) |
Set the constant by which time is normalized. | |
virtual double | getTimeNormConstant () const |
Get the constant by which time is normalized. | |
virtual void | getStateNames (Array< std::string > &rStateNames) const |
Get the names of the states. | |
int | getNumMuscleStates () const |
Get the number of Muscle state variabls in the model. | |
virtual void | setInitialTime (double ti) |
void | setStep (const SimTK::State &s, int step) const |
set step | |
int | getStep (const SimTK::State &s) const |
get step number | |
void | setSystem (SimTK::MultibodySystem *mbs) |
set pointer to MultibodySystem | |
SimTK::MultibodySystem & | getSystem () const |
get pointer to MultibodySystem | |
virtual CoordinateSet & | updCoordinateSet () |
virtual const CoordinateSet & | getCoordinateSet () const |
virtual BodySet & | updBodySet () |
virtual const BodySet & | getBodySet () const |
virtual JointSet & | updJointSet () |
Get a flat list of Joints contained in the model. | |
virtual const JointSet & | getJointSet () |
virtual AnalysisSet & | updAnalysisSet () |
virtual const AnalysisSet & | getAnalysisSet () const |
virtual ContactGeometrySet & | updContactGeometrySet () |
virtual const ContactGeometrySet & | getContactGeometrySet () const |
virtual Body & | getGroundBody () const |
Get the body that is being used as ground. | |
virtual ConstraintSet & | updConstraintSet () |
virtual const ConstraintSet & | getConstraintSet () const |
virtual MarkerSet & | updMarkerSet () |
virtual const MarkerSet & | getMarkerSet () const |
virtual int | replaceMarkerSet (const SimTK::State &s, MarkerSet &aMarkerSet) |
Replace all markers in the model with the ones in the passed-in marker set. | |
virtual void | writeMarkerFile (const std::string &aFileName) const |
virtual void | updateMarkerSet (MarkerSet &aMarkerSet) |
Update all markers in the model with the ones in the passed-in marker set. | |
virtual int | deleteUnusedMarkers (const Array< std::string > &aMarkerNames) |
virtual void | addAnalysis (Analysis *aAnalysis) |
Add an analysis to the model. | |
virtual void | addController (Controller *aController) |
Add a controller to the Model. | |
virtual void | removeAnalysis (Analysis *aAnalysis, bool deleteIt=true) |
Remove an analysis from the model. | |
virtual void | removeController (Controller *aController) |
Remove a controller from the model. | |
virtual void | computeEquilibriumForAuxiliaryStates (SimTK::State &s) |
Compute values for the auxiliary states (i.e., states other than the generalized coordinates and speeds) that are in quasi-static equilibrium. | |
virtual bool | scale (SimTK::State &s, const ScaleSet &aScaleSet, double aFinalMass=-1.0, bool aPreserveMassDist=false) |
Scale the model. | |
void | printBasicInfo (std::ostream &aOStream) const |
Print some basic information about the model. | |
void | printDetailedInfo (const SimTK::State &s, std::ostream &aOStream) const |
Print detailed information about the model. | |
void | disownAllComponents () |
Model relinquishes ownership of all components such as: Bodies, Constraints, Forces, ConactGeometry and so on. | |
Protected Member Functions | |
Model & | operator= (const Model &Model) |
Assignment operator. | |
void | setupFromXML () |
This is called after the Model has been constructed from an XML file. | |
void | initState (SimTK::State &state) const |
This is called after a SimTK System and State have been created for the Model. | |
void | createGroundBodyIfNecessary () |
Create a ground body if necessary. | |
Friends | |
class | ForceSet |
A base class that specifies the interface for a musculoskeletal model.
This class is based on Model, written by Frank C. Anderson for Realistic Dynamics, Inc., but all of the data and methods relating to kinematics engines or dynamics engines have been removed.
Model::Model | ( | ) |
Default constructor.
OpenSim::Model::Model | ( | const std::string & | aFileName | ) |
Constructor from an XML file.
aFileName | XML file name. |
Model::~Model | ( | ) | [virtual] |
Destructor.
void Model::addAnalysis | ( | Analysis * | aAnalysis | ) | [virtual] |
Add an analysis to the model.
aAnalysis | pointer to the analysis to add |
void Model::addBody | ( | OpenSim::Body * | aBody | ) | [virtual] |
void Model::addConstraint | ( | OpenSim::Constraint * | aConstraint | ) | [virtual] |
Add a constraint to the Model.
void Model::addContactGeometry | ( | OpenSim::ContactGeometry * | aContactGeometry | ) | [virtual] |
Add a contact geometry to the Model.
void Model::addController | ( | Controller * | aController | ) | [virtual] |
Add a controller to the Model.
void Model::addForce | ( | OpenSim::Force * | aForce | ) | [virtual] |
Add a force to the Model.
void Model::applyDefaultConfiguration | ( | SimTK::State & | s | ) | [virtual] |
Apply the default configuration to the model.
This means setting the generalized coordinates and spees to their default values.
bool OpenSim::Model::builtOK | ( | ) | [inline] |
Indicates whether or not problems were encountered during model setup().
void Model::cleanup | ( | ) |
Perform some clean up functions that are normally done from the destructor however this gives the GUI a way to proactively do the cleaning without waiting for garbage collection to do the actual cleanup.
Model* OpenSim::Model::clone | ( | ) | [inline] |
Dynamic casting across JNI is messy.
This method does the upCasting on C++ side
void Model::computeEquilibriumForAuxiliaryStates | ( | SimTK::State & | s | ) | [virtual] |
Compute values for the auxiliary states (i.e., states other than the generalized coordinates and speeds) that are in quasi-static equilibrium.
_____________________________________________________________________________ /** Compute values for the auxiliary states (i.e., states other than the generalized coordinates and speeds) that are in quasi-static equilibrium.
The auxiliary states usually belong to the actuators (e.g., muscle activation and muscle fiber length). The equilibrium computations are passed on to the owner of the the states.
This methods is useful for computing initial conditions for a simulation or for computing torque-angle curves, for example.
rY | Array of states. The values sent in are used as the initial guess for equilibrium. The values returned are those that satisfy equilibrium. |
Object * Model::copy | ( | ) | const [virtual] |
Copy this Model and return a pointer to the copy.
The copy constructor for this class is used.
Reimplemented from OpenSim::Object.
void Model::copyData | ( | const Model & | aModel | ) |
Copy the member variables of the model.
aModel | model to be copied |
void Model::createGroundBodyIfNecessary | ( | ) | [protected] |
Create a ground body if necessary.
void Model::createSystem | ( | ) | [virtual] |
Create the multibody system.
virtual int OpenSim::Model::deleteUnusedMarkers | ( | const Array< std::string > & | aMarkerNames | ) | [virtual] |
void Model::disownAllComponents | ( | ) |
Model relinquishes ownership of all components such as: Bodies, Constraints, Forces, ConactGeometry and so on.
That means the freeing of the memory of these objects is up to the caller.
void Model::equilibrateMuscles | ( | SimTK::State & | state | ) |
Update the state of all Muscles so they are in equilibrium.
Model::formStateStorage is intended to take any storage and populate qStorage.
stateStorage is supposed to be a Storage with labels identical to those obtained by calling Model::getStateNames(). Columns/entries found in the "originalStorage" are copied to the output qStorage. Entries not found are populated with 0s.
create a storage (statesStorage) that has same label order as model's states with values populated from originalStorage, 0.0 for those states unspecified in the originalStorage.
Model::formStateStorage is intended to take any storage and populate stateStorage.
stateStorage is supposed to be a Storage with labels identical to those obtained by calling Model::getStateNames(). Columns/entries found in the "originalStorage" are copied to the output statesStorage. Entries not found are populated with 0s.
Get the subset of Forces in the model which are actuators.
bool Model::getAllControllersEnabled | ( | ) | const [virtual] |
virtual const AnalysisSet& OpenSim::Model::getAnalysisSet | ( | ) | const [inline, virtual] |
virtual const BodySet& OpenSim::Model::getBodySet | ( | ) | const [inline, virtual] |
virtual const ConstraintSet& OpenSim::Model::getConstraintSet | ( | ) | const [inline, virtual] |
virtual const ContactGeometrySet& OpenSim::Model::getContactGeometrySet | ( | ) | const [inline, virtual] |
const ControllerSet & Model::getControllerSet | ( | ) | const [virtual] |
virtual const CoordinateSet& OpenSim::Model::getCoordinateSet | ( | ) | const [inline, virtual] |
virtual const std::string& OpenSim::Model::getCredits | ( | ) | const [inline, virtual] |
Get the credits (e.g., model author names) associated with the model.
const ForceSet& OpenSim::Model::getForceSet | ( | ) | const [inline] |
const OpenSimForceSubsystem& OpenSim::Model::getForceSubsystem | ( | ) | const [inline] |
virtual const Units& OpenSim::Model::getForceUnits | ( | ) | const [inline, virtual] |
Get the force units associated with the model.
void Model::getGravity | ( | SimTK::Vec3 & | rGrav | ) | const [virtual] |
Get the gravity vector in the gloabl frame.
rGrav | The XYZ gravity vector in the global frame is returned here. | |
rGrav | the XYZ gravity vector in the global frame is returned here. |
const SimTK::Force::UniformGravity& OpenSim::Model::getGravitySubsystem | ( | ) | const [inline] |
OpenSim::Body & Model::getGroundBody | ( | ) | const [virtual] |
Get the body that is being used as ground.
virtual const std::string& OpenSim::Model::getInputFileName | ( | ) | const [inline, virtual] |
Get the XML file name used to construct the model.
const JointSet & Model::getJointSet | ( | ) | [virtual] |
virtual const Units& OpenSim::Model::getLengthUnits | ( | ) | const [inline, virtual] |
Get the length units associated with the model.
virtual const MarkerSet& OpenSim::Model::getMarkerSet | ( | ) | const [inline, virtual] |
const SimTK::SimbodyMatterSubsystem& OpenSim::Model::getMatterSubsystem | ( | ) | const [inline] |
virtual SimTK::MultibodySystem& OpenSim::Model::getMultibodySystem | ( | ) | [inline, virtual] |
int Model::getNumAnalyses | ( | ) | const [virtual] |
Get the number of analyses in the model.
int Model::getNumBodies | ( | ) | const [virtual] |
Get the total number of bodies in the model.
int OpenSim::Model::getNumConfigurations | ( | ) | const [inline] |
Get the number of configurations in the model.
int Model::getNumContactGeometries | ( | ) | const [virtual] |
Get the number of ContactGeometries in the model.
Get the number of ContactGeometry objects in the model.
int Model::getNumCoordinates | ( | ) | const [virtual] |
Get the total number of coordinates in the model.
int Model::getNumJoints | ( | ) | const [virtual] |
Get the total number of joints in the model.
int Model::getNumMarkers | ( | ) | const [virtual] |
Get the number of controls in the model.
Get the number of markers in the model.
int Model::getNumMuscleStates | ( | ) | const |
Get the number of Muscle state variabls in the model.
int Model::getNumSpeeds | ( | ) | const [virtual] |
Get the total number of speeds in the model.
Get the total number of coordinates = number of speeds in the model.
int Model::getNumStates | ( | ) | const [virtual] |
Add a joint and associated child body.
aJoint | The joint. Get the number of states in the model. |
virtual const std::string& OpenSim::Model::getPublications | ( | ) | const [inline, virtual] |
Get the publications associated with the model.
const SimbodyEngine& OpenSim::Model::getSimbodyEngine | ( | ) | const [inline] |
Get the model's dynamics engine.
virtual void OpenSim::Model::getStateNames | ( | Array< std::string > & | rStateNames | ) | const [virtual] |
Get the names of the states.
rStateNames | Array of state names.. |
int Model::getStep | ( | const SimTK::State & | s | ) | const |
get step number
state | SimTK::State |
SimTK::MultibodySystem & Model::getSystem | ( | ) | const |
get pointer to MultibodySystem
state | SimTK::State |
double Model::getTimeNormConstant | ( | ) | const [virtual] |
Get the constant by which time is normalized.
By default, the time normalization constant is 1.0.
const SimTK::GeneralForceSubsystem& OpenSim::Model::getUserForceSubsystem | ( | ) | const [inline] |
void Model::initState | ( | SimTK::State & | state | ) | const [protected, virtual] |
This is called after a SimTK System and State have been created for the Model.
It may be overridden to set initial values of state variables.
state | the State to initialize |
Reimplemented from OpenSim::ModelComponent.
SimTK::State & Model::initSystem | ( | ) |
This must be called after the Model is fully created but before starting a simulation.
It creates and initializes the computational system used to simulate the model.
void Model::invalidateSystem | ( | ) |
Mark the computational system as invalid.
This should be called whenever a property of the model is modified. Once this has been called, no calculations can be done until initSystem() is called again.
bool OpenSim::Model::isControlled | ( | ) | const [inline] |
Get a flag indicating if the model needs controls to operate its actuators.
Assignment operator.
Register the types used by this class.
void Model::registerTypes() { now handled by RegisterTypes_osimSimulation() } Assignment operator.
Reimplemented from OpenSim::Object.
void Model::printBasicInfo | ( | std::ostream & | aOStream | ) | const |
Print some basic information about the model.
aOStream | Output stream. |
virtual void OpenSim::Model::printControlStorage | ( | const std::string & | fileName | ) | const [virtual] |
void Model::printDetailedInfo | ( | const SimTK::State & | s, | |
std::ostream & | aOStream | |||
) | const |
Print detailed information about the model.
aOStream | Output stream. |
void Model::removeAnalysis | ( | Analysis * | aAnalysis, | |
bool | deleteIt = true | |||
) | [virtual] |
Remove an analysis from the model.
void Model::removeController | ( | Controller * | aController | ) | [virtual] |
Remove a controller from the model.
aController | Pointer to the controller to remove. |
int Model::replaceMarkerSet | ( | const SimTK::State & | s, | |
MarkerSet & | aMarkerSet | |||
) | [virtual] |
Replace all markers in the model with the ones in the passed-in marker set.
aMarkerSet | The new marker set. |
bool Model::scale | ( | SimTK::State & | s, | |
const ScaleSet & | aScaleSet, | |||
double | aFinalMass = -1.0 , |
|||
bool | aPreserveMassDist = false | |||
) | [virtual] |
Scale the model.
aScaleSet | the set of XYZ scale factors for the bodies | |
aFinalMass | the mass that the scaled model should have | |
aPreserveMassDist | whether or not the masses of the individual bodies should be scaled with the body scale factors. |
void Model::setAllControllersEnabled | ( | bool | enabled | ) | [virtual] |
virtual void OpenSim::Model::setAuthors | ( | const std::string & | aCredits | ) | [inline, virtual] |
Set the credits (e.g., model author names) associated with the model.
aCredits | The string of credits. |
void Model::setDefaultsFromState | ( | const SimTK::State & | state | ) | [virtual] |
Given a State, set all default values for this Model to match those found in the State.
Reimplemented from OpenSim::ModelComponent.
bool Model::setGravity | ( | const SimTK::Vec3 & | aGrav | ) | [virtual] |
Set the gravity vector in the gloabl frame.
aGrav | The XYZ gravity vector |
aGrav | the XYZ gravity vector |
void Model::setInitialTime | ( | double | ti | ) | [virtual] |
virtual void OpenSim::Model::setInputFileName | ( | const std::string & | fileName | ) | [inline, virtual] |
Set the XML file name used to construct the model.
fileName | The XML file name. |
virtual void OpenSim::Model::setMultibodySystem | ( | SimTK::MultibodySystem & | system | ) | [inline, virtual] |
virtual void OpenSim::Model::setPublications | ( | const std::string & | aPublications | ) | [inline, virtual] |
Set the publications associated with the model.
aPublications | The string of publications. |
void Model::setStep | ( | const SimTK::State & | s, | |
int | step | |||
) | const |
set step
state | SimTK::State | |
step | The step number |
void Model::setSystem | ( | SimTK::MultibodySystem * | mbs | ) |
set pointer to MultibodySystem
mbs | pointer to a SimTK::MultibodySystem |
void Model::setTimeNormConstant | ( | double | aNormConst | ) | [virtual] |
Set the constant by which time is normalized.
The normalization constant must be greater than or equal to the constant Zero
Time | normalization constant. |
The normalization constant must be greater than or equal to the constant Zero.
Time | normalization constant. |
void Model::setup | ( | ) | [virtual] |
Perform some set up functions that happen after the object has been deserialized.
TODO: this method is not yet designed to be called after a model has been copied.
This method is not yet designed to be called after a model has been copied.
void Model::setupFromXML | ( | ) | [protected, virtual] |
This is called after the Model has been constructed from an XML file.
It may be overridden to do required initialization, such as looking up references to other objects in the Model (which might not have existed yet when this object was created).
Reimplemented from OpenSim::ModelComponent.
void Model::setupProperties | ( | void | ) |
Connect properties to local pointers.
Reimplemented from OpenSim::Object.
void Model::storeControls | ( | const SimTK::State & | s, | |
int | step | |||
) | [virtual] |
virtual AnalysisSet& OpenSim::Model::updAnalysisSet | ( | ) | [inline, virtual] |
void Model::updateFromXMLNode | ( | ) | [virtual] |
Override of the default implementation to account for versioning.
Override default implementation by object to intercept and fix the XML node underneath the model to match current version.
Reimplemented from OpenSim::Object.
void Model::updateMarkerSet | ( | MarkerSet & | aMarkerSet | ) | [virtual] |
Update all markers in the model with the ones in the passed-in marker set.
If the marker does not yet exist in the model, it is added.
aMarkerSet | set of markers to be updated/added |
virtual BodySet& OpenSim::Model::updBodySet | ( | ) | [inline, virtual] |
virtual ConstraintSet& OpenSim::Model::updConstraintSet | ( | ) | [inline, virtual] |
virtual ContactGeometrySet& OpenSim::Model::updContactGeometrySet | ( | ) | [inline, virtual] |
ControllerSet & Model::updControllerSet | ( | ) | [virtual] |
virtual CoordinateSet& OpenSim::Model::updCoordinateSet | ( | ) | [inline, virtual] |
ForceSet& OpenSim::Model::updForceSet | ( | ) | [inline] |
JointSet & Model::updJointSet | ( | ) | [virtual] |
Get a flat list of Joints contained in the model.
virtual MarkerSet& OpenSim::Model::updMarkerSet | ( | ) | [inline, virtual] |
SimTK::SimbodyMatterSubsystem& OpenSim::Model::updMatterSubsystem | ( | ) | [inline] |
SimbodyEngine& OpenSim::Model::updSimbodyEngine | ( | ) | [inline] |
SimTK::GeneralForceSubsystem& OpenSim::Model::updUserForceSubsystem | ( | ) | [inline] |
virtual void OpenSim::Model::writeMarkerFile | ( | const std::string & | aFileName | ) | const [virtual] |
friend class ForceSet [friend] |