API  3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
OpenSim::Model Class Reference

A concrete class that specifies the interface to a musculoskeletal model. More...

+ Inheritance diagram for OpenSim::Model:

Public Member Functions

 Model ()
 Default constructor creates a Model containing only the ground Body and a set of default properties. More...
 
 Model (const std::string &filename, bool connectToModel=true) SWIG_DECLARE_EXCEPTION
 Constructor from an OpenSim XML model file. More...
 
 Model (const Model &source)
 Copy constructor copies model components but does not copy any run-time objects. More...
 
Modeloperator= (const Model &source)
 Copy assignment copies model components but does not copy any run-time objects. More...
 
void setup () SWIG_DECLARE_EXCEPTION
 Perform some set up functions that happen after the object has been deserialized. More...
 
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. More...
 
void buildSystem ()
 After the Model and its components have been constructed, call this to interconnect the components and then create the Simbody MultibodySystem needed to represent the Model computationally. More...
 
SimTK::StateinitializeState ()
 After buildSystem() has been called, and any additional modifications to the Simbody MultibodySystem have been made, call this method to finalize the MultibodySystem (by calling its realizeTopology() method), obtain an initial state, and assemble it so that position constraints are satisified. More...
 
SimTK::StateinitSystem () SWIG_DECLARE_EXCEPTION
 Convenience method that invokes buildSystem() and then initializeState(). More...
 
const SimTK::StategetWorkingState () const
 Convenience method that returns a reference to the model's 'working' state. More...
 
SimTK::StateupdWorkingState ()
 
void copyDefaultStateIntoWorkingState ()
 Method to copy a model's default state into the space allocated for its working state. More...
 
void initStateWithoutRecreatingSystem (SimTK::State &state) const
 This is called after the Model is fully created but before starting a simulation. More...
 
void invalidateSystem ()
 Mark the computational system as invalid. More...
 
bool isValidSystem () const
 Check that the underlying computational system representing the model is valid. More...
 
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. More...
 
void formQStorage (const Storage &originalStorage, Storage &qStorage)
 
void updateAssemblyConditions (SimTK::State &s)
 Update the AssemblySolver to the latest coordinate locking/constraints. More...
 
void assemble (SimTK::State &state, const Coordinate *coord=NULL, double weight=10)
 Find the kinematic state of the model that satisfies constraints and coordinate goals If assemble is being called due to a coordinate set value, provide the option to weight that coordinate value more heavily if specified. More...
 
void equilibrateMuscles (SimTK::State &state)
 Update the state of all Muscles so they are in equilibrium. More...
 
virtual int getNumStateVariables () const
 Get the number of "Continuous" state variables maintained by the ModelComponent and its specified subcomponents. More...
 
void addComponent (ModelComponent *aComponent)
 Add ModelComponents to the Model. More...
 
void addBody (Body *aBody)
 
void addConstraint (Constraint *aConstraint)
 
void addForce (Force *aForce)
 
void addProbe (Probe *aProbe)
 
void addContactGeometry (ContactGeometry *aContactGeometry)
 
void removeProbe (Probe *aProbe)
 remove passed in Probe from model More...
 
const std::string & getInputFileName () const
 Get the XML file name used to construct the model. More...
 
void setInputFileName (const std::string &fileName)
 Set the XML file name used to construct the model. More...
 
const std::string & getCredits () const
 Get the credits (e.g., model author names) associated with the model. More...
 
void setAuthors (const std::string &aCredits)
 Set the credits (e.g., model author names) associated with the model. More...
 
const std::string & getPublications () const
 Get the publications associated with the model. More...
 
void setPublications (const std::string &aPublications)
 Set the publications associated with the model. More...
 
const UnitsgetLengthUnits () const
 Get the length units associated with the model. More...
 
const UnitsgetForceUnits () const
 Get the force units associated with the model. More...
 
SimTK::Vec3 getGravity () const
 Get the gravity vector in the global frame. More...
 
bool setGravity (const SimTK::Vec3 &aGrav)
 Set the gravity vector in the gloabl frame. More...
 
int getNumMarkers () const
 Get the number of markers in the model. More...
 
int getNumContactGeometries () const
 Get the number of ContactGeometries in the model. More...
 
int getNumBodies () const
 Get the total number of bodies in the model. More...
 
int getNumJoints () const
 Get the total number of joints in the model. More...
 
int getNumCoordinates () const
 Get the total number of coordinates in the model. More...
 
int getNumSpeeds () const
 Get the total number of speeds in the model. More...
 
int getNumProbes () const
 Get the total number of probes in the model. More...
 
const Set< Actuator > & getActuators () const
 Get the subset of Forces in the model which are actuators. More...
 
Set< Actuator > & updActuators ()
 
const Set< Muscle > & getMuscles () const
 Get the subset of Forces in the model which are muscles. More...
 
Set< Muscle > & updMuscles ()
 
const ForceSetgetForceSet () const
 
ForceSetupdForceSet ()
 
const ProbeSetgetProbeSet () const
 Get the subset of Probes in the model. More...
 
ProbeSetupdProbeSet ()
 
const ComponentSetgetMiscModelComponentSet () const
 Get the subset of misc ModelComponents in the model. More...
 
ComponentSetupdMiscModelComponentSet ()
 
int getNumAnalyses () const
 Get the number of analyses in the model. More...
 
int getNumControls () const
 Get the number of controls for this the model. More...
 
SimTK::VectorupdDefaultControls () const
 Writable access to the default values for controls. More...
 
void setDefaultControls (const SimTK::Vector &controls) const
 
const SimTK::VectorgetDefaultControls () const
 
SimTK::VectorupdControls (const SimTK::State &s) const
 Update the controls for this the model at a given state. More...
 
void markControlsAsValid (const SimTK::State &s) const
 Mark controls as valid after an update at a given state. More...
 
void setControls (const SimTK::State &s, const SimTK::Vector &controls) const
 Alternatively, set the controls on the model at a given state. More...
 
const SimTK::VectorgetControls (const SimTK::State &s) const
 Const access to controls does not invalidate dynamics. More...
 
void computeControls (const SimTK::State &state, SimTK::Vector &controls) const
 Compute the controls for the model. More...
 
bool isControlled () const
 Get a flag indicating if the model needs controls to operate its actuators. More...
 
void storeControls (const SimTK::State &s, int step)
 
void printControlStorage (const std::string &fileName) const
 
const ControllerSetgetControllerSet () const
 
ControllerSetupdControllerSet ()
 
bool getAllControllersEnabled () const
 
void setAllControllersEnabled (bool enabled)
 
void applyDefaultConfiguration (SimTK::State &s)
 
const SimbodyEnginegetSimbodyEngine () const
 Get the model's dynamics engine. More...
 
SimbodyEngineupdSimbodyEngine ()
 
SimTK::Vector computeStateVariableDerivatives (const SimTK::State &s) const
 If a model component has allocated any continuous state variables using the addStateVariable() method, then computeStateVariableDerivatives() must be implemented to provide time derivatives for those states. More...
 
double getTotalMass (const SimTK::State &s) const
 
SimTK::Inertia getInertiaAboutMassCenter (const SimTK::State &s) const
 
SimTK::Vec3 calcMassCenterPosition (const SimTK::State &s) const
 
SimTK::Vec3 calcMassCenterVelocity (const SimTK::State &s) const
 
SimTK::Vec3 calcMassCenterAcceleration (const SimTK::State &s) const
 
void getStateValues (const SimTK::State &state, Array< double > &stateValues) const
 Get the values of state variables in the same ordering as returned by getStateVariableNames(). More...
 
SimTK::Vector getStateValues (const SimTK::State &s) const
 
