API
4.4
For C++ developers
|
The abstract Component class defines the interface used to add computational elements to the underlying SimTK::System (MultibodySystem). More...
OpenSim Properties, Sockets, Outputs, Inputs | |
Properties (list) | |
Component | components |
"List of components that this component owns and serializes." More... | |
Public Member Functions | |
Component () | |
Default constructor. More... | |
Component (const std::string &aFileName, bool aUpdateFromXMLNode=true) | |
Construct Component from an XML file. More... | |
Component (SimTK::Xml::Element &aNode) | |
Construct Component from a specific node in an XML document. More... | |
Component (const Component &)=default | |
Use default copy constructor and assignment operator. More... | |
Component & | operator= (const Component &)=default |
virtual | ~Component ()=default |
Destructor is virtual to allow concrete Component to cleanup. More... | |
virtual void | generateDecorations (bool fixed, const ModelDisplayHints &hints, const SimTK::State &state, SimTK::Array_< SimTK::DecorativeGeometry > &appendToThis) const |
Optional method for generating arbitrary display geometry that reflects this Component at the specified state. More... | |
const SimTK::MultibodySystem & | getSystem () const |
Get the underlying MultibodySystem that this component is connected to. More... | |
bool | hasSystem () const |
Check if this component has an underlying MultibodySystem. More... | |
bool | isComponentInOwnershipTree (const Component *component) const |
Does the provided component already exist anywhere in the ownership tree (not just subcomponents of this component)? More... | |
void | addComponent (Component *subcomponent) |
Add a Component (as a subcomponent) of this component. More... | |
template<typename T = Component> | |
ComponentList< const T > | getComponentList () const |
Get an iterator through the underlying subcomponents that this component is composed of. More... | |
template<typename T = Component> | |
ComponentList< T > | updComponentList () |
Similar to getComponentList(), except the resulting list allows one to modify the components. More... | |
template<typename T = Component> | |
unsigned | countNumComponents () const |
Uses getComponentList<T>() to count the number of underlying subcomponents of the specified type. More... | |
std::string | getAbsolutePathString () const |
Get the complete (absolute) pathname for this Component to its ancestral Component, which is the root of the tree to which this Component belongs. More... | |
ComponentPath | getAbsolutePath () const |
Return a ComponentPath of the absolute path of this Component. More... | |
std::string | getRelativePathString (const Component &wrt) const |
Get the relative path of this Component with respect to another Component, as a string. More... | |
ComponentPath | getRelativePath (const Component &wrt) const |
Get the relative path of this Component with respect to another Component. More... | |
bool | hasComponent (const std::string &pathname) const |
Query if there is a component (of any type) at the specified path name. More... | |
template<class C = Component> | |
bool | hasComponent (const std::string &pathname) const |
Query if there is a component of a given type at the specified path name. More... | |
template<class C = Component> | |
const C & | getComponent (const std::string &pathname) const |
Get a unique subcomponent of this Component by its path name and type 'C'. More... | |
template<class C = Component> | |
const C & | getComponent (const ComponentPath &pathname) const |
const Component & | getComponent (const std::string &pathname) const |
Similar to the templatized getComponent(), except this returns the component as the generic Component type. More... | |
template<class C = Component> | |
C & | updComponent (const std::string &name) |
Get a writable reference to a subcomponent. More... | |
template<class C = Component> | |
C & | updComponent (const ComponentPath &name) |
Component & | updComponent (const std::string &pathname) |
Similar to the templatized updComponent(), except this returns the component as the generic Component type. More... | |
unsigned | printComponentsMatching (const std::string &substring) const |
Print a list to the console of all components whose absolute path name contains the given string. More... | |
int | getNumStateVariables () const |
Get the number of "continuous" state variables maintained by the Component and its subcomponents. More... | |
Array< std::string > | getStateVariableNames () const |
Get the names of "continuous" state variables maintained by the Component and its subcomponents. More... | |
template<class C = Component> | |
const C * | findComponent (const ComponentPath &pathToFind) const |
Find a Component to which this Component is an ancestor—in other words, a Component that is directly owned by this Component or is owned by one of its sub-components, sub-sub-components, etc. More... | |
template<class C = Component> | |
const C * | findComponent (const std::string &pathToFind) const |
Same as findComponent(const ComponentPath&), but accepting a string (a path or just a name) as input. More... | |
const StateVariable * | traverseToStateVariable (const std::string &pathName) const |
Get a StateVariable anywhere in the Component tree, given a StateVariable path. More... | |
const StateVariable * | traverseToStateVariable (const ComponentPath &path) const |
Get a StateVariable anywhere in the Component tree, given a StateVariable path. More... | |
Component Structural Interface | |
The structural interface ensures that deserialization, resolution of inter-connections, and handling of dependencies are performed systematically and prior to system creation, followed by allocation of necessary System resources. These methods can be extended by virtual methods that form the Component Extension Interface (e.g. extendFinalizeFromProperties) that can be implemented by subclasses of Components. Component ensures that the corresponding calls are propagated to all of its subcomponents. | |
void | finalizeFromProperties () |
Define a Component's internal data members and structure according to its properties. More... | |
void | finalizeConnections (Component &root) |
Satisfy the Component's connections specified by its Sockets and Inputs. More... | |
void | clearConnections () |
Disconnect/clear this Component from its aggregate component. More... | |
void | addToSystem (SimTK::MultibodySystem &system) const |
Have the Component add itself to the underlying computational System. More... | |
void | initStateFromProperties (SimTK::State &state) const |
Initialize Component's state variable values from its properties. More... | |
void | setPropertiesFromState (const SimTK::State &state) |
Set Component's properties given a state. More... | |
Component Socket Access methods | |
Access Sockets of this component by name. | |
int | getNumSockets () const |
Get the number of Sockets in this Component. More... | |
std::vector< std::string > | getSocketNames () |
Collect and return the names of the sockets in this component. More... | |
template<typename T > | |
const T & | getConnectee (const std::string &name) const |
Get the "connectee" object that the Component's Socket is bound to. More... | |
const Object & | getConnectee (const std::string &name) const |
Get the connectee as an Object. More... | |
const AbstractSocket & | getSocket (const std::string &name) const |
Get an AbstractSocket for the given socket name. More... | |
AbstractSocket & | updSocket (const std::string &name) |
Get a writable reference to the AbstractSocket for the given socket name. More... | |
template<typename T > | |
const Socket< T > & | getSocket (const std::string &name) const |
Get a const reference to the concrete Socket provided by this Component by name. More... | |
template<typename T > | |
Socket< T > & | updSocket (const std::string &name) |
Get a writable reference to the concrete Socket provided by this Component by name. More... | |
Print information to the console | |
void | printSubcomponentInfo () const |
List all subcomponents by name and recurse into these components to list their subcomponents, and so on. More... | |
void | printSocketInfo () const |
List all the Sockets of this component and whether or not they are connected. More... | |
void | printInputInfo () const |
List all the inputs of this component and whether or not they are connected. More... | |
template<typename C > | |
void | printSubcomponentInfo () const |
void | printOutputInfo (const bool includeDescendants=true) const |
Print outputs of this component and optionally, those of all subcomponents. More... | |
Public Member Functions inherited from OpenSim::Object | |
virtual | ~Object () |
Virtual destructor for cleanup. More... | |
bool | isEqualTo (const Object &aObject) const |
Equality operator wrapper for use from languages not supporting operator overloading. More... | |
Object & | operator= (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. 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 AbstractProperty & | getPropertyByIndex (int propertyIndex) const |
Get a const reference to a property by its index number, returned as an AbstractProperty. More... | |
AbstractProperty & | updPropertyByIndex (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 AbstractProperty & | getPropertyByName (const std::string &name) const |
Get a const reference to a property by its name, returned as an AbstractProperty. More... | |
AbstractProperty & | updPropertyByName (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... | |
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... | |
void | updateXMLNode (SimTK::Xml::Element &parent, const AbstractProperty *prop=nullptr) const |
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... | |
int | getDocumentFileVersion () const |
If there is a document associated with this object then return its version number. More... | |
void | setAllPropertiesUseDefault (bool aUseDefault) |
bool | print (const std::string &fileName) const |
Write this Object into an XML file of the given name; conventionally the suffix to use is ".osim". More... | |
std::string | dump () const |
dump the XML representation of this Object into an std::string and return it. 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... | |
PropertySet & | getPropertySet () |
OBSOLETE: Get a reference to the PropertySet maintained by the Object. More... | |
const PropertySet & | getPropertySet () const |
Public Types | |
typedef Component | Self |
This typedef might be useful within the member functions of this class. More... | |
typedef Object | Super |
Use this typedef to refer to the superclass of this class. More... | |
Protected Member Functions | |
SimTK_DEFINE_UNIQUE_INDEX_TYPE (MemberSubcomponentIndex) | |
template<class C = Component> | |
MemberSubcomponentIndex | constructSubcomponent (const std::string &name) |
Construct a subcomponent as a data member of this Component. More... | |
template<class C = Component> | |
const C & | getMemberSubcomponent (MemberSubcomponentIndex ix) const |
template<class C = Component> | |
C & | updMemberSubcomponent (MemberSubcomponentIndex ix) |
void | adoptSubcomponent (Component *subcomponent) |
Adopt a component as a subcomponent of this Component. More... | |
size_t | getNumImmediateSubcomponents () const |
Get the number of Subcomponents immediately owned by this Component. More... | |
size_t | getNumMemberSubcomponents () const |
Get the number of Subcomponents that are data members of this Component. More... | |
size_t | getNumPropertySubcomponents () const |
Get the number of Subcomponents that are properties of this Component. More... | |
size_t | getNumAdoptedSubcomponents () const |
Get the number of Subcomponents adopted by this Component. More... | |
std::vector< SimTK::ReferencePtr< const Component > > | getImmediateSubcomponents () const |
Access this Component's immediate subcomponents (not those owned by subcomponents) More... | |
template<class C > | |
const C * | traversePathToComponent (ComponentPath path) const |
void | setNextSubcomponentInSystem (const Component &sub) const |
Helper method to enable Component makers to specify the order of their subcomponents to be added to the System during addToSystem(). More... | |
void | resetSubcomponentOrder () |
resetSubcomponentOrder clears this Component's list of ordered subcomponents (but otherwise leaves subcomponents untouched). More... | |
void | updateFromXMLNode (SimTK::Xml::Element &node, int versionNumber) override |
Handle a change in XML syntax for Sockets. More... | |
Property-related functions | |
const Component & | get_components (int i) const |
Get the value of the i-th element of the components property. More... | |
Component & | upd_components (int i) |
Get a writable reference to the i-th element of the components property. More... | |
void | set_components (int i, const Component &value) |
Set the value of the i-th element of components property. More... | |
int | append_components (const Component &value) |
Append an element to the components property. More... | |
Component Extension Interface | |
The interface ensures that deserialization, resolution of inter-connections, and handling of dependencies are performed systematically and prior to system creation, followed by allocation of necessary System resources. These methods are virtual and may be implemented by subclasses of Components.
The base class implementations ensures that the corresponding calls are made to any subcomponents which are owned by this Component. Ownership is established by the subcomponent being a data member (not serialized), a property (serialized), or created and adopted based on other settings or options that arise from the properties. For example, a Model (Component) may have to split a body and add a Weld constraint to handle a closed loop specified by Joints that are properties of the Model. The new Body and Weld (components) are created and adopted as part of connecting the model to form a valid multibody tree. So assuming that your concrete Component and all intermediate classes from which it derives properly follow the requirement of calling the Super class method first, the order of operations enforced here for a call to a single method will be
| |
virtual void | extendAddComponent (Component *subcomponent) |
Perform any secondary operations, e.g. More... | |
virtual void | extendFinalizeFromProperties () |
Perform any time-invariant calculations, data structure initializations, or other configuration based on the component's properties to form a functioning (but not yet connected) component. More... | |
virtual void | extendFinalizeConnections (Component &root) |
Perform any necessary initializations required to connect the component (and it subcomponents) to other components and mark the connection status. More... | |
void | initComponentTreeTraversal (const Component &root) const |
Build the tree of Components from this component through its descendants. More... | |
virtual void | extendAddToSystem (SimTK::MultibodySystem &system) const |
Add appropriate Simbody elements (if needed) to the System corresponding to this component and specify needed state resources. More... | |
virtual void | extendAddToSystemAfterSubcomponents (SimTK::MultibodySystem &system) const |
Add appropriate Simbody elements (if needed) to the System after your component's subcomponents have had a chance to add themselves to the system. More... | |
virtual void | extendInitStateFromProperties (SimTK::State &state) const |
Transfer property values or other state-independent initial values into this component's state variables in the passed-in state argument. More... | |
virtual void | extendSetPropertiesFromState (const SimTK::State &state) |
Update this component's property values to match the specified State, if the component has created any state variable that is intended to correspond to a property. More... | |
virtual void | 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... | |
void | setStateVariableDerivativeValue (const SimTK::State &state, const std::string &name, double deriv) const |
Set the derivative of a state variable by name when computed inside of this Component's computeStateVariableDerivatives() method. More... | |
Component Advanced Interface | |
You probably won't need to override methods in this section. These provide a way for you to perform computations ("realizations") that must be scheduled in carefully-ordered stages as described in the class description above. The typical operation will be that the given SimTK::State provides you with the inputs you need for your computation, which you will then write into some element of the state cache, where later computations can pick it up.
| |
virtual void | extendRealizeTopology (SimTK::State &state) const |
Obtain state resources that are needed unconditionally, and perform computations that depend only on the system topology. More... | |
virtual void | extendRealizeModel (SimTK::State &state) const |
Obtain and name state resources (like state variables allocated by an underlying Simbody component) that may be needed, depending on modeling options. More... | |
virtual void | extendRealizeInstance (const SimTK::State &state) const |
Perform computations that depend only on instance variables, like lengths and masses. More... | |
virtual void | extendRealizeTime (const SimTK::State &state) const |
Perform computations that depend only on time and earlier stages. More... | |
virtual void | extendRealizePosition (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 | extendRealizeVelocity (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 | extendRealizeDynamics (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 | extendRealizeAcceleration (const SimTK::State &state) const |
Perform computations that may depend on applied forces. More... | |
virtual void | extendRealizeReport (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... | |
Component System Creation and Access Methods | |
These methods support implementing concrete Components. Add methods can only be called inside of extendAddToSystem() and are useful for creating the underlying SimTK::System level variables that are used for computing values of interest.
| |
void | addModelingOption (const std::string &optionName, int maxFlagValue) const |
Add a modeling option (integer flag stored in the State) for use by this Component. More... | |
void | addStateVariable (const std::string &stateVariableName, const SimTK::Stage &invalidatesStage=SimTK::Stage::Dynamics, bool isHidden=false) const |
Add a continuous system state variable belonging to this Component, and assign a name by which to refer to it. More... | |
void | addStateVariable (Component::StateVariable *stateVariable) const |
The above method provides a convenient interface to this method, which automatically creates an 'AddedStateVariable' and allocates resources in the SimTK::State for this variable. More... | |
void | addDiscreteVariable (const std::string &discreteVariableName, SimTK::Stage invalidatesStage) const |
Add a system discrete variable belonging to this Component, 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... | |
SimTK::MultibodySystem & | updSystem () const |
Get writable reference to the MultibodySystem that this component is connected to. More... | |
int | getStateIndex (const std::string &name) const |
Get the index of a Component's continuous state variable in the Subsystem for allocations. More... | |
SimTK::SystemYIndex | getStateVariableSystemIndex (const std::string &stateVariableName) const |
Get the System Index of a state variable allocated by this Component. More... | |
const SimTK::DiscreteVariableIndex | getDiscreteVariableIndex (const std::string &name) const |
Get the index of a Component's discrete variable in the Subsystem for allocations. More... | |
Internal methods for constructing Sockets, Outputs, Inputs | |
To declare Sockets, Outputs, and Inputs for your component, use the following macros within your class declaration (ideally at the top near property declarations):
The methods below are used in those macros, and you should not use these methods yourself. | |
template<typename T > | |
PropertyIndex | constructSocket (const std::string &name, const std::string &propertyComment) |
Construct a specialized Socket for this Component's dependence on another Component. More... | |
template<typename T , typename CompType = Component> | |
bool | constructOutput (const std::string &name, T(CompType::*const memFunc)(const SimTK::State &) const, const SimTK::Stage &dependsOn=SimTK::Stage::Acceleration) |
Construct an output for a member function of the same component. More... | |
template<typename T , typename CompType = Component> | |
bool | constructOutput (const std::string &name, const T &(CompType::*const memFunc)(const SimTK::State &) const, const SimTK::Stage &dependsOn=SimTK::Stage::Acceleration) |
This variant handles component member functions that return the output value by const reference (const T&). More... | |
template<typename T , typename CompType > | |
bool | constructListOutput (const std::string &name, T(CompType::*const memFunc)(const SimTK::State &, const std::string &channel) const, const SimTK::Stage &dependsOn=SimTK::Stage::Acceleration) |
Construct an output that can have multiple channels. More... | |
bool | constructOutputForStateVariable (const std::string &name) |
Construct an Output for a StateVariable. More... | |
template<typename T > | |
PropertyIndex | constructInput (const std::string &name, bool isList, const std::string &propertyComment, const SimTK::Stage &requiredAtStage=SimTK::Stage::Instance) |
Construct an Input (socket) for this Component's dependence on an Output signal. 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) | |
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... | |
template<class T > | |
void | checkPropertyValueIsPositive (const Property< T > &p) const |
Throw an exception if any of the property's values are not positive. More... | |
template<class T > | |
void | checkPropertyValueIsInSet (const Property< T > &p, const std::set< T > &set) const |
Throw an exception if any of the property's values are not in the provided set. More... | |
template<class T > | |
void | checkPropertyValueIsInRangeOrSet (const Property< T > &p, const T &lower, const T &upper, const std::set< T > &set) const |
Throw an exception if any of the property's values are neither in the provided range nor in the provided set. 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... | |
void | clearObjectIsUpToDateWithProperties () |
For testing or debugging purposes, manually clear the "object is up to
date with respect to properties" flag. More... | |
void | makeObjectNamesConsistentWithProperties () |
Make sure the name of an object is consistent with its property type. 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 XMLDocument * | getDocument () const |
Get a const pointer to the document (if any) associated with this object. More... | |
XMLDocument * | updDocument () |
Get a writable pointer to the document (if any) associated with this object. More... | |
Static Protected Member Functions | |
static void | prependComponentPathToConnecteePath (Component &subcomponent) |
For internal use. More... | |
Friends | |
template<typename T > | |
class | ComponentList |
Class that permits iterating over components/subcomponents (but does not actually contain the components themselves). More... | |
template<typename T > | |
class | ComponentListIterator |
Class to iterate over ComponentList returned by getComponentList(). More... | |
template<class T > | |
class | ComponentMeasure |
Auto-generated functions | |
static Component * | safeDownCast (OpenSim::Object *obj) |
For use in MATLAB and Python to access the concrete class. More... | |
static const std::string & | getClassName () |
This returns "Component". More... | |
void | assign (Object &aObject) override |
This allows copy assignment in the Java GUI. More... | |
Component * | clone () const override=0 |
Create a new heap-allocated copy of the concrete object to which this Object refers. More... | |
const std::string & | getConcreteClassName () const override=0 |
Returns the class name of the concrete Object-derived class of the actual object referenced by this Object, as a string. More... | |
Component Inputs and Outputs Access methods | |
Access inputs and outputs by name and iterate over all outputs. | |
typedef std::map< std::string, SimTK::ClonePtr< AbstractOutput > >::const_iterator | OutputConstIterator |
Define OutputConstIterator for convenience. More... | |
int | getNumInputs () const |
Access the number of Inputs that this component has. More... | |
int | getNumOutputs () const |
Access the number of Outputs that this component has. More... | |
std::vector< std::string > | getInputNames () const |
Collect and return the names of Inputs in this component as an std::vector. More... | |
std::vector< std::string > | getOutputNames () const |
Collect and return the names of Outputs in this component as an std::vector. More... | |
const AbstractInput & | getInput (const std::string &name) const |
Get an Input provided by this Component by name. More... | |
AbstractInput & | updInput (const std::string &name) |
Get a writable reference to an Input provided by this Component by name. More... | |
template<typename T > | |
const Input< T > & | getInput (const std::string &name) const |
Get a concrete Input that you can directly ask for its values. More... | |
const AbstractOutput & | getOutput (const std::string &name) const |
Get the Output provided by this Component by name. More... | |
AbstractOutput & | updOutput (const std::string &name) |
Get a writable reference to an Output provided by this Component by name. More... | |
SimTK::IteratorRange< OutputConstIterator > | getOutputs () const |
Iterate through all Outputs of this component. More... | |
Component State Access methods | |
Get and set modeling option, input and output values, state variable, discrete and/or cache variables in the State. | |
int | getModelingOption (const SimTK::State &state, const std::string &name) const |
Get a ModelingOption flag for this Component by name. More... | |
void | setModelingOption (SimTK::State &state, const std::string &name, int flag) const |
Set the value of a ModelingOption flag for this Component. More... | |
template<typename T > | |
const T & | getInputValue (const SimTK::State &state, const std::string &name) const |
Get the Input value that this component is dependent on. More... | |
template<typename T > | |
const T & | getOutputValue (const SimTK::State &state, const std::string &name) const |
Get the Output value provided by this Component by name. More... | |
double | getStateVariableValue (const SimTK::State &state, const std::string &name) const |
Get the value of a state variable allocated by this Component. More... | |
double | getStateVariableValue (const SimTK::State &state, const ComponentPath &path) const |
Get the value of a state variable allocated by this Component. More... | |
void | setStateVariableValue (SimTK::State &state, const std::string &name, double value) const |
Set the value of a state variable allocated by this Component by name. More... | |
SimTK::Vector | getStateVariableValues (const SimTK::State &state) const |
Get all values of the state variables allocated by this Component. More... | |
void | setStateVariableValues (SimTK::State &state, const SimTK::Vector &values) const |
Set all values of the state variables allocated by this Component. More... | |
double | getStateVariableDerivativeValue (const SimTK::State &state, const std::string &name) const |
Get the value of a state variable derivative computed by this Component. More... | |
double | getDiscreteVariableValue (const SimTK::State &state, const std::string &name) const |
Get the value of a discrete variable allocated by this Component by name. More... | |
void | setDiscreteVariableValue (SimTK::State &state, const std::string &name, double value) const |
Set the value of a discrete variable allocated by this Component by name. More... | |
template<class T > | |
SimTK::CacheEntryIndex | getCacheVariableIndex (const CacheVariable< T > &cv) const |
Get the index of a Component's cache variable in the Subsystem for allocations. More... | |
SimTK::CacheEntryIndex | getCacheVariableIndex (const std::string &name) const |
Get the index of a Component's cache variable in the Subsystem for allocations. More... | |
template<class T > | |
const T & | getCacheVariableValue (const SimTK::State &state, const std::string &name) const |
Get the value of a cache variable allocated by this Component by name. More... | |
template<class T > | |
const T & | getCacheVariableValue (const SimTK::State &state, const CacheVariable< T > &cv) const |
Get the value of a cache variable allocated by this Component. More... | |
template<typename T > | |
void | setCacheVariableValue (const SimTK::State &state, const std::string &k, T value) const |
Set the value of a cache variable, identified by name , to a new value and mark the cache variable as valid. More... | |
template<typename T > | |
void | setCacheVariableValue (const SimTK::State &state, const CacheVariable< T > &cv, T value) const |
Set the value of a cache variable to a new value and mark the cache variable as valid. More... | |
template<typename T > | |
T & | updCacheVariableValue (const SimTK::State &state, const std::string &name) const |
Returns a mutable reference to the value of a cache variable identified by name . More... | |
template<typename T > | |
T & | updCacheVariableValue (const SimTK::State &state, const CacheVariable< T > &cv) const |
Returns a mutable reference to the value of a cache variable. More... | |
bool | isCacheVariableValid (const SimTK::State &state, const std::string &name) const |
Returns true if the cache variable, identified by name , is valid. More... | |
template<class T > | |
bool | isCacheVariableValid (const SimTK::State &state, const CacheVariable< T > &cv) const |
Returns true if the cache variable is valid. More... | |
void | markCacheVariableValid (const SimTK::State &state, const std::string &name) const |
Marks the value of a cache variable, identified by name , as valid. More... | |
template<typename T > | |
void | markCacheVariableValid (const SimTK::State &state, const CacheVariable< T > &cv) const |
Marks the value of a cache variable as valid. More... | |
void | markCacheVariableInvalid (const SimTK::State &state, const std::string &name) const |
Marks the value of a cache variable, identified by name , as invalid. More... | |
template<class T > | |
void | markCacheVariableInvalid (const SimTK::State &state, const CacheVariable< T > &cv) const |
Marks the value of a cache variable as invalid. More... | |
template<class T > | |
CacheVariable< T > | addCacheVariable (std::string name, T variablePrototype, SimTK::Stage dependsOnStage) const |
Add a state cache entry belonging to this Component to hold calculated values that must be automatically invalidated when certain state values change. More... | |
Access to the owning component (advanced). | |
const Component & | getOwner () const |
Access the owner of this Component. More... | |
bool | hasOwner () const |
(For advanced users) Check if this Component has an owner. More... | |
const Component & | getRoot () const |
Obtain the root Component, which is this component if it is orphaned. More... | |
void | setOwner (const Component &owner) |
Set this Component's reference to its owning Component More... | |
Nested Classes | |
class | CacheVariable |
A cache variable containing a value of type T. More... | |
class | StateVariable |
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 Object * | getDefaultInstanceOfType (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 Object * | newInstanceOfType (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 bool | PrintPropertyInfo (std::ostream &os, const std::string &classNameDotPropertyName, bool printFlagInfo=true) |
Dump formatted property information to a given output stream, useful for creating a "help" facility for registered objects. More... | |
static bool | PrintPropertyInfo (std::ostream &os, const std::string &className, const std::string &propertyName, bool printFlagInfo=true) |
Same as the other signature but the class name and property name are provided as two separate strings. More... | |
static Object * | makeObjectFromFile (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 amount of logging output. More... | |
static int | getDebugLevel () |
Get the current setting of debug level. More... | |
static Object * | SafeCopy (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 Attributes inherited from OpenSim::Object | |
PropertySet | _propertySet |
OBSOLETE: Property_Deprecated set for serializable member variables of this and derived classes. More... | |
Related Functions inherited from OpenSim::Object | |
#define | OpenSim_DECLARE_CONCRETE_OBJECT(ConcreteClass, SuperClass) |
Macro to be included as the first line of the class declaration for any non-templatized, concrete class that derives from OpenSim::Object. More... | |
#define | OpenSim_DECLARE_ABSTRACT_OBJECT(ConcreteClass, SuperClass) |
Macro to be included as the first line of the class declaration for any still-abstract class that derives from OpenSim::Object. More... | |
#define | OpenSim_DECLARE_CONCRETE_OBJECT_T(ConcreteClass, TArg, SuperClass) |
Macro to be included as the first line of the class declaration for any templatized, concrete class that derives from OpenSim::Object, like Set<T>. More... | |
#define | OpenSim_DECLARE_ABSTRACT_OBJECT_T(ConcreteClass, TArg, SuperClass) |
Macro to be included as the first line of the class declaration for any templatized, still-abstract class that derives from OpenSim::Object. More... | |
The abstract Component class defines the interface used to add computational elements to the underlying SimTK::System (MultibodySystem).
It specifies the interface that components must satisfy in order to be part of the system and provides a series of helper methods for adding variables (state, discrete, cache, ...) to the underlying system. As such, Component handles all of the bookkeeping of system indices and provides convenience access to variable values (incl. derivatives) via their names as strings.
The MultibodySystem and its State are defined by Simbody (ref ...). Briefly, a System represents the mathematical equations that specify the behavior of a computational model. The State is a collection of all the variables that uniquely define the unknowns in the system equations. Consider a single differential equation as a system, while a single set of variable values that satisfy the equation is a state of that system. These could be values for joint coordinates, their speeds, as well other variables that govern the system dynamics (e.g. muscle activation and fiber-length variables that dictate muscle force). These variables are called continuous state variables in Simbody, but are more simply referred to as StateVariables in OpenSim. Component provides services to define and access its StateVariables and specify their dynamics (derivatives with respect to time) that are automatically and simultaneously integrated with the MultibodySystem dynamics. Common operations to integrate, take the max or min, or to delay a signal, etc. require internal variables to perform their calculations and these are also held in the State. Simbody provides the infrastructure to ensure that calculations are kept up-to-date with the state variable values.
There are other types of "State" variables such as a flag (or options) that enables a component to be disabled or for a muscle force to be overridden and and these are identified as ModelingOptions since they may change the modeled dynamics of the component. Component provides services that enable developers of components to define additional ModelingOptions.
Often a component requires input from an outside source (precomputed data from a file, another program, or interaction from a user) in which case these variables do not have dynamics (differential eqns.) known to the component, but are necessary to describe the dynamical "state" of the system. An example, is a throttle component (a "controller" that provides an actuator, e.g. a motor, with a control signal like a voltage or current) which it gets as direct input from the user (via a joystick, key press, etc..). The throttle controls the motor torque output and therefore the behavior of the model. The input by the user to the throttle the motor (the controls) is necessary to specify the model dynamics at any instant and therefore are considered part of the State. In OpenSim they are simply referred to as DiscreteVariables. The Component provides services to enable developers of components to define and access its DiscreteVariables.
Fast and efficient simulations also require computationally expensive calculations to be performed only when necessary. Often the result of an expensive calculation can be reused many times over, while the variables it is dependent on remain fixed. The concept of holding onto these values is called caching and the variables that hold these values are call CacheVariables. It is important to note, that cache variables are not state variables. Cache variables can always be recomputed exactly from the State. OpenSim uses the Simbody infrastructure to manage cache variables and their validity. Component provides a simplified interface to define and access CacheVariables.
Many modeling and simulation codes put the onus on users and component creators to manage the validity of cache variables, which is likely to lead to undetectable errors where cache values are stale (calculated based on past state variable values). Simbody, on the other hand, provides a more strict infrastructure to make it easy to exploit the efficiencies of caching while reducing the risks of validity errors. To do this, Simbody employs the concept of computational stages to "realize" (or compute) a model's system to a particular stage requires cached quantities up to and including the stage to to computed/specified. Simbody utilizes nine realization stages (SimTK::Stage::
)
Topology
finalize System with "slots" for most variables (above)Model
specify modeling choicesInstance
specify modifiable model parametersTime
compute time dependent quantitiesPosition
compute position dependent quantitiesVelocity
compute velocity dependent quantitiesDynamics
compute system applied forces and dependent quantitiesAcceleration
compute system accelerations and all other derivativesReport
compute quantities for reporting/outputThe Component interface is automatically invoked by the System and its realizations. Component users and most developers need not concern themselves with Topology
, Model
or Instance
stages. That interaction is managed by Component when component creators implement extendAddToSystem() and use the services provided by Component. Component creators do need to determine and specify stage dependencies for Discrete and CacheVariables that they add to their components. For example, the throttle controller reads its value from user input and it is valid for all calculations as long as time does not change. If the simulation (via numerical integration) steps forward (or backward for a trial step) and updates the state, the control from a previous state (time) should be invalid and an error generated for trying to access the DiscreteVariable for the control value. To do this one specifies the "invalidates" stage (e.g. SimTK::Stage::Time
) for a DiscreteVariable when the variable is added to the Component. A subsequent change to that variable will invalidate all state cache entries at that stage or higher. For example, if a DiscreteVariable is declared to invalidate Stage::Position
then changing it will invalidate cache entries that depend on positions, velocities, forces, and accelerations.
Similar principles apply to CacheVariables, which requires a "dependsOn" stage to be specified when a CacheVariable is added to the component. In this case, the cache variable "shadows" the State (unlike a DiscreteVariable, which is a part of the State) holding already-computed state-dependent values so that they do not need to be recomputed until the state changes. Accessing the CacheVariable in a State whose current stage is lower than that CacheVariable's specified dependsOn stage will trigger an exception. It is up to the component to update the value of the cache variable. Component provides methods to check if the cache is valid, update its value and then to mark it as valid.
The primary responsibility of a Component is to add its computational representation(s) to the underlying SimTK::System by implementing extendAddToSystem().
Additional methods provide support for adding modeling options, state and cache variables.
Public methods enable access to component variables via their names.
A Component can have any number of Components within it; we call these subcomponents. Subcomponents can also contain their own subcomponents as well. There are three categories of subcomponents, which vary in whether they are configurable and fixed in number:
Also, any specific Component can end up in any of these three categories. That is, if you have a MySpecialForce Component, any other Component can have it as a property subcomponent, a member subcomponent, or as an adopted subcomponent.
typedef std::map<std::string, SimTK::ClonePtr<AbstractOutput> >:: const_iterator OpenSim::Component::OutputConstIterator |
Define OutputConstIterator for convenience.
typedef Component OpenSim::Component::Self |
This typedef might be useful within the member functions of this class.
This is generated by the OpenSim_DECLARE_*_OBJECT
macros.
typedef Object OpenSim::Component::Super |
Use this typedef to refer to the superclass of this class.
Avoid using the explicit type name of the superclass; this would introduce bugs if the superclass is changed.
This is generated by the OpenSim_DECLARE_*_OBJECT
macros.
OpenSim::Component::Component | ( | ) |
Default constructor.
OpenSim::Component::Component | ( | const std::string & | aFileName, |
bool | aUpdateFromXMLNode = true |
||
) |
Construct Component from an XML file.
|
explicit |
Construct Component from a specific node in an XML document.
|
default |
Use default copy constructor and assignment operator.
|
virtualdefault |
Destructor is virtual to allow concrete Component to cleanup.
|
inlineprotected |
Add a state cache entry belonging to this Component to hold calculated values that must be automatically invalidated when certain state values change.
Cache entries contain values whose computations depend on state variables and provide convenience and/or efficiency by holding on to them in memory (cache) to avoid recomputation. Once the state changes, the cache values automatically become invalid and has to be recomputed based on the current state before it can be referenced again. Any attempt to reference an invalid cache entry results in an exception being thrown.
Cache entry validity is managed by computation Stage, rather than by dependence on individual state variables. Changing a variables whose "invalidates" stage is the same or lower as the one specified as the "depends on" stage here cause the cache entry to be invalidated. For example, a body's momentum, which is dependent on position and velocity states, should have Stage::Velocity as its dependsOnStage. Then if a Velocity stage variable or lower (e.g. Position stage) changes, then the cache is invalidated. But, if a Dynamics stage variable (or above) is changed, the velocity remains valid so the cache entry does not have to be recomputed.
[in] | name | The name you are assigning to this cache entry. Must be unique within this model component. |
[in] | variablePrototype | An object defining the type of value, and a default value of that type, to be held in this cache entry. Can be a simple int or an elaborate class, as long as it has deep copy semantics. |
[in] | dependsOnStage | This is the highest computational stage on which this cache entry's value computation depends. State changes at this level or lower will invalidate the cache entry. |
void OpenSim::Component::addComponent | ( | Component * | subcomponent | ) |
Add a Component (as a subcomponent) of this component.
This component takes ownership of the subcomponent and it will be serialized (appear in XML) as part of this component. Specifically, it will appear in the <components>
list for this Component. If the subcomponent is already owned by this component or exists in the same hierarchy (tree) as this component, an Exception is thrown.
Typical usage is:
ComponentAlreadyPartOfOwnershipTree |
subcomponent | is the Component to be added. |
Referenced by OpenSim::analyze().
|
protected |
Add a system discrete variable belonging to this Component, 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.
|
protected |
Add a modeling option (integer flag stored in the State) for use by this Component.
Each modeling option is identified by its own optionName, specified here. Modeling options enable the model component to be configured differently in order to represent different operating modes. For example, if two modes of operation are necessary (mode off and mode on) then specify optionName, "mode" with maxFlagValue = 1. Subsequent gets will return 0 or 1 and set will only accept 0 and 1 as acceptable values. Changing the value of a model option invalidates Stage::Instance and above in the State, meaning all calculations involving time, positions, velocity, and forces are invalidated.
|
protected |
Add a continuous system state variable belonging to this Component, and assign a name by which to refer to it.
Changing the value of this state variable will automatically invalidate everything at and above its invalidatesStage, which is normally Stage::Dynamics meaning that there are forces that depend on this variable. If you define one or more of these variables you must also override computeStateVariableDerivatives() to provide time derivatives for them. Note, all corresponding system indices are automatically determined using this interface. As an advanced option you may choose to hide the state variable from being accessed outside of this component, in which case it is considered to be "hidden". You may also want to create an Output for this state variable; see OpenSim_DECLARE_OUTPUT_FOR_STATE_VARIABLE for more information. Reporters should use such an Output to get the StateVariable's value (instead of using getStateVariableValue()).
[in] | stateVariableName | string value to access variable by name |
[in] | invalidatesStage | the system realization stage that is invalidated when variable value is changed |
[in] | isHidden | flag (bool) to optionally hide this state variable from being accessed outside this component as an Output |
|
protected |
The above method provides a convenient interface to this method, which automatically creates an 'AddedStateVariable' and allocates resources in the SimTK::State for this variable.
This interface allows the creator to add/expose state variables that are allocated by underlying Simbody components and specify how the state variable value is accessed by implementing a concrete StateVariable and adding it to the component using this method. You may also want to create an Output for this state variable; see OpenSim_DECLARE_OUTPUT_FOR_STATE_VARIABLE for more information. Reporters should use such an Output to get the StateVariable's value (instead of using getStateVariableValue()).
void OpenSim::Component::addToSystem | ( | SimTK::MultibodySystem & | system | ) | const |
Have the Component add itself to the underlying computational System.
|
protected |
Adopt a component as a subcomponent of this Component.
Component methods (e.g. addToSystem(), initStateFromProperties(), ...) are automatically invoked on subcomponents when called on this Component. Realization is also performed automatically on subcomponents. All subcomponents are owned, therefore this Component also takes ownership.
|
inlineprotected |
Append an element to the components property.
|
inlineoverride |
void OpenSim::Component::clearConnections | ( | ) |
Disconnect/clear this Component from its aggregate component.
Empties all component's sockets and sets them as disconnected.
|
overridepure virtual |
Create a new heap-allocated copy of the concrete object to which this Object refers.
It is up to the caller to delete the returned object when no longer needed. Every concrete object deriving from Object implements this pure virtual method automatically, via the declaration macro it invokes (e.g., OpenSim_DECLARE_CONCRETE_OBJECT()). Note that the concrete class overrides modify the return type to be a pointer to the concrete object; that still overrides the base class method because the return type is covariant with (that is, derives from) Object.
Implements OpenSim::Object.
Implemented in OpenSim::FrameGeometry, OpenSim::Mesh, OpenSim::Brick, OpenSim::Torus, OpenSim::Cone, OpenSim::Cylinder, OpenSim::Ellipsoid, OpenSim::Sphere, OpenSim::AnalyticGeometry, OpenSim::Model, OpenSim::Millard2012AccelerationMuscle, OpenSim::ConsoleReporter_< T >, OpenSim::Arrow, OpenSim::EspositoMiller2018Force, OpenSim::Bhargava2004SmoothedMuscleMetabolics, OpenSim::Umberger2010MuscleMetabolicsProbe, OpenSim::Millard2012EquilibriumMuscle, OpenSim::LineGeometry, OpenSim::Bhargava2004MuscleMetabolicsProbe, OpenSim::TableReporter_< InputT, ValueT >, OpenSim::HuntCrossleyForce, OpenSim::ElasticFoundationForce, OpenSim::Blankevoort1991Ligament, OpenSim::MeyerFregly2016Force, OpenSim::ScalarActuator, OpenSim::HuntCrossleyForce, OpenSim::ElasticFoundationForce, OpenSim::Probe, OpenSim::Thelen2003Muscle, OpenSim::Joint, OpenSim::Reporter< InputT >, OpenSim::Reporter< T >, OpenSim::DeGrooteFregly2016Muscle, OpenSim::MuscleFixedWidthPennationModel, OpenSim::ModelComponent, OpenSim::FirstOrderMuscleActivationDynamics, OpenSim::Frame, OpenSim::MuscleFirstOrderActivationDynamicModel, OpenSim::AckermannVanDenBogert2010Force, OpenSim::Muscle, OpenSim::CMC, OpenSim::SmoothSphereHalfSpaceForce, OpenSim::ExternalLoads, OpenSim::OffsetFrame< PhysicalFrame >, OpenSim::ClutchedPathSpring, OpenSim::CoordinateLimitForce, OpenSim::GeometryPath, OpenSim::PhysicalFrame, OpenSim::Delp1990Muscle_Deprecated, OpenSim::RigidTendonMuscle, OpenSim::ModelComponentSet< T >, OpenSim::RollingOnSurfaceConstraint, OpenSim::ModelComponentSet< ExternalForce >, OpenSim::ModelComponentSet< ContactGeometry >, OpenSim::ModelComponentSet< WrapObject >, OpenSim::ModelComponentSet< Force >, OpenSim::ModelComponentSet< Joint >, OpenSim::ModelComponentSet< Probe >, OpenSim::ModelComponentSet< Controller >, OpenSim::ModelComponentSet< ModelComponent >, OpenSim::ModelComponentSet< Marker >, OpenSim::ModelComponentSet< Body >, OpenSim::ModelComponentSet< Constraint >, OpenSim::ScapulothoracicJoint, OpenSim::MuscleActivationDynamics, OpenSim::ExpressionBasedPointToPointForce, OpenSim::ExternalForce, OpenSim::Controller, OpenSim::ActivationFiberLengthMuscle, OpenSim::Geometry, OpenSim::ExpressionBasedBushingForce, OpenSim::FunctionBasedBushingForce, OpenSim::PathSpring, OpenSim::PrescribedForce, OpenSim::TwoFrameLinker< Force, PhysicalFrame >, OpenSim::TwoFrameLinker< Constraint, PhysicalFrame >, OpenSim::ActivationFiberLengthMuscle_Deprecated, OpenSim::BushingForce, OpenSim::Coordinate, OpenSim::CustomJoint, OpenSim::Schutte1993Muscle_Deprecated, OpenSim::TorqueActuator, OpenSim::Ligament, OpenSim::BallJoint, OpenSim::CoordinateCouplerConstraint, OpenSim::BodyActuator, OpenSim::PointActuator, OpenSim::Thelen2003Muscle_Deprecated, OpenSim::PointToPointActuator, OpenSim::Actuator, OpenSim::Point, OpenSim::FreeJoint, OpenSim::UnilateralConstraint, OpenSim::ActivationCoordinateActuator, OpenSim::CoordinateActuator, OpenSim::McKibbenActuator, OpenSim::ForceSet, OpenSim::JointInternalPowerProbe, OpenSim::PhysicalOffsetFrame, OpenSim::WeldConstraint, OpenSim::ControlSetController, OpenSim::EllipsoidJoint, OpenSim::CorrectionController, OpenSim::AbstractReporter, OpenSim::TableSource_< ET >, OpenSim::ExperimentalMarker, OpenSim::WrapObject, OpenSim::Set< Joint, ModelComponent >, OpenSim::Set< Marker, ModelComponent >, OpenSim::Set< T, ModelComponent >, OpenSim::Set< ContactGeometry, ModelComponent >, OpenSim::Set< Controller, ModelComponent >, OpenSim::Set< WrapObject, ModelComponent >, OpenSim::Set< Probe, ModelComponent >, OpenSim::Set< ModelComponent, ModelComponent >, OpenSim::Set< Body, ModelComponent >, OpenSim::Set< Constraint, ModelComponent >, OpenSim::Set< ExternalForce, ModelComponent >, OpenSim::Set< Force, ModelComponent >, OpenSim::SpringGeneralizedForce, OpenSim::ControllerSet, OpenSim::PathActuator, OpenSim::ExperimentalFrame, OpenSim::PinJoint, OpenSim::UniversalJoint, OpenSim::AccelerationMotion, OpenSim::PrescribedController, OpenSim::ActuatorPowerProbe, OpenSim::ContactGeometry, OpenSim::Force, OpenSim::Marker, OpenSim::MovingPathPoint, OpenSim::MuscleActiveFiberPowerProbe, OpenSim::SystemEnergyProbe, OpenSim::PointConstraint, OpenSim::Constraint, OpenSim::GimbalJoint, OpenSim::PlanarJoint, OpenSim::WrapCylinder, OpenSim::WrapEllipsoid, OpenSim::WrapSphere, OpenSim::WrapTorus, OpenSim::SignalGenerator, OpenSim::ActuatorForceProbe, OpenSim::ConditionalPathPoint, OpenSim::JointSet, OpenSim::Station, OpenSim::IMU, OpenSim::PositionMotion, OpenSim::Body, OpenSim::SliderJoint, OpenSim::WeldJoint, OpenSim::PathWrapPoint, OpenSim::ConstantMuscleActivation, OpenSim::ComponentSet, OpenSim::Ground, OpenSim::PointToPointSpring, OpenSim::ConstantDistanceConstraint, OpenSim::ZerothOrderMuscleActivationDynamics, OpenSim::ElasticFoundationForce, OpenSim::ProbeSet, OpenSim::PointOnLineConstraint, OpenSim::StatesTrajectoryReporter, OpenSim::WrapObjectSet, OpenSim::DiscreteForces, OpenSim::AbstractPathPoint, OpenSim::ContactGeometrySet, OpenSim::ContactHalfSpace, OpenSim::HuntCrossleyForce, OpenSim::PathPoint, OpenSim::BodySet, OpenSim::ConstraintSet, OpenSim::ContactMesh, OpenSim::MarkerSet, OpenSim::MocoScaleFactor, OpenSim::Bhargava2004SmoothedMuscleMetabolics_MuscleParameters, OpenSim::ContactSphere, OpenSim::ExpressionBasedCoordinateForce, OpenSim::DiscreteController, and OpenSim::StationPlaneContactForce.
|
protectedvirtual |
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 set the derivatives of state variables added to the system by this component. (also see extendAddToSystem()). If the component adds states and computeStateVariableDerivatives is not implemented by the component, an exception is thrown when the system tries to evaluate its derivatives.
Implement like this:
For subclasses, it is highly recommended that you first call Super::computeStateVariableDerivatives(state) to preserve the derivative computation of the parent class and to only specify the derivatives of the state variables added by name. One does have the option to override all the derivative values for the parent by accessing the derivatives by their state variable name. This is necessary, for example, if a newly added state variable is coupled to the dynamics (derivatives) of the states variables that were added by the parent.
Reimplemented in OpenSim::Model, OpenSim::Millard2012AccelerationMuscle, OpenSim::Millard2012EquilibriumMuscle, OpenSim::DeGrooteFregly2016Muscle, OpenSim::Delp1990Muscle_Deprecated, OpenSim::ActivationFiberLengthMuscle_Deprecated, OpenSim::FirstOrderMuscleActivationDynamics, OpenSim::ClutchedPathSpring, OpenSim::ActivationFiberLengthMuscle, and OpenSim::ActivationCoordinateActuator.
|
inlineprotected |
Construct an Input (socket) for this Component's dependence on an Output signal.
It is a placeholder for the Output and its type and enables the Component to automatically traverse its dependencies and provide a meaningful message if the provided Output is incompatible or non-existent. This also specifies at what stage the output must be valid for the component to consume it as an input. If the Output's dependsOnStage is above the Input's requiredAtStage, an Exception is thrown because the output cannot satisfy the Input's requirement. This function also creates a Property in this component to store the connectee paths for this input; the propertyComment argument is the comment to use for that Property.
References OpenSim::Exception::Exception(), and OpenSim::Exception::OPENSIM_THROW_IF.
|
inlineprotected |
Construct an output that can have multiple channels.
You add Channels to this Output in extendFinalizeFromProperties() using AbstractOutput::addChannel(). The member function you provide must take the name of the channel whose value is requested.
|
inlineprotected |
Construct an output for a member function of the same component.
The following must be true about componentMemberFunction, the function that returns the output:
const SimTK::State&
double computeQuantity(const SimTK::State&) const
).You must also provide the stage on which the output depends.
You can ask outputs for their value only after you call finalizeFromProperties()
.
|
inlineprotected |
This variant handles component member functions that return the output value by const reference (const T&).
|
protected |
Construct an Output for a StateVariable.
While this method is a convenient way to construct an Output for a StateVariable, it is inefficient because it uses a string lookup. To create a more efficient Output, create a member variable that returns the state variable directly; see the implementations of Coordinate::getValue() or Muscle::getActivation() for examples.
name | Name of the output, which must be the same as the name of the corresponding state variable. |
|
inlineprotected |
Construct a specialized Socket for this Component's dependence on another Component.
It serves as a placeholder for the Component and its type and enables the Component to automatically traverse its dependencies and provide a meaningful message if the provided Component is incompatible or non-existent. This function also creates a Property in this component to store the connectee path for this socket; the propertyComment argument is the comment to use for that Property.
References OpenSim::Exception::Exception(), and OpenSim::Exception::OPENSIM_THROW_IF.
|
inlineprotected |
|
inline |
Uses getComponentList<T>() to count the number of underlying subcomponents of the specified type.
|
inlineprotectedvirtual |
Perform any secondary operations, e.g.
to investigate the component or to insert it into a particular internal list (for grouping), after adding the subcomponent to this component. This is intended primarily for composites like Model to have more control over the handling of a component being added to it.
If you override this method, be sure to invoke the base class method first, using code like this :
|
inlineprotectedvirtual |
Add appropriate Simbody elements (if needed) to the System corresponding to this component and specify needed state resources.
extendAddToSystem() is called when the Simbody System is being created to represent a completed system (model) for computation. That is, connect() 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 extendAddToSystem() only.
Note that this method is const; you may not modify your model component or the containing model during this call. Any modifications you need should instead be performed in finalizeFromProperties() or at the latest connect(), which are non-const. The only exception is that you may need to record access information for resources you create in the system, such as an index number. For most Components, OpenSim base classes either provide convenience methods or handle indices automatically. Otherwise, you must declare indices as mutable data members so that you can set them here.
If you override this method, be sure to invoke the base class method at the beginning, using code like this:
This method assumes that this Component's addToSystem will be invoked before its subcomponents. If you need your subcomponents to be added to the system, first (e.g. require of a Force to be anchored to a SimTK::MobilizedBody specified by subcomponents) then you must implement: extendAddToSystemAfterSubcomponents(). It is possible to implement both method to add system elements before and then after your subcomponents have added themselves. Caution is required that Simbody elements are not added twice especially when order is unimportant.
[in,out] | system | The MultibodySystem being added to. |
Reimplemented in OpenSim::Model, OpenSim::Millard2012AccelerationMuscle, OpenSim::Millard2012EquilibriumMuscle, OpenSim::Muscle, OpenSim::Frame, OpenSim::Joint, OpenSim::Blankevoort1991Ligament, OpenSim::Coordinate, OpenSim::Probe, OpenSim::ScalarActuator, OpenSim::CMC, OpenSim::GeometryPath, OpenSim::CoordinateLimitForce, OpenSim::ScapulothoracicJoint, OpenSim::DeGrooteFregly2016Muscle, OpenSim::ExpressionBasedPointToPointForce, OpenSim::RollingOnSurfaceConstraint, OpenSim::Delp1990Muscle_Deprecated, OpenSim::EllipsoidJoint, OpenSim::Point, OpenSim::SmoothSphereHalfSpaceForce, OpenSim::ActivationFiberLengthMuscle_Deprecated, OpenSim::ClutchedPathSpring, OpenSim::Ligament, OpenSim::FirstOrderMuscleActivationDynamics, OpenSim::Force, OpenSim::Controller, OpenSim::CoordinateCouplerConstraint, OpenSim::FreeJoint, OpenSim::ActivationFiberLengthMuscle, OpenSim::ExpressionBasedCoordinateForce, OpenSim::BallJoint, OpenSim::GimbalJoint, OpenSim::PlanarJoint, OpenSim::UniversalJoint, OpenSim::HuntCrossleyForce, OpenSim::PinJoint, OpenSim::SpringGeneralizedForce, OpenSim::SliderJoint, OpenSim::ConstantDistanceConstraint, OpenSim::PointConstraint, OpenSim::Actuator, OpenSim::AbstractReporter, OpenSim::ActivationCoordinateActuator, OpenSim::PointOnLineConstraint, OpenSim::ConstantMuscleActivation, OpenSim::PhysicalOffsetFrame, OpenSim::ElasticFoundationForce, OpenSim::WeldJoint, OpenSim::Ground, OpenSim::DiscreteForces, and OpenSim::PathWrapPoint.
|
inlineprotectedvirtual |
Add appropriate Simbody elements (if needed) to the System after your component's subcomponents have had a chance to add themselves to the system.
If you override this method, be sure to invoke the base class method at the beginning, using code like this:
[in,out] | system | The MultibodySystem being added to. |
Reimplemented in OpenSim::PointToPointSpring, and OpenSim::WeldConstraint.
|
inlineprotectedvirtual |
Perform any necessary initializations required to connect the component (and it subcomponents) to other components and mark the connection status.
Provides a check for error conditions. connect() is invoked on all components to form a directed acyclic graph of the multibody system, prior to creating the Simbody MultibodySystem to represent it computationally. It may also be invoked at times just for its error-checking side effects.
The "root" Component argument is the root node of the directed graph composed of all the subcomponents (and their subcomponents and so on ...) and their interconnections. This should yield a fully connected root component. For ModelComponents this is the Model component. But a Model can be connected to an environment or world component with several other models, by choosing the environment/world as the root.
If you override this method, be sure to invoke the base class method first, using code like this:
Reimplemented in OpenSim::TableReporter_< InputT, ValueT >, and OpenSim::Geometry.
|
inlineprotectedvirtual |
Perform any time-invariant calculations, data structure initializations, or other configuration based on the component's properties to form a functioning (but not yet connected) component.
For example, each property should be checked to ensure that its value is within an acceptable range. When this method returns, the component will be marked as being up-to-date with its properties. Do not perform any configuration that depends on the SimTK::MultibodySystem; it is not available at this point.
If you override this method, be sure to invoke the base class method first, using code like this:
Reimplemented in OpenSim::Model, OpenSim::Mesh, OpenSim::Joint, OpenSim::MuscleFixedWidthPennationModel, OpenSim::Blankevoort1991Ligament, OpenSim::Thelen2003Muscle, OpenSim::EspositoMiller2018Force, OpenSim::GeometryPath, OpenSim::ExternalForce, OpenSim::ModelComponent, OpenSim::PhysicalFrame, OpenSim::DeGrooteFregly2016Muscle, OpenSim::PathSpring, OpenSim::OffsetFrame< PhysicalFrame >, OpenSim::FunctionBasedBushingForce, OpenSim::WrapObject, OpenSim::ClutchedPathSpring, OpenSim::Ligament, OpenSim::MuscleFirstOrderActivationDynamicModel, OpenSim::ControlSetController, OpenSim::Body, OpenSim::PathPoint, OpenSim::WrapTorus, OpenSim::WrapSphere, OpenSim::WrapCylinder, OpenSim::WrapEllipsoid, OpenSim::ModelComponentSet< T >, OpenSim::ModelComponentSet< ExternalForce >, OpenSim::ModelComponentSet< ContactGeometry >, OpenSim::ModelComponentSet< WrapObject >, OpenSim::ModelComponentSet< Force >, OpenSim::ModelComponentSet< Joint >, OpenSim::ModelComponentSet< Probe >, OpenSim::ModelComponentSet< Controller >, OpenSim::ModelComponentSet< ModelComponent >, OpenSim::ModelComponentSet< Marker >, OpenSim::ModelComponentSet< Body >, OpenSim::ModelComponentSet< Constraint >, and OpenSim::Ground.
Referenced by OpenSim::TableSource_< ET >::getRowAtTime().
|
inlineprotectedvirtual |
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 extendAddToSystem() 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:
state | The state that will receive the new initial conditions. |
Reimplemented in OpenSim::Model, OpenSim::Millard2012AccelerationMuscle, OpenSim::Millard2012EquilibriumMuscle, OpenSim::Muscle, OpenSim::Joint, OpenSim::Thelen2003Muscle, OpenSim::Coordinate, OpenSim::GeometryPath, OpenSim::DeGrooteFregly2016Muscle, OpenSim::RollingOnSurfaceConstraint, OpenSim::EllipsoidJoint, OpenSim::ActivationFiberLengthMuscle_Deprecated, OpenSim::ClutchedPathSpring, OpenSim::FirstOrderMuscleActivationDynamics, OpenSim::CorrectionController, OpenSim::Force, OpenSim::FreeJoint, OpenSim::ActivationFiberLengthMuscle, OpenSim::BallJoint, OpenSim::GimbalJoint, OpenSim::Constraint, OpenSim::ActivationCoordinateActuator, and OpenSim::ConstantMuscleActivation.
|
protectedvirtual |
Perform computations that may depend on applied forces.
|
protectedvirtual |
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.
Reimplemented in OpenSim::Ligament, and OpenSim::PathActuator.
|
protectedvirtual |
Perform computations that depend only on instance variables, like lengths and masses.
Reimplemented in OpenSim::Coordinate, and OpenSim::SmoothSphereHalfSpaceForce.
|
protectedvirtual |
Obtain and name state resources (like state variables allocated by an underlying Simbody component) that may be needed, depending on modeling options.
Also, perform any computations that depend only on topology and selected modeling options.
|
protectedvirtual |
Perform computations that depend only on position-level state variables and computations performed in earlier stages (including time).
|
protectedvirtual |
Perform computations that may depend on anything but are only used for reporting and cannot affect subsequent simulation behavior.
Reimplemented in OpenSim::AbstractReporter.
|
protectedvirtual |
Perform computations that depend only on time and earlier stages.
|
protectedvirtual |
Obtain state resources that are needed unconditionally, and perform computations that depend only on the system topology.
Reimplemented in OpenSim::DiscreteController.
|
protectedvirtual |
Perform computations that depend only on velocity-level state variables and computations performed in earlier stages (including position, and time).
|
inlineprotectedvirtual |
Update this component's property values to match the specified State, if the component has created any state variable that is intended to correspond to a property.
Thus, state variable values can persist as part of the model component and be serialized as a property.
If you override this method, be sure to invoke the base class method first, using code like this:
state | The State from which values may be extracted to set persistent property values. |
Reimplemented in OpenSim::Model, OpenSim::Millard2012AccelerationMuscle, OpenSim::Millard2012EquilibriumMuscle, OpenSim::Muscle, OpenSim::Joint, OpenSim::Thelen2003Muscle, OpenSim::Coordinate, OpenSim::RollingOnSurfaceConstraint, OpenSim::DeGrooteFregly2016Muscle, OpenSim::EllipsoidJoint, OpenSim::ActivationFiberLengthMuscle_Deprecated, OpenSim::ClutchedPathSpring, OpenSim::FirstOrderMuscleActivationDynamics, OpenSim::Force, OpenSim::FreeJoint, OpenSim::ActivationFiberLengthMuscle, OpenSim::BallJoint, OpenSim::GimbalJoint, OpenSim::Constraint, OpenSim::ActivationCoordinateActuator, and OpenSim::ConstantMuscleActivation.
void OpenSim::Component::finalizeConnections | ( | Component & | root | ) |
Satisfy the Component's connections specified by its Sockets and Inputs.
Locate Components and their Outputs to satisfy the connections in an aggregate Component (e.g. Model), which is the root of a tree of Components.
Referenced by OpenSim::Model::finalizeConnections().
void OpenSim::Component::finalizeFromProperties | ( | ) |
Define a Component's internal data members and structure according to its properties.
This includes its subcomponents as part of the component ownership tree and identifies its owner (if present) in the tree. finalizeFromProperties propagates to all of the component's subcomponents prior to invoking the virtual extendFinalizeFromProperties() on itself. Note that if the Component has already been added to a System (result of addToSystem(); e.g., Model::initSystem()) when finalizeFromProperties() is called, then finalizeFromProperties() disassociates the component from that System.
Referenced by OpenSim::ModOpIgnoreActivationDynamics::operate(), OpenSim::ModOpIgnoreTendonCompliance::operate(), OpenSim::ModOpTendonComplianceDynamicsModeDGF::operate(), OpenSim::ModOpScaleMaxIsometricForce::operate(), OpenSim::ModOpUseImplicitTendonComplianceDynamicsDGF::operate(), OpenSim::ModOpRemoveMuscles::operate(), OpenSim::ModOpIgnorePassiveFiberForcesDGF::operate(), OpenSim::ModOpPassiveFiberStrainAtOneNormForceDGF::operate(), OpenSim::ModOpScaleActiveFiberForceCurveWidthDGF::operate(), OpenSim::ModOpFiberDampingDGF::operate(), and OpenSim::ModelProcessor::process().
|
inline |
Find a Component to which this Component is an ancestor—in other words, a Component that is directly owned by this Component or is owned by one of its sub-components, sub-sub-components, etc.
The Component can be found by type (by specifying a template argument) and either path or name.
Here is an example of searching for a component of any type with the name 'elbow_flexion':
Here, we require that 'elbow_flexion' is of type Coordinate.
The search can be sped up considerably if the path or even partial path name is known. For example, "forearm/elbow/elbow_flexion" will find the Coordinate component of the elbow joint that connects the forearm body in linear time (linear search for name at each component level). Whereas supplying "elbow_flexion" requires a tree search. Returns nullptr (None in Python, empty array in Matlab) if Component of that specified name cannot be found.
NOTE: If the component name is ambiguous, an exception is thrown. To disambiguate, more information must be provided, such as the template argument to specify the type and/or a path rather than just the name.
References OpenSim::Exception::Exception(), OpenSim::ComponentPath::getComponentName(), OpenSim::ComponentPath::pushBack(), and OpenSim::ComponentPath::toString().
|
inline |
Same as findComponent(const ComponentPath&), but accepting a string (a path or just a name) as input.
|
inlinevirtual |
Optional method for generating arbitrary display geometry that reflects this Component 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.
Please note that there is a precondition that the state passed in to generateDecorations be realized to Stage::Position. If your component can visualize quantities realized at Velocity, Dynamics or Acceleration stages, then you must check that the stage has been realized before using/requesting stage dependent values. It is forbidden to realize the model to a higher stage within generateDecorations, because this can trigger costly side- effects such as evaluating all model forces even when performing a purely kinematic study.
If you override this method, be sure to invoke the base class method first, using code like this:
[in] | fixed | If true , generate only geometry that is fixed to a PhysicalFrame, configuration, and velocity. Otherwise generate only such dependent geometry. |
[in] | hints | See 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] | state | The State for which geometry should be produced. See below for more information. |
[in,out] | appendToThis | Array 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 in OpenSim::Model, OpenSim::FrameGeometry, OpenSim::ExpressionBasedBushingForce, OpenSim::GeometryPath, OpenSim::FunctionBasedBushingForce, OpenSim::EllipsoidJoint, OpenSim::SmoothSphereHalfSpaceForce, OpenSim::Geometry, OpenSim::ConstantDistanceConstraint, OpenSim::ContactMesh, OpenSim::ContactSphere, OpenSim::Marker, OpenSim::IMU, OpenSim::ContactHalfSpace, OpenSim::WrapTorus, OpenSim::WrapSphere, OpenSim::WrapCylinder, OpenSim::WrapEllipsoid, and OpenSim::StationPlaneContactForce.
|
inlineprotected |
Get the value of the i-th element of the components property.
ComponentPath OpenSim::Component::getAbsolutePath | ( | ) | const |
Return a ComponentPath of the absolute path of this Component.
Note that this has more overhead than calling getName()
because it traverses up the tree to generate the absolute pathname (and its computational cost is thus a function of depth). Consider other options if this is repeatedly called and efficiency is important. For instance, getAbsolutePathString()
is faster if you only need the path as a string.
std::string OpenSim::Component::getAbsolutePathString | ( | ) | const |
Get the complete (absolute) pathname for this Component to its ancestral Component, which is the root of the tree to which this Component belongs.
For example: a Coordinate Component would have an absolute path name like: /arm26/elbow_r/flexion
. Accessing a Component by its absolutePathName from root is guaranteed to be unique. The absolutePathName is generated on-the-fly by traversing the ownership tree and, therefore, calling this method is not "free".
Referenced by OpenSim::ConnecteeNotSpecified::ConnecteeNotSpecified(), OpenSim::Socket< T >::findAndConnect(), and OpenSim::Socket< T >::getConnectee().
|
inline |
Get the index of a Component's cache variable in the Subsystem for allocations.
T | Type of value held in the cache variable |
cv | A CacheVariable<T>, as allocated by Component::addCacheVariable |
SimTK::CacheEntryIndex OpenSim::Component::getCacheVariableIndex | ( | const std::string & | name | ) | const |
Get the index of a Component's cache variable in the Subsystem for allocations.
T | Type of value held in the cache variable |
name | Name of the cache variable, as provided to Component::addCacheVariable |
|
inline |
Get the value of a cache variable allocated by this Component by name.
state | the State from which to get the value |
name | the name of the cache variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
inline |
Get the value of a cache variable allocated by this Component.
state | the State from which to get the value |
cv | the cache variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
inlinestatic |
This returns "Component".
See getConcreteClassName() if you want the class name of the underlying concrete object instead.
This is generated by the OpenSim_DECLARE_*_OBJECT
macros.
|
inline |
Get a unique subcomponent of this Component by its path name and type 'C'.
Throws ComponentNotFoundOnSpecifiedPath exception if the component at that path name location does not exist OR it is not of the correct type. For example,
returns coord which is a Coordinate named "elbow_flexion" from a Joint named "right_elbow" given it is a child of the Component (Model) model. If unsure of a Component's path or whether or not it exists in the model, use printComponentsMatching() or hasComponent().
This template function cannot be used in Python/Java/MATLAB; see the non-templatized getComponent().
pathname | a pathname of a Component of interest |
ComponentNotFoundOnSpecifiedPath | if no component exists |
Referenced by OpenSim::analyze(), and OpenSim::Input< T >::finalizeConnection().
|
inline |
References OpenSim::Exception::OPENSIM_THROW, and OpenSim::ComponentPath::toString().
|
inline |
Similar to the templatized getComponent(), except this returns the component as the generic Component type.
This can be used in Python/Java/MATLAB. Here is an example of using this in MATLAB:
Exception: in Python, you will get the concrete type (in most cases):
|
inline |
Get an iterator through the underlying subcomponents that this component is composed of.
The hierarchy of Components/subComponents forms a tree. The order of the Components is that of tree preorder traversal so that a component is traversed before its subcomponents.
The returned ComponentList does not permit modifying any components; if you want to modify the components, see updComponentList().
Referenced by OpenSim::analyze(), and OpenSim::MocoProblemRep::getImplicitComponentReferencePtrs().
|
overridepure virtual |
Returns the class name of the concrete Object-derived class of the actual object referenced by this Object, as a string.
This is the string that is used as the tag for this concrete object in an XML file. Every concrete class derived from Object automatically overrides this method via the declaration macro it uses. See getClassName() to get the class name of the referencing (possibly abstract) class rather than the concrete object.
Implements OpenSim::Object.
Implemented in OpenSim::FrameGeometry, OpenSim::Mesh, OpenSim::Brick, OpenSim::Torus, OpenSim::Cone, OpenSim::Cylinder, OpenSim::Ellipsoid, OpenSim::Sphere, OpenSim::AnalyticGeometry, OpenSim::Model, OpenSim::Millard2012AccelerationMuscle, OpenSim::ConsoleReporter_< T >, OpenSim::Arrow, OpenSim::EspositoMiller2018Force, OpenSim::Bhargava2004SmoothedMuscleMetabolics, OpenSim::Umberger2010MuscleMetabolicsProbe, OpenSim::Millard2012EquilibriumMuscle, OpenSim::LineGeometry, OpenSim::Bhargava2004MuscleMetabolicsProbe, OpenSim::TableReporter_< InputT, ValueT >, OpenSim::HuntCrossleyForce, OpenSim::ElasticFoundationForce, OpenSim::Blankevoort1991Ligament, OpenSim::MeyerFregly2016Force, OpenSim::ScalarActuator, OpenSim::HuntCrossleyForce, OpenSim::ElasticFoundationForce, OpenSim::Probe, OpenSim::Thelen2003Muscle, OpenSim::Joint, OpenSim::Reporter< InputT >, OpenSim::Reporter< T >, OpenSim::DeGrooteFregly2016Muscle, OpenSim::MuscleFixedWidthPennationModel, OpenSim::ModelComponent, OpenSim::FirstOrderMuscleActivationDynamics, OpenSim::Frame, OpenSim::MuscleFirstOrderActivationDynamicModel, OpenSim::AckermannVanDenBogert2010Force, OpenSim::Muscle, OpenSim::CMC, OpenSim::SmoothSphereHalfSpaceForce, OpenSim::ExternalLoads, OpenSim::OffsetFrame< PhysicalFrame >, OpenSim::ClutchedPathSpring, OpenSim::CoordinateLimitForce, OpenSim::GeometryPath, OpenSim::PhysicalFrame, OpenSim::Delp1990Muscle_Deprecated, OpenSim::RigidTendonMuscle, OpenSim::ModelComponentSet< T >, OpenSim::RollingOnSurfaceConstraint, OpenSim::ModelComponentSet< ExternalForce >, OpenSim::ModelComponentSet< ContactGeometry >, OpenSim::ModelComponentSet< WrapObject >, OpenSim::ModelComponentSet< Force >, OpenSim::ModelComponentSet< Joint >, OpenSim::ModelComponentSet< Probe >, OpenSim::ModelComponentSet< Controller >, OpenSim::ModelComponentSet< ModelComponent >, OpenSim::ModelComponentSet< Marker >, OpenSim::ModelComponentSet< Body >, OpenSim::ModelComponentSet< Constraint >, OpenSim::ScapulothoracicJoint, OpenSim::MuscleActivationDynamics, OpenSim::ExpressionBasedPointToPointForce, OpenSim::ExternalForce, OpenSim::Controller, OpenSim::ActivationFiberLengthMuscle, OpenSim::Geometry, OpenSim::ExpressionBasedBushingForce, OpenSim::FunctionBasedBushingForce, OpenSim::PathSpring, OpenSim::PrescribedForce, OpenSim::TwoFrameLinker< Force, PhysicalFrame >, OpenSim::TwoFrameLinker< Constraint, PhysicalFrame >, OpenSim::ActivationFiberLengthMuscle_Deprecated, OpenSim::BushingForce, OpenSim::Coordinate, OpenSim::CustomJoint, OpenSim::Schutte1993Muscle_Deprecated, OpenSim::TorqueActuator, OpenSim::Ligament, OpenSim::BallJoint, OpenSim::CoordinateCouplerConstraint, OpenSim::BodyActuator, OpenSim::PointActuator, OpenSim::Thelen2003Muscle_Deprecated, OpenSim::PointToPointActuator, OpenSim::Actuator, OpenSim::Point, OpenSim::FreeJoint, OpenSim::UnilateralConstraint, OpenSim::ActivationCoordinateActuator, OpenSim::CoordinateActuator, OpenSim::McKibbenActuator, OpenSim::ForceSet, OpenSim::JointInternalPowerProbe, OpenSim::PhysicalOffsetFrame, OpenSim::WeldConstraint, OpenSim::ControlSetController, OpenSim::EllipsoidJoint, OpenSim::CorrectionController, OpenSim::AbstractReporter, OpenSim::TableSource_< ET >, OpenSim::ExperimentalMarker, OpenSim::WrapObject, OpenSim::Set< Joint, ModelComponent >, OpenSim::Set< Marker, ModelComponent >, OpenSim::Set< T, ModelComponent >, OpenSim::Set< ContactGeometry, ModelComponent >, OpenSim::Set< Controller, ModelComponent >, OpenSim::Set< WrapObject, ModelComponent >, OpenSim::Set< Probe, ModelComponent >, OpenSim::Set< ModelComponent, ModelComponent >, OpenSim::Set< Body, ModelComponent >, OpenSim::Set< Constraint, ModelComponent >, OpenSim::Set< ExternalForce, ModelComponent >, OpenSim::Set< Force, ModelComponent >, OpenSim::SpringGeneralizedForce, OpenSim::ControllerSet, OpenSim::PathActuator, OpenSim::ExperimentalFrame, OpenSim::PinJoint, OpenSim::UniversalJoint, OpenSim::AccelerationMotion, OpenSim::PrescribedController, OpenSim::ActuatorPowerProbe, OpenSim::ContactGeometry, OpenSim::Force, OpenSim::Marker, OpenSim::MovingPathPoint, OpenSim::MuscleActiveFiberPowerProbe, OpenSim::SystemEnergyProbe, OpenSim::PointConstraint, OpenSim::Constraint, OpenSim::GimbalJoint, OpenSim::PlanarJoint, OpenSim::WrapCylinder, OpenSim::WrapEllipsoid, OpenSim::WrapSphere, OpenSim::WrapTorus, OpenSim::SignalGenerator, OpenSim::ActuatorForceProbe, OpenSim::ConditionalPathPoint, OpenSim::JointSet, OpenSim::Station, OpenSim::IMU, OpenSim::PositionMotion, OpenSim::Body, OpenSim::SliderJoint, OpenSim::WeldJoint, OpenSim::PathWrapPoint, OpenSim::ConstantMuscleActivation, OpenSim::ComponentSet, OpenSim::Ground, OpenSim::PointToPointSpring, OpenSim::ConstantDistanceConstraint, OpenSim::ZerothOrderMuscleActivationDynamics, OpenSim::ElasticFoundationForce, OpenSim::ProbeSet, OpenSim::PointOnLineConstraint, OpenSim::StatesTrajectoryReporter, OpenSim::WrapObjectSet, OpenSim::DiscreteForces, OpenSim::AbstractPathPoint, OpenSim::ContactGeometrySet, OpenSim::ContactHalfSpace, OpenSim::HuntCrossleyForce, OpenSim::PathPoint, OpenSim::BodySet, OpenSim::ConstraintSet, OpenSim::ContactMesh, OpenSim::MarkerSet, OpenSim::MocoScaleFactor, OpenSim::Bhargava2004SmoothedMuscleMetabolics_MuscleParameters, OpenSim::ContactSphere, OpenSim::ExpressionBasedCoordinateForce, OpenSim::DiscreteController, and OpenSim::StationPlaneContactForce.
Referenced by OpenSim::ConnecteeNotSpecified::ConnecteeNotSpecified(), OpenSim::Socket< T >::finalizeConnection(), and OpenSim::Socket< T >::getConnectee().
|
inline |
Get the "connectee" object that the Component's Socket is bound to.
Guaranteed to be valid only after the Component has been connected (that is connect() has been invoked). If the Socket has not been connected, an exception is thrown.
This method is for getting the concrete connectee object, and is not available in scripting. If you want generic access to the connectee as an Object, use the non-templated version.
T | the type of the Connectee (e.g., PhysicalFrame). |
name | the name of the socket |
Example:
References OpenSim::Exception::Exception(), OpenSim::Socket< T >::getConnectee(), and OpenSim::Socket< T >::isConnected().
|
inline |
Get the connectee as an Object.
This means you will not have access to the methods on the concrete connectee. This is the method you must use in MATLAB to access the connectee.
Example:
In MATLAB, if you want the concrete type, you need to downcast the Object. Here is an example where you know the "parent_frame" is a Body:
Exception: in Python, you will get the concrete type (in most cases):
References OpenSim::Exception::Exception(), OpenSim::AbstractSocket::getConnecteeAsObject(), and OpenSim::AbstractSocket::isConnected().
|
protected |
Get the index of a Component's discrete variable in the Subsystem for allocations.
This method is intended for derived Components that may need direct access to its underlying Subsystem.
double OpenSim::Component::getDiscreteVariableValue | ( | const SimTK::State & | state, |
const std::string & | name | ||
) | const |
Get the value of a discrete variable allocated by this Component by name.
state | the State from which to get the value |
name | the name of the state variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
protected |
Access this Component's immediate subcomponents (not those owned by subcomponents)
Referenced by traversePathToComponent().
|
inline |
Get an Input provided by this Component by name.
C++ example: get an Input from a Component in the model
If you have not yet called finalizeFromProperties() on this component, this function will update the Input (to tell it which component it's in) before providing it to you.
name | the name of the Input |
|
inline |
Get a concrete Input that you can directly ask for its values.
If you have not yet called finalizeFromProperties() on this component, this function will update the Input (to tell it which component it's in) before providing it to you.
name | the name of the Input |
|
inline |
Collect and return the names of Inputs in this component as an std::vector.
|
inline |
Get the Input value that this component is dependent on.
Checks if Input is connected, otherwise it will throw an exception. You can only call this method for non-list inputs. For list inputs, you must get the input using getInput(), from which you can ask for its values.
state | the State for which to set the value |
name | the name of the input |
References OpenSim::Exception::Exception(), and OpenSim::AbstractSocket::isConnected().
|
inlineprotected |
References OpenSim::Exception::Exception().
int OpenSim::Component::getModelingOption | ( | const SimTK::State & | state, |
const std::string & | name | ||
) | const |
Get a ModelingOption flag for this Component by name.
The flag is an integer corresponding to the index of modelingOptionNames used add the modeling option to the component.
state | the State in which to set the modeling option |
name | the name (string) of the modeling option of interest |
|
protected |
Get the number of Subcomponents adopted by this Component.
|
inlineprotected |
Get the number of Subcomponents immediately owned by this Component.
|
inline |
Access the number of Inputs that this component has.
|
protected |
Get the number of Subcomponents that are data members of this Component.
|
inline |
Access the number of Outputs that this component has.
|
protected |
Get the number of Subcomponents that are properties of this Component.
|
inline |
Get the number of Sockets in this Component.
int OpenSim::Component::getNumStateVariables | ( | ) | const |
Get the number of "continuous" state variables maintained by the Component and its subcomponents.
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
inline |
Get the Output provided by this Component by name.
C++ example: get an Output from a Component in a model
name | the name of the Output |
Referenced by OpenSim::analyze(), and OpenSim::Input< T >::finalizeConnection().
|
inline |
Collect and return the names of Outputs in this component as an std::vector.
Referenced by OpenSim::analyze().
|
inline |
Iterate through all Outputs of this component.
The intent is to use this in a loop as such:
This provides access to the outputs as AbstractOutputs, not as the concrete type. This also does not permit modifying the outputs.
Not available in Python/Java/MATLAB; use getOutputNames() and getOutput() instead.
Referenced by OpenSim::MocoProblemRep::getImplicitComponentReferencePtrs().
|
inline |
const Component& OpenSim::Component::getOwner | ( | ) | const |
Access the owner of this Component.
An exception is thrown if the Component has no owner; in this case, the component is the root component, or is orphaned.
Referenced by traversePathToComponent().
ComponentPath OpenSim::Component::getRelativePath | ( | const Component & | wrt | ) | const |
std::string OpenSim::Component::getRelativePathString | ( | const Component & | wrt | ) | const |
const Component& OpenSim::Component::getRoot | ( | ) | const |
Obtain the root Component, which is this component if it is orphaned.
Referenced by OpenSim::Socket< T >::finalizeConnection(), OpenSim::Input< T >::finalizeConnection(), OpenSim::Socket< T >::findAndConnect(), and traversePathToComponent().
|
inline |
Get an AbstractSocket for the given socket name.
This lets you get information about the connection (like if the socket is connected), but does not give you access to the socket's connectee. For that, use getConnectee().
If you have not yet called finalizeFromProperties() on this component, this function will update the Socket (to tell it which component it's in) before providing it to you.
C++ example
|
inline |
Get a const reference to the concrete Socket provided by this Component by name.
If you have not yet called finalizeFromProperties() on this component, this function will update the Socket (to tell it which component it's in) before providing it to you.
name | the name of the Socket |
|
inline |
Collect and return the names of the sockets in this component.
You can use this to iterate through the sockets:
|
protected |
Get the index of a Component's continuous state variable in the Subsystem for allocations.
This method is intended for derived Components that may need direct access to its underlying Subsystem.
double OpenSim::Component::getStateVariableDerivativeValue | ( | const SimTK::State & | state, |
const std::string & | name | ||
) | const |
Get the value of a state variable derivative computed by this Component.
state | the State for which to get the derivative value |
name | the name (string) of the state variable of interest |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
Array<std::string> OpenSim::Component::getStateVariableNames | ( | ) | const |
Get the names of "continuous" state variables maintained by the Component and its subcomponents.
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
protected |
Get the System Index of a state variable allocated by this Component.
Returns an InvalidIndex if no state variable with the name provided is found.
stateVariableName | the name of the state variable |
double OpenSim::Component::getStateVariableValue | ( | const SimTK::State & | state, |
const std::string & | name | ||
) | const |
Get the value of a state variable allocated by this Component.
To connect this StateVariable as an input to another component (such as a Reporter), use getOutput(name); each state variable has a corresponding Output:
state | the State for which to get the value |
name | the name (string) of the state variable of interest |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
double OpenSim::Component::getStateVariableValue | ( | const SimTK::State & | state, |
const ComponentPath & | path | ||
) | const |
Get the value of a state variable allocated by this Component.
To connect this StateVariable as an input to another component (such as a Reporter), use getOutput(name); each state variable has a corresponding Output:
state | the State for which to get the value |
name | path to the state variable of interest |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
SimTK::Vector OpenSim::Component::getStateVariableValues | ( | const SimTK::State & | state | ) | const |
Get all values of the state variables allocated by this Component.
Includes state variables allocated by its subcomponents.
state | the State for which to get the value |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
inline |
Get the underlying MultibodySystem that this component is connected to.
Make sure you have called Model::initSystem() prior to accessing the System. Throws an Exception if the System has not been created or the Component has not added itself to the System.
Referenced by OpenSim::analyze().
|
inline |
Query if there is a component (of any type) at the specified path name.
For example,
checks if model
has a subcomponent "right_elbow," which has a subcomponent "elbow_flexion."
|
inline |
Query if there is a component of a given type at the specified path name.
For example,
checks if model
has a subcomponent "right_elbow," which has a subcomponent "elbow_flexion," and that "elbow_flexion" is of type Coordinate. This method cannot be used from scripting; see the non-templatized hasComponent().
bool OpenSim::Component::hasOwner | ( | ) | const |
(For advanced users) Check if this Component has an owner.
A component may not have an owner if it: (1) is the root component, or (2) has not been added to another component
Referenced by traversePathToComponent().
|
inline |
Check if this component has an underlying MultibodySystem.
Returns false if the System has not been created OR if this Component has not added itself to the System.
Referenced by OpenSim::TableProcessor::processAndConvertToRadians().
|
protected |
Build the tree of Components from this component through its descendants.
This method is invoked whenever a ComponentList<C> is requested. Note that all components must have been added to the model (or its subcomponents), otherwise it will not be included in the tree and will not be found for iteration or for connection. The implementation populates the _nextComponent ReferencePtr with a pointer to the next Component in tree pre-order traversal.
ComponentIsRootWithNoSubcomponents | if the Component is the root and yet has no subcomponents. |
void OpenSim::Component::initStateFromProperties | ( | SimTK::State & | state | ) | const |
Initialize Component's state variable values from its properties.
bool OpenSim::Component::isCacheVariableValid | ( | const SimTK::State & | state, |
const std::string & | name | ||
) | const |
Returns true if the cache variable, identified by name
, is valid.
This method enables callers to monitor the validity of the cache variable, which enables the caller to decide whether to update the cache variable's value (or not). When computing an update is costly, use this method to check whether computing the value is necessary.
state | the State in which the cache variable's value resides |
name | the name of the cache variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
inline |
Returns true if the cache variable is valid.
This method enables callers to monitor the validity of the cache variable, which enables the caller to decide whether to update the cache variable's value (or not). When computing an update is costly, use this method to check whether computing the value is necessary.
state | the State in which the cache variable's value resides |
cv | the cache variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
bool OpenSim::Component::isComponentInOwnershipTree | ( | const Component * | component | ) | const |
Does the provided component already exist anywhere in the ownership tree (not just subcomponents of this component)?
void OpenSim::Component::markCacheVariableInvalid | ( | const SimTK::State & | state, |
const std::string & | name | ||
) | const |
Marks the value of a cache variable, identified by name
, as invalid.
Upon marking a cache variable's value as invalid, it will remain invalid until Component::markCacheVariableValid
is called (or a method which uses that, such as Component::setCacheVariableValue
, is called).
Component::addCacheVariable
.length
state variablelength
(e.g. strain
)length
may invalidate the strain
indirectly (depending on how the state variable is handled)state | the State in which the cache variable's value resides |
name | the name of the cache variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
inline |
Marks the value of a cache variable as invalid.
Upon marking a cache variable's value as invalid, it will remain invalid until Component::markCacheVariableValid
is called (or a method which uses that, such as Component::setCacheVariableValue
, is called).
Component::addCacheVariable
.length
state variablelength
(e.g. strain
)length
may invalidate the strain
indirectly (depending on how the state variable is handled)state | the State in which the cache variable's value resides |
cv | the cache variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
void OpenSim::Component::markCacheVariableValid | ( | const SimTK::State & | state, |
const std::string & | name | ||
) | const |
Marks the value of a cache variable, identified by name
, as valid.
Upon marking a cache variable's value as valid, the cache variable will remain valid until either:
Component::addCacheVariable
Component::markCacheVariableInvalid
This method causes Component::isCacheVariableValid
to return true. Component::isCacheVariableValid
is commonly used by value-getting methods to decide on whether to return the value as-is or recompute the value. Therefore, if a cache variable is not marked as valid then the cache variable's value may be recomputed more than necessary, which may be costly.
state | the State in which the cache variable's value resides |
name | the name of the cache variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
inline |
Marks the value of a cache variable as valid.
Upon marking a cache variable's value as valid, the cache variable will remain valid until either:
Component::addCacheVariable
Component::markCacheVariableInvalid
This method causes Component::isCacheVariableValid
to return true. Component::isCacheVariableValid
is commonly used by value-getting methods to decide on whether to return the value as-is or recompute the value. Therefore, if a cache variable is not marked as valid then the cache variable's value may be recomputed more than necessary, which may be costly.
state | the State in which the cache variable's value resides |
cv | the cache variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
staticprotected |
For internal use.
Update absolute connectee paths in all sockets and inputs in the subcomponent by prepending the absolute path of the subcomponent. To be used when adding subcomponent to another component.
unsigned OpenSim::Component::printComponentsMatching | ( | const std::string & | substring | ) | const |
Print a list to the console of all components whose absolute path name contains the given string.
You might use this if (a) you know the name of a component in your model but don't know its absolute path, (b) if you want to find all components with a given name, or (c) to get a list of all components on the right leg of a model (if all components on the right side have "_r" in their name).
A function call like:
may produce output like:
* /leg_model/right_hip/rotation * /leg_model/left_hip/rotation *
void OpenSim::Component::printInputInfo | ( | ) | const |
List all the inputs of this component and whether or not they are connected.
Also list the (desired) connectee paths for the inputs.
void OpenSim::Component::printOutputInfo | ( | const bool | includeDescendants = true | ) | const |
Print outputs of this component and optionally, those of all subcomponents.
void OpenSim::Component::printSocketInfo | ( | ) | const |
List all the Sockets of this component and whether or not they are connected.
Also list the connectee paths for sockets that are connected.
void OpenSim::Component::printSubcomponentInfo | ( | ) | const |
List all subcomponents by name and recurse into these components to list their subcomponents, and so on.
|
inline |
|
inlineprotected |
resetSubcomponentOrder clears this Component's list of ordered subcomponents (but otherwise leaves subcomponents untouched).
You can form the ordered list using setNextSubcomponentInSystem() above.
References OpenSim::Exception::OPENSIM_THROW.
|
inlinestatic |
For use in MATLAB and Python to access the concrete class.
Example: cObj = Component.safeDownCast(obj)
. This is equivalent to dynamic_cast<Component*>(obj)
in C++.
|
inlineprotected |
Set the value of the i-th element of components property.
|
inline |
Set the value of a cache variable, identified by name
, to a new value and mark the cache variable as valid.
state | the State in which to store the new value |
k | the name of the cache variable |
value | the new value for this cache variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
inline |
Set the value of a cache variable to a new value and mark the cache variable as valid.
state | the State in which to store the new value |
cv | the cache variable to update |
value | the new value for the cache variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
void OpenSim::Component::setDiscreteVariableValue | ( | SimTK::State & | state, |
const std::string & | name, | ||
double | value | ||
) | const |
Set the value of a discrete variable allocated by this Component by name.
state | the State for which to set the value |
name | the name of the discrete variable |
value | the value to set |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
void OpenSim::Component::setModelingOption | ( | SimTK::State & | state, |
const std::string & | name, | ||
int | flag | ||
) | const |
Set the value of a ModelingOption flag for this Component.
if the integer value exceeds the number of option names used to define the options, an exception is thrown. The SimTK::State Stage will be reverted back to Stage::Instance.
state | the State in which to set the flag |
name | the name (string) of the modeling option of interest |
flag | the desired flag (int) value specifying the modeling option |
|
protected |
Helper method to enable Component makers to specify the order of their subcomponents to be added to the System during addToSystem().
It is highly unlikely that you will need to reorder the subcomponents of your custom component. This ability is primarily intended for Model (and other top-level) components that have the responsibility of creating a valid SimTK::MultibodySystem. MultibodySystem (Simbody) elements such as MobilizedBodies must be added sequentially to form a Multibody tree. SimTK::Constraints and SimTK::Forces must be applied to MobilizedBodies that are already present in the MultibodySystem. The Model component handles this order for you and should handle user-defined Components without any issues. You should rarely need to use this method yourself. If needed, use this method in extendFinalizeConnections() of your Component (or within your extendConnectToModel() for ModelComponents) to set the order of your subcomponents. For example, Model orders subcomponents according to the Multibody tree and adds bodies and joints in order starting from Ground and growing outward. If the subcomponent already appears in the ordered list setting it later in the list has no effect. The list remains unique. NOTE: If you do need to set the order of your subcomponents, you must do so for all your immediate subcomponents, otherwise those components not in the ordered list will not be added to the System.
|
protected |
Set this Component's reference to its owning Component
void OpenSim::Component::setPropertiesFromState | ( | const SimTK::State & | state | ) |
Set Component's properties given a state.
|
protected |
Set the derivative of a state variable by name when computed inside of this Component's computeStateVariableDerivatives() method.
state | the State for which to set the value |
name | the name of the state variable |
deriv | the derivative value to set |
void OpenSim::Component::setStateVariableValue | ( | SimTK::State & | state, |
const std::string & | name, | ||
double | value | ||
) | const |
Set the value of a state variable allocated by this Component by name.
state | the State for which to set the value |
name | the name of the state variable |
value | the value to set |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
void OpenSim::Component::setStateVariableValues | ( | SimTK::State & | state, |
const SimTK::Vector & | values | ||
) | const |
Set all values of the state variables allocated by this Component.
Includes state variables allocated by its subcomponents. Note, this method simply sets the values on the input State. If other conditions must be met (such as satisfying kinematic constraints for Coordinates, or fiber and tendon equilibrium for muscles) you must invoke the appropriate methods on Model (e.g. assemble() to satisfy constraints or equilibrateMuscles()) to satisfy these conditions starting from the State values provided by setStateVariableValues.
state | the State whose values are set |
values | Vector of state variable values of length getNumStateVariables() in the order returned by getStateVariableNames() |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
protected |
|
inlineprotected |
const StateVariable* OpenSim::Component::traverseToStateVariable | ( | const std::string & | pathName | ) | const |
Get a StateVariable anywhere in the Component tree, given a StateVariable path.
The StateVariable doesn't need to be in a subcomponent of this component; it could be located in a different branch of the Component tree (in such a case, the specified path might begin with "../").
This returns nullptr if a StateVariable does not exist at the specified path or if the path is invalid.
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
const StateVariable* OpenSim::Component::traverseToStateVariable | ( | const ComponentPath & | path | ) | const |
Get a StateVariable anywhere in the Component tree, given a StateVariable path.
The StateVariable doesn't need to be in a subcomponent of this component; it could be located in a different branch of the Component tree (in such a case, the specified path might begin with "../").
This returns nullptr if a StateVariable does not exist at the specified path or if the path is invalid.
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
inlineprotected |
Get a writable reference to the i-th element of the components property.
|
overrideprotectedvirtual |
Handle a change in XML syntax for Sockets.
Reimplemented from OpenSim::Object.
Reimplemented in OpenSim::Model, OpenSim::Joint, OpenSim::ModelComponent, OpenSim::Coordinate, OpenSim::Force, OpenSim::TwoFrameLinker< Force, PhysicalFrame >, OpenSim::TwoFrameLinker< Constraint, PhysicalFrame >, OpenSim::Probe, OpenSim::PhysicalFrame, OpenSim::RollingOnSurfaceConstraint, OpenSim::ContactGeometry, OpenSim::WrapObject, OpenSim::Controller, OpenSim::CustomJoint, OpenSim::PointToPointSpring, OpenSim::PrescribedForce, OpenSim::Constraint, OpenSim::ConstantDistanceConstraint, OpenSim::ExternalLoads, OpenSim::PointConstraint, OpenSim::AbstractPathPoint, OpenSim::Marker, OpenSim::MovingPathPoint, and OpenSim::PointOnLineConstraint.
|
inline |
Returns a mutable reference to the value of a cache variable identified by name
.
Note: do not forget to mark the cache variable as valid after updating. Otherwise, it will force a re-computation of the value if the computation method is monitoring the validity of the cache value.
state | the State in which to set the value |
name | the name of the cache variable |
ComponentHasNoSystem | if this Component has not been added to a System (i.e., if initSystem has not been called) |
|
inline |
Returns a mutable reference to the value of a cache variable.
Note: do not forget to mark the cache variable as valid after updating. Otherwise, it will force a re-computation of the value if the computation method is monitoring the validity of the cache value.
state | the State in which to set the value |
cv | the cache variable |
ComponentHasNoSystem | if this Component has not been added to the System (i.e., if initSystem has not been called) |
|
inline |
Get a writable reference to a subcomponent.
Use this method to edit the properties and connections of the subcomponent. Note: the method will mark this Component as out-of-date with its properties and will require finalizeFromProperties() to be invoked directly or indirectly (by finalizeConnections() or Model::initSystem())
name | the pathname of the Component of interest |
ComponentNotFoundOnSpecifiedPath | if no component exists |
|
inline |
|
inline |
Similar to the templatized updComponent(), except this returns the component as the generic Component type.
As with the non-templatized getComponent(), though, this will give the concrete type in Python in most cases.
|
inline |
Similar to getComponentList(), except the resulting list allows one to modify the components.
For example, you could use this method to change the max isometric force of all muscles:
Referenced by OpenSim::ModOpIgnoreActivationDynamics::operate(), OpenSim::ModOpIgnoreTendonCompliance::operate(), OpenSim::ModOpTendonComplianceDynamicsModeDGF::operate(), OpenSim::ModOpScaleMaxIsometricForce::operate(), OpenSim::ModOpUseImplicitTendonComplianceDynamicsDGF::operate(), OpenSim::ModOpIgnorePassiveFiberForcesDGF::operate(), OpenSim::ModOpPassiveFiberStrainAtOneNormForceDGF::operate(), OpenSim::ModOpScaleActiveFiberForceCurveWidthDGF::operate(), and OpenSim::ModOpFiberDampingDGF::operate().
|
inline |
Get a writable reference to an Input provided by this Component by name.
C++ example: get a writable reference to an Input of a Component in a model
If you have not yet called finalizeFromProperties() on this component, this function will update the Input (to tell it which component it's in) before providing it to you.
name | the name of the Input |
|
inlineprotected |
References OpenSim::Exception::Exception().
|
inline |
Get a writable reference to an Output provided by this Component by name.
C++ example: get a writable reference to an Output of a Component in a model
name | the name of the Output |
Referenced by OpenSim::TableSource_< ET >::getRowAtTime(), and OpenSim::TableSource_< ET >::setTable_impl().
|
inline |
Get a writable reference to the AbstractSocket for the given socket name.
Use this method to connect the Socket to something.
C++ example
If you have not yet called finalizeFromProperties() on this component, this function will update the Socket (to tell it which component it's in) before providing it to you.
|
inline |
Get a writable reference to the concrete Socket provided by this Component by name.
If you have not yet called finalizeFromProperties() on this component, this function will update the Socket (to tell it which component it's in) before providing it to you.
name | the name of the Socket |
|
protected |
Get writable reference to the MultibodySystem that this component is connected to.
|
friend |
Class that permits iterating over components/subcomponents (but does not actually contain the components themselves).
|
friend |
Class to iterate over ComponentList returned by getComponentList().
|
friend |
Component OpenSim::Component::components |
"List of components that this component owns and serializes."
This property appears in XML files under the tag <components>. This property holds a list of objects, and was generated with the OpenSim_DECLARE_LIST_PROPERTY macro; see Property to learn about the property system.