1 #ifndef SimTK_SimTKCOMMON_SUBSYSTEM_H_ 
    2 #define SimTK_SimTKCOMMON_SUBSYSTEM_H_ 
   89 {   
return s.
allocateQ(getMySubsystemIndex(), qInit); }
 
   91 {   
return s.
allocateU(getMySubsystemIndex(), uInit); }
 
   93 {   
return s.
allocateZ(getMySubsystemIndex(), zInit); }
 
  101                (getMySubsystemIndex(),invalidates,v,updateDependsOn); }
 
  105                (getMySubsystemIndex(), dependsOn, computedBy, v); }
 
  109 {   
return allocateCacheEntry(state, g, g, v); }
 
  115 {   
return s.
allocateQErr(getMySubsystemIndex(), nqerr); }
 
  117 {   
return s.
allocateUErr(getMySubsystemIndex(), nuerr); }
 
  125 {   
return s.
getQ(getMySubsystemIndex()); }
 
  127 {   
return s.
getU(getMySubsystemIndex()); }
 
  129 {   
return s.
getZ(getMySubsystemIndex()); }
 
  140 {   
return s.
getQDot(getMySubsystemIndex()); }
 
  142 {   
return s.
getUDot(getMySubsystemIndex()); }
 
  144 {   
return s.
getZDot(getMySubsystemIndex()); }
 
  146 {   
return s.
getQDotDot(getMySubsystemIndex()); }
 
  149 {   
return s.
updQDot(getMySubsystemIndex()); }
 
  151 {   
return s.
updUDot(getMySubsystemIndex()); }
 
  153 {   
return s.
updZDot(getMySubsystemIndex()); }
 
  155 {   
return s.
updQDotDot(getMySubsystemIndex()); }
 
  158 {   
return s.
getQErr(getMySubsystemIndex()); }
 
  160 {   
return s.
getUErr(getMySubsystemIndex()); }
 
  167 {   
return s.
getUDotErr(getMySubsystemIndex()); }
 
  174 {   
return s.
updQErr(getMySubsystemIndex()); }
 
  176 {   
return s.
updUErr(getMySubsystemIndex()); }
 
  178 {   
return s.
updUDotErr(getMySubsystemIndex()); }
 
  185 {   
return s.
getQStart(getMySubsystemIndex()); }
 
  187 {   
return s.
getNQ(getMySubsystemIndex()); }
 
  190 {   
return s.
getUStart(getMySubsystemIndex()); }
 
  192 {   
return s.
getNU(getMySubsystemIndex()); }
 
  195 {   
return s.
getZStart(getMySubsystemIndex()); }
 
  197 {   
return s.
getNZ(getMySubsystemIndex()); }
 
  202 {   
return s.
getNQErr(getMySubsystemIndex()); }
 
  207 {   
return s.
getNUErr(getMySubsystemIndex()); }
 
  288 inline const String& getName()    
const;
 
  291 inline const String& getVersion() 
const;
 
  294 inline bool isInSystem() 
const;
 
  298 inline bool isInSameSystem(
const Subsystem& otherSubsystem) 
const;
 
  303 inline const System& getSystem() 
const;
 
  307 inline System& updSystem();
 
  323 {   
return guts && (guts==otherSubsystem.guts); }
 
  328 inline bool isOwnerHandle() 
const; 
 
  333 inline bool subsystemTopologyHasBeenRealized() 
const;
 
  342 inline void invalidateSubsystemTopologyCache() 
const;
 
#define SimTK_ASSERT(cond, msg)
Definition: ExceptionMacros.h:373
 
This file declares the base class AbstractMeasure for all derived Measure handle classes,...
 
#define SimTK_SimTKCOMMON_EXPORT
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:224
 
This is the header which should be included in user programs that would like to make use of all the S...
 
Declares the user-visible part of a SimTK::State, the implementation is done in a separate internal c...
 
Includes internal headers providing declarations for the basic SimTK Core classes.
 