void setStateValues (SimTK::State &state, const double *stateValues) const
 Set the values of state variables which are passed in the same ordering as returned by getStateVariableNames(). More...
 
int getNumMuscleStates () const
 
int getNumProbeStates () const
 
CoordinateSetupdCoordinateSet ()
 
const CoordinateSetgetCoordinateSet () const
 
BodySetupdBodySet ()
 
const BodySetgetBodySet () const
 
JointSetupdJointSet ()
 
const JointSetgetJointSet () const
 
AnalysisSetupdAnalysisSet ()
 
const AnalysisSetgetAnalysisSet () const
 
ContactGeometrySetupdContactGeometrySet ()
 
const ContactGeometrySetgetContactGeometrySet () const
 
BodygetGroundBody () const
 
ConstraintSetupdConstraintSet ()
 
const ConstraintSetgetConstraintSet () const
 
MarkerSetupdMarkerSet ()
 
const MarkerSetgetMarkerSet () const
 
int replaceMarkerSet (const SimTK::State &s, MarkerSet &aMarkerSet)
 
void writeMarkerFile (const std::string &aFileName) const
 
void updateMarkerSet (MarkerSet &aMarkerSet)
 
int deleteUnusedMarkers (const Array< std::string > &aMarkerNames)
 
void addAnalysis (Analysis *analysis)
 Add an Analysis to the Model. More...
 
void addController (Controller *aController)
 Add a Controller to the Model. More...
 
void removeAnalysis (Analysis *analysis, bool deleteIt=true)
 Remove an Analysis from the Model. More...
 
void removeController (Controller *aController)
 Remove a Controller from the Model. More...
 
bool scale (SimTK::State &state, const ScaleSet &scaleSet, double finalMass=-1.0, bool preserveMassDist=false)
 Scale the model. More...
 
void printBasicInfo (std::ostream &aOStream) const
 Print some basic information about the model. More...
 
void printDetailedInfo (const SimTK::State &s, std::ostream &aOStream) const
 Print detailed information about the model. More...
 
void disownAllComponents ()
 Model relinquishes ownership of all components such as: Bodies, Constraints, Forces, ConactGeometry and so on. More...
 
void overrideAllActuators (SimTK::State &s, bool flag)
 Convenice function to turn on/off overriding the force for all actuators. More...
 
const std::string & getValidationLog ()
 Get a log of errors/warnings ecountered when loading/constructing the model. More...
 
void clearValidationLog ()
 
const ObjectgetObjectByTypeAndName (const std::string &typeString, const std::string &nameString) SWIG_DECLARE_EXCEPTION
 Utility to get a reference to an Object based on its name and type throws an exception if the object was not found. More...
 
Visualization

Methods in this group affect visualization of this Model, which may be through the OpenSim GUI or through the use of a ModelVisualizer which can provide limited run-time display and user interaction capability for an OpenSim API-based program.

If you enable visualization at the API level, the Model will create a ModelVisualizer that you can use to control display and user interaction. In turn, the ModelVisualizer makes use of a Simbody SimTK::Visualizer; for advanced features you can ask the ModelVisualizer to give you direct access to the SimTK::Visualizer; consult Simbody documentation for more details.

const ModelDisplayHintsgetDisplayHints () const
 Get read only access to the ModelDisplayHints object stored with this Model. More...
 
ModelDisplayHintsupdDisplayHints ()
 Get writable access to the ModelDisplayHints object stored with this Model. More...
 
void setUseVisualizer (bool visualize)
 Request or suppress visualization of this Model. More...
 
bool getUseVisualizer () const
 Return the current setting of the "use visualizer" flag, which will take effect at the next call to initSystem() on this Model. More...
 
bool hasVisualizer () const
 Test whether a ModelVisualizer has been created for this Model. More...
 
const ModelVisualizergetVisualizer () const
 Obtain read-only access to the ModelVisualizer. More...
 
ModelVisualizerupdVisualizer ()
 Obtain writable access to the ModelVisualizer. More...
 
Access to the Simbody System and components

Methods in this section provide advanced users access to the underlying Simbody System and associated subcomponents that are constructed and maintained by this Model.

Note that these are not available until after initSystem() has been invoked on this Model. Be very careful if you call any of the upd() methods since modifying a System after the Model creates it can require reinitialization.

See Also
initStateWithoutRecreatingSystem()
const SimTK::MultibodySystemgetMultibodySystem () const
 Get read-only access to the internal Simbody MultibodySystem that was created by this Model at the last initSystem() call. More...
 
SimTK::MultibodySystemupdMultibodySystem () const
 (Advanced) Get writable access to the internal Simbody MultibodySystem that was created by this Model at the last initSystem() call. More...
 
const
SimTK::DefaultSystemSubsystem
getDefaultSubsystem () const
 Get read-only access to the internal DefaultSystemSubsystem allocated by this Model's Simbody MultibodySystem. More...
 
SimTK::DefaultSystemSubsystemupdDefaultSubsystem ()
 (Advanced) Get writable access to the internal DefaultSystemSubsystem allocated by this Model's Simbody MultibodySystem. More...
 
const
SimTK::SimbodyMatterSubsystem
getMatterSubsystem () const
 Get read-only access to the internal SimbodyMatterSubsystem allocated by this Model. More...
 
SimTK::SimbodyMatterSubsystemupdMatterSubsystem ()
 (Advanced) Get writable access to the internal SimbodyMatterSubsystem allocated by this Model. More...
 
const SimTK::Force::GravitygetGravityForce () const
 Get read-only access to the Simbody Force::Gravity element that was allocated by this Model. More...
 
SimTK::Force::GravityupdGravityForce ()
 (Advanced) Get writable access to the Simbody Force::Gravity element that was allocated by this Model. More...
 
const
SimTK::GeneralForceSubsystem
getForceSubsystem () const
 Get read-only access to the internal Simbody GeneralForceSubsystem allocated by this Model. More...
 
SimTK::GeneralForceSubsystemupdForceSubsystem ()
 (Advanced) Get writable access to the internal Simbody GeneralForceSubsystem allocated by this Model. More...
 
Implementation of Object interface

These methods are Model's implementation of virtual methods defined in the Object class from which Model derives (indirectly through ModelComponent).

 ~Model ()
 Destructor. More...
 
void updateFromXMLNode (SimTK::Xml::Element &aNode, int versionNumber=-1)
 Override of the default implementation to account for versioning. More...
 
Implementation of ModelComponent interface

These methods are Model's implementation of virtual methods defined in the ModelComponent class from which Model derives.

The implementations here serve as dispatchers that treat all contained ModelComponents (and model elements that are not ModelComponents) as subcomponents whose corresponding methods need to be called.

void connectToModel (Model &model) override
 Perform any necessary initializations required to connect the component into the Model, and check for error conditions. More...
 
void addToSystem (SimTK::MultibodySystem &system) const override
 Add appropriate Simbody elements (if needed) to the System corresponding to this component and specify needed state resources. More...
 
void initStateFromProperties (SimTK::State &state) const override
 Transfer property values or other state-independent initial values into this component's state variables in the passed-in state argument. More...
 
void setPropertiesFromState (const SimTK::State &state) override
 Given a State, set all default values for this Model to match those found in the State. More...
 
void generateDecorations (bool fixed, const ModelDisplayHints &hints, const SimTK::State &state, SimTK::Array_< SimTK::DecorativeGeometry > &appendToThis) const override
 Optional method for generating arbitrary display geometry that reflects this ModelComponent at the specified state. More...
 
Array< std::string > getStateVariableNames () const
 Get the names of the states. More...
 
const Array
< SimTK::SystemYIndex > & 
getStateVariableSystemIndices () const
 
double getStateVariable (const SimTK::State &s, const std::string &name) const
 Get the value of a state variable of this Model. More...
 
void setStateVariable (SimTK::State &s, const std::string &name, double value) const
 Set the value of a state variable of this Model. More...
 
SimTK::SystemYIndex getStateVariableSystemIndex (const std::string &stateVariableName) const
 Get the Y index of a state variable by name. More...
 
- Public Member Functions inherited from OpenSim::ModelComponent
 ModelComponent ()
 Default constructor. More...
 
 ModelComponent (const std::string &aFileName, bool aUpdateFromXMLNode=true) SWIG_DECLARE_EXCEPTION
 Construct ModelComponent from an XML file. More...
 
 ModelComponent (SimTK::Xml::Element &aNode)
 Construct ModelComponent from a specific node in an XML document. More...
 
 ModelComponent (const ModelComponent &source)
 Construct ModelComponent with its contents copied from another ModelComponent; this is a deep copy so nothing is shared with the source after the copy. More...
 
virtual ~ModelComponent ()
 Destructor is virtual to allow concrete model component cleanup. More...
 
ModelComponentoperator= (const ModelComponent &aModelComponent)
 Assignment operator to copy contents of an existing component. More...
 
const ModelgetModel () const
 Get a const reference to the Model this component is part of. More...
 
ModelupdModel ()
 Get a modifiable reference to the Model this component is part of. More...
 
virtual void updateDisplayer (const SimTK::State &s) const
 In case the ModelComponent has a visual representation (VisualObject), override this method to update it. More...
 
int getModelingOption (const SimTK::State &state, const std::string &name) const
 Get a ModelingOption flag for this ModelComponent by name. More...
 
void setModelingOption (SimTK::State &state, const std::string &name, int flag) const
 Set the value of a ModelingOption flag for this ModelComponent. More...
 
double getStateVariable (const SimTK::State &state, const std::string &name) const
 Get the value of a state variable allocated by this ModelComponent. More...
 
void setStateVariable (SimTK::State &state, const std::string &name, double value) const
 Set the value of a state variable allocated by this ModelComponent by name. More...
 
double getDiscreteVariable (const SimTK::State &state, const std::string &name) const
 Get the value of a discrete variable allocated by this ModelComponent by name. More...
 
void setDiscreteVariable (SimTK::State &state, const std::string &name, double value) const
 Set the value of a discrete variable allocated by this ModelComponent by name. More...
 
template<typename T >
const T & getCacheVariable (const SimTK::State &state, const std::string &name) const
 Get the value of a cache variable allocated by this ModelComponent by name. More...
 
template<typename T >
const T & getCacheVariable (const SimTK::State &state, SimTK::CacheEntryIndex ceIndex) const
 
template<typename T >
T & updCacheVariable (const SimTK::State &state, const std::string &name) const
 Obtain a writable cache variable value allocated by this ModelComponent by name. More...
 
template<typename T >
T & updCacheVariable (const SimTK::State &state, SimTK::CacheEntryIndex ceIndex) const
 
void markCacheVariableValid (const SimTK::State &state, const std::string &name) const
 After updating a cache variable value allocated by this ModelComponent, you can mark its value as valid, which will not change until the realization stage falls below the minimum set at the time the cache variable was created. More...
 
void markCacheVariableValid (const SimTK::State &state, SimTK::CacheEntryIndex ceIndex) const
 
void markCacheVariableInvalid (const SimTK::State &state, const std::string &name) const
 Mark a cache variable value allocated by this ModelComponent as invalid. More...
 
void markCacheVariableInvalid (const SimTK::State &state, SimTK::CacheEntryIndex ceIndex) const
 
bool isCacheVariableValid (const SimTK::State &state, const std::string &name) const
 Enables the to monitor the validity of the cache variable value using the returned flag. More...
 
bool isCacheVariableValid (const SimTK::State &state, SimTK::CacheEntryIndex ceIndex) const
 
template<typename T >
void setCacheVariable (const SimTK::State &state, const std::string &name, const T &value) const
 Set cache variable value allocated by this ModelComponent by name. More...
 
template<typename T >
void setCacheVariable (const SimTK::State &state, SimTK::CacheEntryIndex ceIndex, const T &value) const
 
- Public Member Functions inherited from OpenSim::Object
virtual ~Object ()
 Virtual destructor for cleanup. More...
 
virtual Objectclone () const =0
 Create a new heap-allocated copy of the concrete object to which this Object refers. More...
 
virtual const std::string & getConcreteClassName () const =0
 Returns the class name of the concrete Object-derived class of the actual object referenced by this Object, as a string. More...
 
virtual const VisibleObjectgetDisplayer () const
 Methods to support making the object displayable in the GUI or Visualizer Implemented only in few objects. More...
 
virtual VisibleObjectupdDisplayer ()
 get Non const pointer to VisibleObject More...
 
bool isEqualTo (const Object &aObject) const
 Equality operator wrapper for use from languages not supporting operator overloading. More...
 
Objectoperator= (const Object &aObject)
 Copy assignment copies he base class fields, including the properties. More...
 
virtual bool operator== (const Object &aObject) const
 Determine if two objects are equal. More...
 
virtual bool operator< (const Object &aObject) const
 Provide an ordering for objects so they can be put in sorted containers. More...
 
void setName (const std::string &name)
 Set the name of the Object. More...
 
const std::string & getName () const
 Get the name of this Object. More...
 
void setDescription (const std::string &description)
 Set description, a one-liner summary. More...
 
const std::string & getDescription () const
 Get description, a one-liner summary. More...
 
const std::string & getAuthors () const
 Get Authors of this Object. More...
 
void setAuthors (const std::string &authors)
 Set Authors of this object, call this method in your constructor if needed. More...
 
const std::string & getReferences () const
 Get references or publications to cite if using this object. More...
 
void setReferences (const std::string &references)
 Set references or publications to cite if using this object. More...
 
int getNumProperties () const
 Determine how many properties are stored with this Object. More...
 
const AbstractPropertygetPropertyByIndex (int propertyIndex) const
 Get a const reference to a property by its index number, returned as an AbstractProperty. More...
 
AbstractPropertyupdPropertyByIndex (int propertyIndex)
 Get a writable reference to a property by its index number, returned as an AbstractProperty. More...
 
bool hasProperty (const std::string &name) const
 Return true if this Object has a property of any type with the given name, which must not be empty. More...
 
const AbstractPropertygetPropertyByName (const std::string &name) const
 Get a const reference to a property by its name, returned as an AbstractProperty. More...
 
AbstractPropertyupdPropertyByName (const std::string &name)
 Get a writable reference to a property by its name, returned as an AbstractProperty. More...
 
template<class T >
bool hasProperty () const
 Return true if this Object contains an unnamed, one-object property that contains objects of the given template type T. More...
 
template<class T >
const Property< T > & getProperty (const PropertyIndex &index) const
 Get property of known type Property<T> as a const reference; the property must be present and have the right type. More...
 
template<class T >
Property< T > & updProperty (const PropertyIndex &index)
 Get property of known type Property<T> as a writable reference; the property must be present and have the right type. More...
 
void setObjectIsUpToDateWithProperties ()
 When an object is initialized using the current values of its properties, it can set a flag indicating that it is up to date. More...
 
bool isObjectUpToDateWithProperties () const
 Returns true if no property's value has changed since the last time setObjectIsUpToDateWithProperties() was called. More...
 
void readObjectFromXMLNodeOrFile (SimTK::Xml::Element &objectElement, int versionNumber)
 We're given an XML element from which we are to populate this Object. More...
 
virtual void updateXMLNode (SimTK::Xml::Element &parent)
 Serialize this object into the XML node that represents it. More...
 