This is the base class for all Measure handle classes.
Definition: Measure.h:151
 
Abstract base class representing an arbitrary value of unknown type.
Definition: Value.h:49
 
This unique integer type is for selecting non-shared cache entries.
 
This unique integer type is for selecting discrete variables.
 
Unique integer type for Subsystem-local, per-stage event indexing.
 
This is the base handle class for all Measures whose value type is known, including all the Simbody b...
Definition: Measure.h:263
 
Unique integer type for Subsystem-local qErr indexing.
 
Unique integer type for Subsystem-local q indexing.
 
This class is basically a glorified enumerated type, type-safe and range checked but permitting conve...
Definition: Stage.h:66
 
@ Infinity
Higher than any legitimate Stage.
Definition: Stage.h:79
 
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:280
 
SystemEventTriggerIndex getEventTriggerStartByStage(Stage) const
Return the index within the global event trigger array at which the first of the event triggers assoc...
 
int getNQErr() const
Return the total number nqerr=mp+nQuaternions of cache entries for position-level constraint errors.
 
Vector & updUDotErr(SubsystemIndex) const
 
int getNUDotErr() const
Return the total number nudotErr=mp+mv+ma of cache entries for acceleration-level constraint errors (...
 
const Vector & getU(SubsystemIndex) const
 
const Vector & getQDotDot(SubsystemIndex) const
 
SystemYErrIndex getUErrStart() const
Returns the yErr index at which the uErr's begin. Callable at Instance stage.
 
Vector & updZ(SubsystemIndex)
 
AbstractValue & updCacheEntry(SubsystemIndex, CacheEntryIndex) const
Retrieve a writable reference to the value contained in a particular cache entry.
 
Vector & updMultipliers(SubsystemIndex) const
 
void markCacheValueNotRealized(SubsystemIndex, CacheEntryIndex) const
(Advanced) Normally cache entries are invalidated automatically, however this method allows manual in...
 
QIndex allocateQ(SubsystemIndex, const Vector &qInit)
Allocate generalized coordinates q, which are second order continuous state variables.
 
int getNQ() const
Get total number of shared q's (generalized coordinates; second order state variables).
 
Vector & updZDot(SubsystemIndex) const
 
bool isDiscreteVarUpdateValueRealized(SubsystemIndex, DiscreteVariableIndex) const
Check whether the update value for this auto-update discrete variable has already been computed since...
 
QErrIndex allocateQErr(SubsystemIndex, int nqerr) const
Allocate nqerr cache slots to hold the current error for position-level (holonomic) constraint equati...
 
const Vector & getUErr(SubsystemIndex) const
 
const AbstractValue & getDiscreteVarUpdateValue(SubsystemIndex, DiscreteVariableIndex) const
For an auto-updating discrete variable, return the current value of its associated update cache entry...
 
Vector & updU(SubsystemIndex)
 
SystemYIndex getUStart() const
Returns the y index at which the u's begin. Callable at Model stage.
 
SystemYErrIndex getQErrStart() const
Returns the yErr index at which the qErr's begin. Callable at Instance stage.
 
AbstractValue & updDiscreteVarUpdateValue(SubsystemIndex, DiscreteVariableIndex) const
For an auto-updating discrete variable, return a writable reference to the value of its associated up...
 
const Vector & getUErrWeights(SubsystemIndex) const
 
int getNU() const
Get total number of shared u's (generalized speeds; mobilities).
 
SystemYIndex getQStart() const
Returns the y index at which the q's begin. Callable at Model stage.
 
Vector & updUErr(SubsystemIndex) const
 
const Vector & getZWeights(SubsystemIndex) const
 
AbstractValue & updDiscreteVariable(SubsystemIndex, DiscreteVariableIndex)
Get a writable reference to the value stored in the indicated discrete state variable dv,...
 
SystemMultiplierIndex getMultipliersStart(SubsystemIndex) const
 
Real getDiscreteVarLastUpdateTime(SubsystemIndex, DiscreteVariableIndex) const
Return the time of last update for this discrete variable.
 
Vector & updEventTriggersByStage(Stage) const
 
void advanceSubsystemToStage(SubsystemIndex, Stage) const
Advance a particular Subsystem's current stage by one to the indicated stage.
 
const Vector & getZDot(SubsystemIndex) const
 
void markCacheValueRealized(SubsystemIndex, CacheEntryIndex) const
Mark the value of a particular cache entry as up to date after it has been recalculated.
 
const Vector & getUWeights(SubsystemIndex) const
 
UDotErrIndex allocateUDotErr(SubsystemIndex, int nudoterr) const
Allocate nudoterr cache slots to hold the current error for acceleration-level (acceleration-only,...
 
Vector & updQ(SubsystemIndex)
 
Vector & updQDot(SubsystemIndex) const
 
SystemYIndex getZStart() const
Returns the y index at which the z's begin. Callable at Model stage.
 
const AbstractValue & getCacheEntry(SubsystemIndex, CacheEntryIndex) const
Retrieve a const reference to the value contained in a particular cache entry.
 
Vector & updQDotDot(SubsystemIndex) const
 
const Vector & getUDot(SubsystemIndex) const
 
CacheEntryIndex getDiscreteVarUpdateIndex(SubsystemIndex, DiscreteVariableIndex) const
For an auto-updating discrete variable, return the CacheEntryIndex for its associated update cache en...
 
const Vector & getMultipliers(SubsystemIndex) const
 
UErrIndex allocateUErr(SubsystemIndex, int nuerr) const
Allocate nuerr cache slots to hold the current error for velocity-level (nonholonomic and holonomic f...
 
int getNZ() const
Get total number of shared z's (auxiliary state variables).
 
DiscreteVariableIndex allocateAutoUpdateDiscreteVariable(SubsystemIndex, Stage invalidates, AbstractValue *, Stage updateDependsOn)
This method allocates a DiscreteVariable whose value should be updated automatically after each time ...
 
const Vector & getQDot(SubsystemIndex) const
Per-subsystem access to the shared cache entries.
 
int getNUErr() const
Return the total number nuerr=mp+mv of cache entries for velocity-level constraint errors (including ...
 
const Stage & getSubsystemStage(SubsystemIndex) const
 
int getNMultipliers() const
Return the total number of constraint multipliers; necessarily the same as the number of acceleration...
 
const Vector & getQ(SubsystemIndex) const
Per-subsystem access to the global shared variables.
 
const AbstractValue & getDiscreteVariable(SubsystemIndex, DiscreteVariableIndex) const
Get the current value of the indicated discrete variable.
 
const Vector & getUDotErr(SubsystemIndex) const
 
SystemUDotErrIndex getUDotErrStart(SubsystemIndex) const
 
const Vector & getQErr(SubsystemIndex) const
 
CacheEntryIndex allocateCacheEntry(SubsystemIndex, Stage earliest, Stage latest, AbstractValue *value) const
There are two Stages supplied explicitly as arguments to this method: earliest and latest.
 
const Vector & getEventTriggersByStage(Stage) const
 
void markDiscreteVarUpdateValueRealized(SubsystemIndex, DiscreteVariableIndex) const
Mark the update value for this auto-update discrete variable as up-to-date with respect to the state ...
 
UIndex allocateU(SubsystemIndex, const Vector &uInit)
Allocate generalized speeds u, which are first order continuous state variables related to the deriva...
 
int getNEventTriggersByStage(Stage) const
Return the size of the partition of event trigger functions which are evaluated at a given Stage.
 
DiscreteVariableIndex allocateDiscreteVariable(SubsystemIndex, Stage invalidates, AbstractValue *)
The Stage supplied here in the call is the earliest subsystem stage which is invalidated by a change ...
 
EventTriggerByStageIndex allocateEventTrigger(SubsystemIndex, Stage stage, int nevent) const
Allocate room for nevent witness function values that will be available at the indicated stage.
 
ZIndex allocateZ(SubsystemIndex, const Vector &zInit)
Allocate auxiliary first order continuous state variables z.
 
const Vector & getQErrWeights(SubsystemIndex) const
 
Vector & updUDot(SubsystemIndex) const
 
Vector & updQErr(SubsystemIndex) const
 
bool isCacheValueRealized(SubsystemIndex, CacheEntryIndex) const
Check whether the value in a particular cache entry has been recalculated since the last change to th...
 
const Vector & getZ(SubsystemIndex) const
 
SimTK::String is a plug-compatible std::string replacement (plus some additional functionality) inten...
Definition: String.h:65
 
Provide a unique integer type for identifying Subsystems.
 
The abstract parent of all Subsystem implementation classes.
Definition: SubsystemGuts.h:47
 
A Subsystem is expected to be part of a larger System and to have interdependencies with other subsys...
Definition: Subsystem.h:55
 
const Vector & getZWeights(const State &s) const
Definition: Subsystem.h:132
 
AbstractValue & updCacheEntry(const State &s, CacheEntryIndex index) const
Definition: Subsystem.h:251
 
const Vector & getUDotErr(const State &s) const
Definition: Subsystem.h:166
 
int getNQErr(const State &s) const
Definition: Subsystem.h:201
 
const Vector & getQErrWeights(const State &s) const
Definition: Subsystem.h:161
 
Vector & updU(State &s) const
Definition: Subsystem.h:136
 
ZIndex allocateZ(State &s, const Vector &zInit) const
Definition: Subsystem.h:92
 
Vector & updQ(State &s) const
Definition: Subsystem.h:135
 
const Vector & getZDot(const State &s) const
Definition: Subsystem.h:143
 
bool hasGuts() const
Obtain the Subsystem name if one was given on construction of the concrete Subsystem.
Definition: Subsystem.h:362
 
bool isSameSubsystem(const Subsystem &otherSubsystem) const
Determine if this Subsystem handle refers to the same Subsystem::Guts object as handle otherSubsystem...
Definition: Subsystem.h:322
 
void setZ(State &s, const Vector &z) const
Definition: Subsystem.h:234
 
~Subsystem()
Destructor deletes the referenced Subsystem::Guts object if this is the owner handle of that object,...
 
const Vector & getUWeights(const State &s) const
Definition: Subsystem.h:130
 
Vector & updMultipliers(const State &s) const
Definition: Subsystem.h:179
 
CacheEntryIndex getDiscreteVarUpdateIndex(const State &s, DiscreteVariableIndex dx) const
Definition: Subsystem.h:256
 
Vector & updEventTriggersByStage(const State &s, Stage g) const
Definition: Subsystem.h:181
 
Vector & updZ(State &s) const
Definition: Subsystem.h:137
 
CacheEntryIndex allocateCacheEntry(const State &s, Stage dependsOn, Stage computedBy, AbstractValue *v) const
Definition: Subsystem.h:103
 
Vector & updQErr(const State &s) const
Definition: Subsystem.h:173
 
SystemMultiplierIndex getMultipliersStart(const State &s) const
Definition: Subsystem.h:214
 
Vector & updZDot(const State &s) const
Definition: Subsystem.h:152
 
QErrIndex allocateQErr(const State &s, int nqerr) const
Definition: Subsystem.h:114
 
SystemUErrIndex getUErrStart(const State &s) const
Definition: Subsystem.h:204
 
const Subsystem::Guts & getSubsystemGuts() const
Obtain the Subsystem name if one was given on construction of the concrete Subsystem.
Definition: Subsystem.h:353
 
AbstractValue & updDiscreteVariable(State &s, DiscreteVariableIndex index) const
Definition: Subsystem.h:247
 
int getNMultipliers(const State &s) const
Definition: Subsystem.h:216
 
const Vector & getUErrWeights(const State &s) const
Definition: Subsystem.h:163
 
SystemUIndex getUStart(const State &s) const
Definition: Subsystem.h:189
 
const Vector & getQErr(const State &s) const
Definition: Subsystem.h:157
 
AbstractValue & updDiscreteVarUpdateValue(const State &s, DiscreteVariableIndex dx) const
Definition: Subsystem.h:262
 
int getNUDotErr(const State &s) const
Definition: Subsystem.h:211
 
Subsystem::Guts & updSubsystemGuts()
Obtain the Subsystem name if one was given on construction of the concrete Subsystem.
Definition: Subsystem.h:354
 
Stage getStage(const State &s) const
Definition: Subsystem.h:239
 
void markDiscreteVarUpdateValueRealized(const State &s, DiscreteVariableIndex dx) const
Definition: Subsystem.h:268
 
UIndex allocateU(State &s, const Vector &uInit) const
Definition: Subsystem.h:90
 
SystemZIndex getZStart(const State &s) const
Definition: Subsystem.h:194
 
Subsystem()
Default constructor creates and empty handle with a null Subsystem::Guts pointer.
Definition: Subsystem.h:62
 
void markCacheValueNotRealized(const State &s, CacheEntryIndex cx) const
Definition: Subsystem.h:275
 
CacheEntryIndex allocateCacheEntry(const State &state, Stage g, AbstractValue *v) const
Definition: Subsystem.h:108
 
Vector & updUDotErr(const State &s) const
Definition: Subsystem.h:177
 
Subsystem & operator=(const Subsystem &)
Copy assignment deletes the Subsystem::Guts object if there is one and then behaves like the copy con...
 
void adoptSubsystemGuts(Subsystem::Guts *g)
Obtain the Subsystem name if one was given on construction of the concrete Subsystem.
 
SystemUDotErrIndex getUDotErrStart(const State &s) const
Definition: Subsystem.h:209
 
int getNQ(const State &s) const
Definition: Subsystem.h:186
 
int getNZ(const State &s) const
Definition: Subsystem.h:196
 
const AbstractValue & getDiscreteVariable(const State &s, DiscreteVariableIndex index) const
Definition: Subsystem.h:245
 
SystemEventTriggerByStageIndex getEventTriggerStartByStage(const State &s, Stage g) const
Definition: Subsystem.h:219
 
QIndex allocateQ(State &s, const Vector &qInit) const
Definition: Subsystem.h:88
 
Vector & updUErr(const State &s) const
Definition: Subsystem.h:175
 
const AbstractValue & getCacheEntry(const State &s, CacheEntryIndex index) const
Definition: Subsystem.h:249
 
CacheEntryIndex allocateLazyCacheEntry(const State &state, Stage earliest, AbstractValue *v) const
Definition: Subsystem.h:111
 
bool isDiscreteVarUpdateValueRealized(const State &s, DiscreteVariableIndex dx) const
Definition: Subsystem.h:265
 
const Vector & getMultipliers(const State &s) const
Definition: Subsystem.h:168
 
int getNUErr(const State &s) const
Definition: Subsystem.h:206
 
SystemQIndex getQStart(const State &s) const
Definition: Subsystem.h:184
 
Vector & updQDot(const State &s) const
Definition: Subsystem.h:148
 
const Vector & getEventTriggersByStage(const State &s, Stage g) const
Definition: Subsystem.h:170
 
const Vector & getZ(const State &s) const
Definition: Subsystem.h:128
 
const Vector & getQ(const State &s) const
Definition: Subsystem.h:124
 
void setU(State &s, const Vector &u) const
Definition: Subsystem.h:230
 
const AbstractValue & getDiscreteVarUpdateValue(const State &s, DiscreteVariableIndex dx) const
Definition: Subsystem.h:259
 
void setQ(State &s, const Vector &q) const
Definition: Subsystem.h:226
 
int getNEventTriggersByStage(const State &s, Stage g) const
Definition: Subsystem.h:221
 
UDotErrIndex allocateUDotErr(const State &s, int nudoterr) const
Definition: Subsystem.h:118
 
DiscreteVariableIndex allocateAutoUpdateDiscreteVariable(State &s, Stage invalidates, AbstractValue *v, Stage updateDependsOn) const
Definition: Subsystem.h:99
 
Measure_< T > getMeasure_(MeasureIndex mx) const
Obtain the Subsystem name if one was given on construction of the concrete Subsystem.
Definition: Subsystem.h:348
 
const Vector & getU(const State &s) const
Definition: Subsystem.h:126
 
const Vector & getQDotDot(const State &s) const
Definition: Subsystem.h:145
 
bool isCacheValueRealized(const State &s, CacheEntryIndex cx) const
Definition: Subsystem.h:271
 
const Vector & getUErr(const State &s) const
Definition: Subsystem.h:159
 
DiscreteVariableIndex allocateDiscreteVariable(State &s, Stage g, AbstractValue *v) const
Definition: Subsystem.h:96
 
Real getDiscreteVarLastUpdateTime(const State &s, DiscreteVariableIndex dx) const
Definition: Subsystem.h:253
 
bool isEmptyHandle() const
Return true if this handle has a null Subsystem::Guts pointer.
Definition: Subsystem.h:317
 
const Vector & getQDot(const State &s) const
Definition: Subsystem.h:139
 
EventTriggerByStageIndex allocateEventTriggersByStage(const State &s, Stage g, int ntriggers) const
Definition: Subsystem.h:121
 
Subsystem(const Subsystem &)
Copy constructor clones the Subsystem::Guts object if there is one and makes this the owner handle of...
 
Vector & updQDotDot(const State &s) const
Definition: Subsystem.h:154
 
SystemQErrIndex getQErrStart(const State &s) const
Definition: Subsystem.h:199
 
UErrIndex allocateUErr(const State &s, int nuerr) const
Definition: Subsystem.h:116
 
void advanceToStage(const State &s, Stage g) const
Definition: Subsystem.h:241
 
void markCacheValueRealized(const State &s, CacheEntryIndex cx) const
Definition: Subsystem.h:273
 
int getNU(const State &s) const
Definition: Subsystem.h:191
 
const Vector & getUDot(const State &s) const
Definition: Subsystem.h:141
 
Subsystem(Subsystem::Guts *g)
Obtain the Subsystem name if one was given on construction of the concrete Subsystem.
Definition: Subsystem.h:361
 
Vector & updUDot(const State &s) const
Definition: Subsystem.h:150
 
This unique integer type is for identifying a triggered event within a particular Stage of the full S...
 
This unique integer type is for indexing global "multiplier-like" arrays, that is,...
 
This unique integer type is for indexing global "qErr-like" arrays, that is, arrays that inherently h...
 
This unique integer type is for indexing global "q-like" arrays, that is, arrays that inherently have...
 
This unique integer type is for indexing global "uDotErr-like" arrays, that is, arrays that inherentl...
 
This unique integer type is for indexing global "uErr-like" arrays, that is, arrays that inherently h...
 
This unique integer type is for indexing global "u-like" arrays, that is, arrays that inherently have...
 
This unique integer type is for indexing global "z-like" arrays, that is, arrays that inherently have...
 
This is the base class that serves as the parent of all SimTK System objects; most commonly Simbody's...
Definition: System.h:97
 
Unique integer type for Subsystem-local uDotErr indexing.
 
Unique integer type for Subsystem-local uErr indexing.
 
Unique integer type for Subsystem-local u indexing.
 
int size() const
Definition: VectorBase.h:396
 
Unique integer type for Subsystem-local z indexing.
 
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
 
SimTK_Real Real
This is the default compiled-in floating point type for SimTK, either float or double.
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:607