bool getInlined () const
 Inlined means an in-memory Object that is not associated with an XMLDocument. More...
 
void setInlined (bool aInlined, const std::string &aFileName="")
 Mark this as inlined or not and optionally provide a file name to associate with the new XMLDocument for the non-inline case. More...
 
std::string getDocumentFileName () const
 If there is a document associated with this object then return the file name maintained by the document. More...
 
void setAllPropertiesUseDefault (bool aUseDefault)
 
bool print (const std::string &fileName)
 Write this Object into an XML file of the given name; conventionally the suffix to use is ".osim". More...
 
std::string dump (bool dumpName=false)
 dump the XML representation of this Object into an std::string and return it. More...
 
void clearObjectIsUpToDateWithProperties ()
 For testing or debugging purposes, manually clear the "object is up to date with respect to properties" flag. More...
 
virtual bool isA (const char *type) const
 The default implementation returns true only if the supplied string is "Object"; each Object-derived class overrides this to match its own class name. More...
 
const std::string & toString () const
 Wrapper to be used on Java side to display objects in tree; this returns just the object's name. More...
 
PropertySetgetPropertySet ()
 OBSOLETE: Get a reference to the PropertySet maintained by the Object. More...
 
const PropertySetgetPropertySet () const
 

Friends

class ModelComponent
 

Additional Inherited Members

- Static Public Member Functions inherited from OpenSim::Object
static void registerType (const Object &defaultObject)
 Register an instance of a class; if the class is already registered it will be replaced. More...
 
static void renameType (const std::string &oldTypeName, const std::string &newTypeName)
 Support versioning by associating the current Object type with an old name. More...
 
static const ObjectgetDefaultInstanceOfType (const std::string &concreteClassName)
 Return a pointer to the default instance of the registered (concrete) Object whose class name is given, or NULL if the type is not registered. More...
 
template<class T >
static bool isObjectTypeDerivedFrom (const std::string &concreteClassName)
 Return true if the given concrete object type represents a subclass of the template object type T, and thus could be referenced with a T*. More...
 
static ObjectnewInstanceOfType (const std::string &concreteClassName)
 Create a new instance of the concrete Object type whose class name is given as concreteClassName. More...
 
static void getRegisteredTypenames (Array< std::string > &typeNames)
 Retrieve all the typenames registered so far. More...
 
template<class T >
static void getRegisteredObjectsOfGivenType (ArrayPtrs< T > &rArray)
 Return an array of pointers to the default instances of all registered (concrete) Object types that derive from a given Object-derived type that does not have to be concrete. More...
 
static void PrintPropertyInfo (std::ostream &os, const std::string &classNameDotPropertyName)
 Dump formatted property information to a given output stream, useful for creating a "help" facility for registered objects. More...
 
static void PrintPropertyInfo (std::ostream &os, const std::string &className, const std::string &propertyName)
 Same as the other signature but the class name and property name are provided as two separate strings. More...
 
static ObjectmakeObjectFromFile (const std::string &fileName)
 Create an OpenSim object whose type is based on the tag at the root node of the XML file passed in. More...
 
static const std::string & getClassName ()
 Return the name of this class as a string; i.e., "Object". More...
 
static void setSerializeAllDefaults (bool shouldSerializeDefaults)
 Static function to control whether all registered objects and their properties are written to the defaults section of output files rather than only those values for which the default was explicitly overwritten when read in from an input file or set programmatically. More...
 
static bool getSerializeAllDefaults ()
 Report the value of the "serialize all defaults" flag. More...
 
static bool isKindOf (const char *type)
 Returns true if the passed-in string is "Object"; each Object-derived class defines a method of this name for its own class name. More...
 
static void setDebugLevel (int newLevel)
 Set the debug level to get verbose output. More...
 
static int getDebugLevel ()
 Get current setting of debug level. More...
 
static ObjectSafeCopy (const Object *aObject)
 Use the clone() method to duplicate the given object unless the pointer is null in which case null is returned. More...
 
static void RegisterType (const Object &defaultObject)
 OBSOLETE alternate name for registerType(). More...
 
static void RenameType (const std::string &oldName, const std::string &newName)
 OBSOLETE alternate name for renameType(). More...
 
- Static Public Attributes inherited from OpenSim::Object
static const std::string DEFAULT_NAME
 Name used for default objects when they are serialized. More...
 
- Protected Member Functions inherited from OpenSim::ModelComponent
virtual void realizeTopology (SimTK::State &state) const
 Obtain state resources that are needed unconditionally, and perform computations that depend only on the system topology. More...
 
virtual void realizeModel (SimTK::State &state) const
 Obtain state resources that may be needed, depending on modeling options, and perform computations that depend only on topology and selected modeling options. More...
 
virtual void realizeInstance (const SimTK::State &state) const
 Perform computations that depend only on instance variables, like lengths and masses. More...
 
virtual void realizeTime (const SimTK::State &state) const
 Perform computations that depend only on time and earlier stages. More...
 
virtual void realizePosition (const SimTK::State &state) const
 Perform computations that depend only on position-level state variables and computations performed in earlier stages (including time). More...
 
virtual void realizeVelocity (const SimTK::State &state) const
 Perform computations that depend only on velocity-level state variables and computations performed in earlier stages (including position, and time). More...
 
virtual void realizeDynamics (const SimTK::State &state) const
 Perform computations (typically forces) that may depend on dynamics-stage state variables, and on computations performed in earlier stages (including velocity, position, and time), but not on other forces, accelerations, constraint multipliers, or reaction forces. More...
 
virtual void realizeAcceleration (const SimTK::State &state) const
 Perform computations that may depend on applied forces. More...
 
virtual void realizeReport (const SimTK::State &state) const
 Perform computations that may depend on anything but are only used for reporting and cannot affect subsequent simulation behavior. More...
 
void includeAsSubComponent (ModelComponent *aComponent)
 Include another ModelComponent as a Subcomponent of this ModelComponent. More...
 
void addModelingOption (const std::string &optionName, int maxFlagValue) const
 Add a modeling option (integer flag stored in the State) for use by this ModelComponent. More...
 
void addStateVariable (const std::string &stateVariableName, SimTK::Stage invalidatesStage=SimTK::Stage::Dynamics) const
 Add a continuous system state variable belonging to this ModelComponent, and assign a name by which to refer to it. More...
 
void addDiscreteVariable (const std::string &discreteVariableName, SimTK::Stage invalidatesStage) const
 Add a system discrete variable belonging to this ModelComponent, give it a name by which it can be referenced, and declare the lowest Stage that should be invalidated if this variable's value is changed. More...
 
template<class T >
void addCacheVariable (const std::string &cacheVariableName, const T &variablePrototype, SimTK::Stage dependsOnStage) const
 Add a state cache entry belonging to this ModelComponent to hold calculated values that must be automatically invalidated when certain state values change. More...
 
const int getStateIndex (const std::string &name) const
 Get the index of a ModelComponent's continuous state variable in the Subsystem for allocations. More...
 
const SimTK::DiscreteVariableIndex getDiscreteVariableIndex (const std::string &name) const
 Get the index of a ModelComponent's discrete variable in the Subsystem for allocations. More...
 
const SimTK::CacheEntryIndex getCacheVariableIndex (const std::string &name) const
 Get the index of a ModelComponent's cache variable in the Subsystem for allocations. More...
 
- Protected Member Functions inherited from OpenSim::Object
 Object ()
 The default constructor is only for use by constructors of derived types. More...
 
 Object (const std::string &fileName, bool aUpdateFromXMLNode=true) SWIG_DECLARE_EXCEPTION
 Constructor from a file, to be called from other constructors that take a file as input. More...
 
 Object (const Object &source)
 Copy constructor is invoked automatically by derived classes with default copy constructors; otherwise it must be invoked explicitly. More...
 
 Object (SimTK::Xml::Element &aElement)
 Construct the base class portion of an Object from a given Xml element that describes this Object. More...
 
template<class T >
PropertyIndex addProperty (const std::string &name, const std::string &comment, const T &value)
 Define a new single-value property of known type T, with the given name, associated comment, and initial value. More...
 
template<class T >
PropertyIndex addOptionalProperty (const std::string &name, const std::string &comment)
 Add an optional property, meaning it can contain either no value or a single value. More...
 
template<class T >
PropertyIndex addOptionalProperty (const std::string &name, const std::string &comment, const T &value)
 Add an optional property, meaning it can contain either no value or a single value. More...
 
template<class T >
PropertyIndex addListProperty (const std::string &name, const std::string &comment, int minSize, int maxSize)
 Define a new list-valued property of known type T, with the given name, associated comment, minimum (==0) and maximum (>0) allowable list lengths, and a zero-length initial value. More...
 
template<class T , template< class > class Container>
PropertyIndex addListProperty (const std::string &name, const std::string &comment, int minSize, int maxSize, const Container< T > &valueList)
 Define a new list-valued property as above, but assigning an initial value via some templatized container class that supports size() and indexing. More...
 
PropertyIndex getPropertyIndex (const std::string &name) const
 Look up a property by name and return its PropertyIndex if it is found. More...
 
template<class T >
PropertyIndex getPropertyIndex () const
 Look up an unnamed property by the type of object it contains, and return its PropertyIndex if it is found. More...
 
void updateFromXMLDocument ()
 Use this method only if you're deserializing from a file and the object is at the top level; that is, primarily in constructors that take a file name as input. More...
 
void setDocument (XMLDocument *doc)
 Unconditionally set the XMLDocument associated with this object. More...
 
const XMLDocumentgetDocument () const
 Get a const pointer to the document (if any) associated with this object. More...
 
XMLDocumentupdDocument ()
 Get a writable pointer to the document (if any) associated with this object. More...
 
- Protected Attributes inherited from OpenSim::ModelComponent
Model_model
 The model this component belongs to. More...
 
- Protected Attributes inherited from OpenSim::Object
PropertySet _propertySet
 OBSOLETE: Property_Deprecated set for serializable member variables of this and derived classes. More...
 

Detailed Description

A concrete class that specifies the interface to a musculoskeletal model.

You can read this in from an XML file or create it programmatically, and modify it via the API.

A Model contains ModelComponents, and is itself a ModelComponent so must satisfy the ModelComponent interface, as well as the Object interface from which ModelComponent derives. This allows a Model to allocate "global" resources using ModelComponent resource-allocation facilities.

Computation using a Model is done by creating a computational representation of the Model, called a System (SimTK::System), using Simbody. Creation of the System is initiated by a call to the Model's initSystem() method. The System and related objects are maintained in a runtime section of the Model object. You can also ask a Model to provide visualization using the setUseVisualizer() method, in which case it will allocate an maintain a ModelVisualizer.

Authors
Frank Anderson, Peter Loan, Ayman Habib, Ajay Seth, Michael Sherman
See Also
ModelComponent, ModelVisualizer, SimTK::System

Constructor & Destructor Documentation

OpenSim::Model::Model ( )

Default constructor creates a Model containing only the ground Body and a set of default properties.

OpenSim::Model::Model ( const std::string &  filename,
bool  connectToModel = true 
)
explicit

Constructor from an OpenSim XML model file.

Parameters
filenameName of a file containing an OpenSim model in XML format; suffix is typically ".osim".
connectToModelwhether to call connectToModel to create a valid OpenSim Model or not on exit, defaults to true. If set to false only deserialization is performed.
OpenSim::Model::Model ( const Model source)

Copy constructor copies model components but does not copy any run-time objects.

Parameters
sourceThe Model to be copied.
OpenSim::Model::~Model ( )

Destructor.

Member Function Documentation

void OpenSim::Model::addAnalysis ( Analysis analysis)

Add an Analysis to the Model.

Parameters
analysispointer to the Analysis to add
void OpenSim::Model::addBody ( Body aBody)
void OpenSim::Model::addComponent ( ModelComponent aComponent)

Add ModelComponents to the Model.

Model takes ownership of the objects.

void OpenSim::Model::addConstraint ( Constraint aConstraint)
void OpenSim::Model::addContactGeometry ( ContactGeometry aContactGeometry)
void OpenSim::Model::addController ( Controller aController)

Add a Controller to the Model.

void OpenSim::Model::addForce ( Force aForce)
void OpenSim::Model::addProbe ( Probe aProbe)
void OpenSim::Model::addToSystem ( SimTK::MultibodySystem system) const
overridevirtual

Add appropriate Simbody elements (if needed) to the System corresponding to this component and specify needed state resources.

addToSystem() is called when the Simbody System is being created to represent a completed Model for computation. That is, connectToModel() will already have been invoked on all components before any addToSystem() call is made. Helper methods for adding modeling options, state variables and their derivatives, discrete variables, and cache entries are available and can be called within addToSystem() only.

Note that this method is const; you must not modify your model component or the containing model during this call. Any modifications you need should instead be performed in connectToModel(), which is non-const. One exception is that you may need to record access information for resources you create in the system, such as an index number. You should declare those data members mutable so that you can set them here.

If you override this method, be sure to invoke the base class method first, using code like this:

void MyComponent::addToSystem(SimTK::MultibodySystem& system) const {
Super::addToSystem(system); // invoke parent class method
// ... your code goes here
}
Parameters
[in,out]systemThe System being created.
See Also
addModelingOption(), addStateVariable(), addDiscreteVariables(), addCacheVariable()

Reimplemented from OpenSim::ModelComponent.

void OpenSim::Model::applyDefaultConfiguration ( SimTK::State s)
void OpenSim::Model::assemble ( SimTK::State state,
const Coordinate coord = NULL,
double  weight = 10 
)

Find the kinematic state of the model that satisfies constraints and coordinate goals If assemble is being called due to a coordinate set value, provide the option to weight that coordinate value more heavily if specified.

void OpenSim::Model::buildSystem ( )

After the Model and its components have been constructed, call this to interconnect the components and then create the Simbody MultibodySystem needed to represent the Model computationally.

The connectToModel() method of each contained ModelComponent will be invoked, and then their addToSystem() methods are invoked. The resulting MultibodySystem is maintained internally by the Model. After this call, you may obtain a writable reference to the System using updMultibodySystem() which you can use to make any additions you want. Then when the System is complete, call initializeState() to finalize it and obtain an initial State.

SimTK::Vec3 OpenSim::Model::calcMassCenterAcceleration ( const SimTK::State s) const
SimTK::Vec3 OpenSim::Model::calcMassCenterPosition ( const SimTK::State s) const
SimTK::Vec3 OpenSim::Model::calcMassCenterVelocity ( const SimTK::State s) const
void OpenSim::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.

void OpenSim::Model::clearValidationLog ( )
inline
void OpenSim::Model::computeControls ( const SimTK::State state,
SimTK::Vector controls 
) const

Compute the controls for the model.

Calls down to the Controllers to make their contributions to the controls.

Parameters
[in]stateSystem state from which Controllers should draw when computing their control outputs.
[out]controlsThe complete vector of controls into which individual controller contributions should be added.
SimTK::Vector OpenSim::Model::computeStateVariableDerivatives ( const SimTK::State s) const
virtual

If a model component has allocated any continuous state variables using the addStateVariable() method, then computeStateVariableDerivatives() must be implemented to provide time derivatives for those states.

Override to return a Vector of the same size as the number of state variables defined and in order added to the system (also

See Also
addToSystem()). Default returns empty (no derivatives are defined). Implement like this:
SimTK::Vector computeStateVariableDerivatives(const SimTK::State& s) const {
// Collect derivatives from parent class and above first.
SimTK::Vector derivs = Super::computeStateVariableDerivatives(s);
const int n = derivs.size();
derivs.resizeKeep(n + myNumStateVariables); // grow
for (int i=0; i < myNumStateVariables; ++i)
derivs[n+i] = ...; // i'th state variable derivative
return derivs;
}
This method is invoked from the base class realizeAcceleration() method.

Reimplemented from OpenSim::ModelComponent.

void OpenSim::Model::connectToModel ( Model model)
inlineoverridevirtual

Perform any necessary initializations required to connect the component into the Model, and check for error conditions.

connectToModel() is invoked on all components to complete construction of a Model, prior to creating a Simbody System to represent it computationally. It may also be invoked at times just for its error-checking side effects.

If you override this method, be sure to invoke the base class method first, using code like this:

void MyComponent::connectToModel(Model& model) {
Super::connectToModel(model); // invoke parent class method
// ... your code goes here
}

Note that this method is expected to check for modeling errors and should throw an OpenSim::Exception if there is something wrong. For example, if your model component references another object by name, you should verify that it exists in the supplied Model, which is not guaranteed since components may be independently instantiated or constructed from XML files.

Parameters
[in,out]modelThe Model currently being constructed to which this ModelComponent should be connected.

Reimplemented from OpenSim::ModelComponent.

References OVERRIDE_11.

void OpenSim::Model::copyDefaultStateIntoWorkingState ( )

Method to copy a model's default state into the space allocated for its working state.

This is so that the default state does not get corrupted.

int OpenSim::Model::deleteUnusedMarkers ( const Array< std::string > &  aMarkerNames)
void OpenSim::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 OpenSim::Model::equilibrateMuscles ( SimTK::State state)

Update the state of all Muscles so they are in equilibrium.

void OpenSim::Model::formQStorage ( const Storage originalStorage,
Storage qStorage 
)
void OpenSim::Model::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 OpenSim::Model::generateDecorations ( bool  fixed,
const ModelDisplayHints hints,
const SimTK::State state,
SimTK::Array_< SimTK::DecorativeGeometry > &  appendToThis 
) const
overridevirtual

Optional method for generating arbitrary display geometry that reflects this ModelComponent at the specified state.

This will be called once to obtain ground- and body-fixed geometry (with fixed=true), and then once per frame (with fixed=false) to generate on-the-fly geometry such as rubber band lines, force arrows, labels, or debugging aids.

If you override this method, be sure to invoke the base class method first, using code like this:

void MyComponent::generateDecorations
(bool fixed,
const ModelDisplayHints& hints,
const SimTK::State& state,
{
// invoke parent class method
Super::generateDecorations(fixed,hints,state,appendToThis);
// ... your code goes here
}
Parameters
[in]fixedIf true, generate only geometry that is independent of time, configuration, and velocity. Otherwise generate only such dependent geometry.
[in]hintsSee documentation for ModelDisplayHints; you may want to alter the geometry you generate depending on what you find there. For example, you can determine whether the user wants to see debug geometry.
[in]stateThe State for which geometry should be produced. See below for more information.
[in,out]appendToThisArray to which generated geometry should be appended via the push_back() method.

When called with fixed=true only modeling options and parameters (Instance variables) should affect geometry; time, position, and velocity should not. In that case OpenSim will already have realized the state through Instance stage. When called with fixed=false, you may consult any relevant value in state. However, to avoid unnecessary computation, OpenSim guarantees only that state will have been realized through Position stage; if you need anything higher than that (reaction forces, for example) you should make sure the state is realized through Acceleration stage.

Reimplemented from OpenSim::ModelComponent.

const Set<Actuator>& OpenSim::Model::getActuators ( ) const

Get the subset of Forces in the model which are actuators.

Returns
The set of Actuators
bool OpenSim::Model::getAllControllersEnabled ( ) const
const AnalysisSet& OpenSim::Model::getAnalysisSet ( ) const
inline
const BodySet& OpenSim::Model::getBodySet ( ) const
inline
const ConstraintSet& OpenSim::Model::getConstraintSet ( ) const
inline
const ContactGeometrySet& OpenSim::Model::getContactGeometrySet ( ) const
inline
const ControllerSet& OpenSim::Model::getControllerSet ( ) const
const SimTK::Vector& OpenSim::Model::getControls ( const SimTK::State s) const

Const access to controls does not invalidate dynamics.

const CoordinateSet& OpenSim::Model::getCoordinateSet ( ) const
inline
const std::string& OpenSim::Model::getCredits ( ) const
inline

Get the credits (e.g., model author names) associated with the model.

Returns
Credits string.
const SimTK::Vector& OpenSim::Model::getDefaultControls ( ) const
inline
const SimTK::DefaultSystemSubsystem& OpenSim::Model::getDefaultSubsystem ( ) const
inline

Get read-only access to the internal DefaultSystemSubsystem allocated by this Model's Simbody MultibodySystem.

const ModelDisplayHints& OpenSim::Model::getDisplayHints ( ) const
inline

Get read only access to the ModelDisplayHints object stored with this Model.

These should be checked whenever display geometry is being generated.

const ForceSet& OpenSim::Model::getForceSet ( ) const
inline
const SimTK::GeneralForceSubsystem& OpenSim::Model::getForceSubsystem ( ) const
inline

Get read-only access to the internal Simbody GeneralForceSubsystem allocated by this Model.

const Units& OpenSim::Model::getForceUnits ( ) const
inline

Get the force units associated with the model.

Returns
Force units
SimTK::Vec3 OpenSim::Model::getGravity ( ) const

Get the gravity vector in the global frame.

Returns
The XYZ gravity vector in the global frame.
const SimTK::Force::Gravity& OpenSim::Model::getGravityForce ( ) const
inline

Get read-only access to the Simbody Force::Gravity element that was allocated by this Model.

Body& OpenSim::Model::getGroundBody ( ) const
SimTK::Inertia OpenSim::Model::getInertiaAboutMassCenter ( const SimTK::State s) const
const std::string& OpenSim::Model::getInputFileName ( ) const
inline

Get the XML file name used to construct the model.

Returns
XML file name string.
const JointSet& OpenSim::Model::getJointSet ( ) const
const Units& OpenSim::Model::getLengthUnits ( ) const
inline

Get the length units associated with the model.

Returns
Length units.
const MarkerSet& OpenSim::Model::getMarkerSet ( ) const
inline
const SimTK::SimbodyMatterSubsystem& OpenSim::Model::getMatterSubsystem ( ) const
inline

Get read-only access to the internal SimbodyMatterSubsystem allocated by this Model.

const ComponentSet& OpenSim::Model::getMiscModelComponentSet ( ) const
inline

Get the subset of misc ModelComponents in the model.

Returns
The set of misc ModelComponents
const SimTK::MultibodySystem& OpenSim::Model::getMultibodySystem ( ) const
inline

Get read-only access to the internal Simbody MultibodySystem that was created by this Model at the last initSystem() call.

const Set<Muscle>& OpenSim::Model::getMuscles ( ) const

Get the subset of Forces in the model which are muscles.

Returns
The set of Muscles
int OpenSim::Model::getNumAnalyses ( ) const

Get the number of analyses in the model.

Returns
The number of analyses.
int OpenSim::Model::getNumBodies ( ) const

Get the total number of bodies in the model.

Returns
Number of bodies.
int OpenSim::Model::getNumContactGeometries ( ) const

Get the number of ContactGeometries in the model.

Returns
Number of ContactGeometries.
int OpenSim::Model::getNumControls ( ) const

Get the number of controls for this the model.

Only valid once underlying system for the model has been created. Throws an exception if called before Model::initSystem()

Returns
number of controls corresponding to all the actuators in the model
int OpenSim::Model::getNumCoordinates ( ) const

Get the total number of coordinates in the model.

Returns
Number of coordinates.
int OpenSim::Model::getNumJoints ( ) const

Get the total number of joints in the model.

Returns
Number of joints.
int OpenSim::Model::getNumMarkers ( ) const

Get the number of markers in the model.

Returns
Number of markers.
int OpenSim::Model::getNumMuscleStates ( ) const
int OpenSim::Model::getNumProbes ( ) const

Get the total number of probes in the model.

Returns
Number of probes.
int OpenSim::Model::getNumProbeStates ( ) const
int OpenSim::Model::getNumSpeeds ( ) const

Get the total number of speeds in the model.

Returns
Number of speeds.
virtual int OpenSim::Model::getNumStateVariables ( ) const
virtual

Get the number of "Continuous" state variables maintained by the ModelComponent and its specified subcomponents.

Reimplemented from OpenSim::ModelComponent.

const Object& OpenSim::Model::getObjectByTypeAndName ( const std::string &  typeString,
const std::string &  nameString 
)

Utility to get a reference to an Object based on its name and type throws an exception if the object was not found.

names are case sensitive

Parameters
typeStringthe type of object being looked up (Body, Force, Constraint, Coordinate, Joint, Marker, Controller)
nameStringthe name of the object being looked up
Returns
reference to the object if found or throws an exception.
const ProbeSet& OpenSim::Model::getProbeSet ( ) const
inline

Get the subset of Probes in the model.

Returns
The set of Probes
const std::string& OpenSim::Model::getPublications ( ) const
inline

Get the publications associated with the model.

Returns
Publications string.
const SimbodyEngine& OpenSim::Model::getSimbodyEngine ( ) const
inline

Get the model's dynamics engine.

Returns
Reference to the Simbody dynamics engine
void OpenSim::Model::getStateValues ( const SimTK::State state,
Array< double > &  stateValues 
) const

Get the values of state variables in the same ordering as returned by getStateVariableNames().

Values are dug out from the passed-in state based on Y-indices that are associated with the named state variables.

Parameters
[in]stateState from which values are to be obtained.
[out]stateValuesArray used to collect the reordered state values.
SimTK::Vector OpenSim::Model::getStateValues ( const SimTK::State s) const
double OpenSim::Model::getStateVariable ( const SimTK::State s,
const std::string &  name 
) const

Get the value of a state variable of this Model.

Parameters
sthe State for which to get the value
namethe name (string) of the state variable of interest
Array<std::string> OpenSim::Model::getStateVariableNames ( ) const
virtual

Get the names of the states.

These are the continuous states introduced by OpenSim ModelComponents and exposed thru the ModelComponent API.

Reimplemented from OpenSim::ModelComponent.

SimTK::SystemYIndex OpenSim::Model::getStateVariableSystemIndex ( const std::string &  stateVariableName) const
virtual

Get the Y index of a state variable by name.

Parameters
stateVariableNamethe name (string) of the state variable of interest

Reimplemented from OpenSim::ModelComponent.

const Array<SimTK::SystemYIndex>& OpenSim::Model::getStateVariableSystemIndices ( ) const
inline
double OpenSim::Model::getTotalMass ( const SimTK::State s) const
bool OpenSim::Model::getUseVisualizer ( ) const
inline

Return the current setting of the "use visualizer" flag, which will take effect at the next call to initSystem() on this Model.

const std::string& OpenSim::Model::getValidationLog ( )
inline

Get a log of errors/warnings ecountered when loading/constructing the model.

const ModelVisualizer& OpenSim::Model::getVisualizer ( ) const
inline

Obtain read-only access to the ModelVisualizer.

This will throw an exception if visualization was not requested or initSystem() not yet called.

Returns
A const reference to the allocated ModelVisualizer.
const SimTK::State& OpenSim::Model::getWorkingState ( ) const

Convenience method that returns a reference to the model's 'working' state.

This is just returning the reference that was returned by initSystem() and initializeState() – note that either of these methods must be called prior to getWorkingState(), otherwise an empty state will be returned.

bool OpenSim::Model::hasVisualizer ( ) const
inline

Test whether a ModelVisualizer has been created for this Model.

Even if visualization has been requested there will be no visualizer present until initSystem() has been successfully invoked. Use this method prior to calling getVisualizer() or updVisualizer() to avoid an unpleasant exception.

SimTK::State& OpenSim::Model::initializeState ( )

After buildSystem() has been called, and any additional modifications to the Simbody MultibodySystem have been made, call this method to finalize the MultibodySystem (by calling its realizeTopology() method), obtain an initial state, and assemble it so that position constraints are satisified.

The initStateFromProperties() method of each contained ModelComponent will be invoked. A reference to the writable internally- maintained model State is returned (note that this does not affect the system's default state (which is part of the model and hence read only). The model's state can be reset to the system's default state at any time by re-executing initializeState().

void OpenSim::Model::initStateFromProperties ( SimTK::State state) const
overridevirtual

Transfer property values or other state-independent initial values into this component's state variables in the passed-in state argument.

This is called after a SimTK::System and State have been created for the Model (that is, after addToSystem() has been called on all components). You should override this method if your component has properties (serializable values) that can affect initial values for your state variables. You can also perform any other state-independent calculations here that result in state initial conditions.

If you override this method, be sure to invoke the base class method first, using code like this:

void MyComponent::initStateFromProperties(SimTK::State& state) const {
Super::initStateFromProperties(state); // invoke parent class method
// ... your code goes here
}
Parameters
stateThe state that will receive the new initial conditions.
See Also
setPropertiesFromState()

Reimplemented from OpenSim::ModelComponent.

void OpenSim::Model::initStateWithoutRecreatingSystem ( SimTK::State state) const
inline

This is called after the Model is fully created but before starting a simulation.

It ONLY initializes the computational system used to simulate the model and addToSystem() has been called already. This method should only be used if if additional SimTK::System components are being added using the SimTK API and the programmer is certain that the model's system has been created.

SimTK::State& OpenSim::Model::initSystem ( )
inline

Convenience method that invokes buildSystem() and then initializeState().

A reference to the writable internally- maintained model State is returned (note that this does not affect the system's default state (which is part of the model and hence read only).

void OpenSim::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

Get a flag indicating if the model needs controls to operate its actuators.

bool OpenSim::Model::isValidSystem ( ) const

Check that the underlying computational system representing the model is valid.

That is, is the system ready for performing calculations.

void OpenSim::Model::markControlsAsValid ( const SimTK::State s) const

Mark controls as valid after an update at a given state.

Indicates that controls are valid for use at the dynamics stage. If the stage is Velocity or lower the controls will remain invalid.

Parameters
[in]sSystem state in which the controls are updated
Model& OpenSim::Model::operator= ( const Model source)

Copy assignment copies model components but does not copy any run-time objects.

Parameters
sourceThe Model to be copied.
Returns
Reference to this object.
void OpenSim::Model::overrideAllActuators ( SimTK::State s,
bool  flag 
)

Convenice function to turn on/off overriding the force for all actuators.

void OpenSim::Model::printBasicInfo ( std::ostream &  aOStream) const

Print some basic information about the model.

Parameters
aOStreamOutput stream.
void OpenSim::Model::printControlStorage ( const std::string &  fileName) const
void OpenSim::Model::printDetailedInfo ( const SimTK::State s,
std::ostream &  aOStream 
) const

Print detailed information about the model.

Parameters
sthe system State.
aOStreamOutput stream.
void OpenSim::Model::removeAnalysis ( Analysis analysis,
bool  deleteIt = true 
)

Remove an Analysis from the Model.

Parameters
analysisPointer to the analysis to remove.
deleteItWhether the removed object should be deleted.
void OpenSim::Model::removeController ( Controller aController)

Remove a Controller from the Model.

void OpenSim::Model::removeProbe ( Probe aProbe)

remove passed in Probe from model

int OpenSim::Model::replaceMarkerSet ( const SimTK::State s,
MarkerSet aMarkerSet 
)
bool OpenSim::Model::scale ( SimTK::State state,
const ScaleSet scaleSet,
double  finalMass = -1.0,
bool  preserveMassDist = false 
)

Scale the model.

Parameters
stateState containing parameter values that might be modified here.
scaleSetThe set of XYZ scale factors for the bodies.
finalMassThe mass that the scaled model should have.
preserveMassDistWhether or not the masses of the individual bodies should be scaled with the body scale factors.
Returns
Whether or not scaling was successful.
void OpenSim::Model::setAllControllersEnabled ( bool  enabled)
void OpenSim::Model::setAuthors ( const std::string &  aCredits)
inline

Set the credits (e.g., model author names) associated with the model.

Parameters
aCreditsThe string of credits.
void OpenSim::Model::setControls ( const SimTK::State s,
const SimTK::Vector controls 
) const

Alternatively, set the controls on the model at a given state.

Note, this method will invalidate the dynamics of the model, but will mark the controls as valid. (E.g. controllers will not be invoked)

Parameters
[in]sSystem state at which to apply the controls
[in]controlsThe complete Vector of controls to be applied
void OpenSim::Model::setDefaultControls ( const SimTK::Vector controls) const
inline
bool OpenSim::Model::setGravity ( const SimTK::Vec3 aGrav)

Set the gravity vector in the gloabl frame.

Parameters
aGravThe XYZ gravity vector
Returns
Whether or not the gravity vector was successfully set.
void OpenSim::Model::setInputFileName ( const std::string &  fileName)
inline

Set the XML file name used to construct the model.

Parameters
fileNameThe XML file name.
void OpenSim::Model::setPropertiesFromState ( const SimTK::State state)
overridevirtual

Given a State, set all default values for this Model to match those found in the State.

Reimplemented from OpenSim::ModelComponent.

void OpenSim::Model::setPublications ( const std::string &  aPublications)
inline

Set the publications associated with the model.

Parameters
aPublicationsThe string of publications.
void OpenSim::Model::setStateValues ( SimTK::State state,
const double *  stateValues 
) const

Set the values of state variables which are passed in the same ordering as returned by getStateVariableNames().

Values are set in the passed in state object based on Y-indices that are associated with the named state variables.

Parameters
[out]stateState to be modified.
[in]stateValuesPointer to an array of values corresponding to each of the named state variables.
void OpenSim::Model::setStateVariable ( SimTK::State s,
const std::string &  name,
double  value 
) const

Set the value of a state variable of this Model.

Parameters
sthe State for which to get the value
namethe name (string) of the state variable of interest
valuethe value of the state
void OpenSim::Model::setup ( )

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.

void OpenSim::Model::setUseVisualizer ( bool  visualize)
inline

Request or suppress visualization of this Model.

This flag is checked during initSystem() and if set causes the Model to allocate a ModelVisualizer that provides visualization and interaction with the Model as it is executing. The default is no visualization.

See Also
getModelVisualizer()
void OpenSim::Model::storeControls ( const SimTK::State s,
int  step 
)
Set<Actuator>& OpenSim::Model::updActuators ( )
AnalysisSet& OpenSim::Model::updAnalysisSet ( )
inline
void OpenSim::Model::updateAssemblyConditions ( SimTK::State s)

Update the AssemblySolver to the latest coordinate locking/constraints.

void OpenSim::Model::updateFromXMLNode ( SimTK::Xml::Element aNode,
int  versionNumber = -1 
)
virtual

Override of the default implementation to account for versioning.

Reimplemented from OpenSim::Object.

void OpenSim::Model::updateMarkerSet ( MarkerSet aMarkerSet)
BodySet& OpenSim::Model::updBodySet ( )
inline
ConstraintSet& OpenSim::Model::updConstraintSet ( )
inline
ContactGeometrySet& OpenSim::Model::updContactGeometrySet ( )
inline
ControllerSet& OpenSim::Model::updControllerSet ( )
SimTK::Vector& OpenSim::Model::updControls ( const SimTK::State s) const

Update the controls for this the model at a given state.

Only callable once underlying system for the model has been created. Throws an exception if called before Model::initSystem() This call invalidates the dynamics of the model and invalidates the value of the controls until they are marked as valid when the update is completed (

See Also
markControlsAsValid)
Parameters
[in]sSystem state at which to apply the controls
Returns
writable controls Vector
CoordinateSet& OpenSim::Model::updCoordinateSet ( )
inline
SimTK::Vector& OpenSim::Model::updDefaultControls ( ) const
inline

Writable access to the default values for controls.

These values are used for control value during a simulation unless updated, for example, by a Controller

SimTK::DefaultSystemSubsystem& OpenSim::Model::updDefaultSubsystem ( )
inline

(Advanced) Get writable access to the internal DefaultSystemSubsystem allocated by this Model's Simbody MultibodySystem.

ModelDisplayHints& OpenSim::Model::updDisplayHints ( )
inline

Get writable access to the ModelDisplayHints object stored with this Model.

The GUI or ModelVisualizer can update these as a result of user requests, or an OpenSim API program can set them programmatically.

ForceSet& OpenSim::Model::updForceSet ( )
inline
SimTK::GeneralForceSubsystem& OpenSim::Model::updForceSubsystem ( )
inline

(Advanced) Get writable access to the internal Simbody GeneralForceSubsystem allocated by this Model.

SimTK::Force::Gravity& OpenSim::Model::updGravityForce ( )
inline

(Advanced) Get writable access to the Simbody Force::Gravity element that was allocated by this Model.

JointSet& OpenSim::Model::updJointSet ( )
MarkerSet& OpenSim::Model::updMarkerSet ( )
inline
SimTK::SimbodyMatterSubsystem& OpenSim::Model::updMatterSubsystem ( )
inline

(Advanced) Get writable access to the internal SimbodyMatterSubsystem allocated by this Model.

ComponentSet& OpenSim::Model::updMiscModelComponentSet ( )
inline
SimTK::MultibodySystem& OpenSim::Model::updMultibodySystem ( ) const
inline

(Advanced) Get writable access to the internal Simbody MultibodySystem that was created by this Model at the last initSystem() call.

Be careful if you make modifications to the System because that will invalidate initialization already performed by the Model.

See Also
initStateWithoutRecreatingSystem()
Set<Muscle>& OpenSim::Model::updMuscles ( )
ProbeSet& OpenSim::Model::updProbeSet ( )
inline
SimbodyEngine& OpenSim::Model::updSimbodyEngine ( )
inline
ModelVisualizer& OpenSim::Model::updVisualizer ( )
inline

Obtain writable access to the ModelVisualizer.

This will throw an exception if visualization was not requested or initSystem() not yet called. Writable access to the ModelVisualizer requires that you have writable access to this containing Model.

Returns
A non-const reference to the allocated ModelVisualizer.
SimTK::State& OpenSim::Model::updWorkingState ( )
void OpenSim::Model::writeMarkerFile ( const std::string &  aFileName) const

Friends And Related Function Documentation

friend class ModelComponent
friend

The documentation for this class was generated from the following file: