Simbody  3.5
Subsystem.h
Go to the documentation of this file.
1 #ifndef SimTK_SimTKCOMMON_SUBSYSTEM_H_
2 #define SimTK_SimTKCOMMON_SUBSYSTEM_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm): SimTKcommon *
6  * -------------------------------------------------------------------------- *
7  * This is part of the SimTK biosimulation toolkit originating from *
8  * Simbios, the NIH National Center for Physics-Based Simulation of *
9  * Biological Structures at Stanford, funded under the NIH Roadmap for *
10  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11  * *
12  * Portions copyright (c) 2006-14 Stanford University and the Authors. *
13  * Authors: Michael Sherman *
14  * Contributors: *
15  * *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
17  * not use this file except in compliance with the License. You may obtain a *
18  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19  * *
20  * Unless required by applicable law or agreed to in writing, software *
21  * distributed under the License is distributed on an "AS IS" BASIS, *
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23  * See the License for the specific language governing permissions and *
24  * limitations under the License. *
25  * -------------------------------------------------------------------------- */
26 
27 #include "SimTKcommon/basics.h"
28 #include "SimTKcommon/Simmatrix.h"
31 
32 #include <cassert>
33 
34 namespace SimTK {
35 
36 class System;
37 
56 public:
57 class Guts; // local; name is Subsystem::Guts
58 friend class Guts;
59 
62 Subsystem() : guts(0) {}
63 
67 Subsystem(const Subsystem&);
70 Subsystem& operator=(const Subsystem&);
71 
76 ~Subsystem();
77 
78 
88 QIndex allocateQ(State& s, const Vector& qInit) const
89 { return s.allocateQ(getMySubsystemIndex(), qInit); }
90 UIndex allocateU(State& s, const Vector& uInit) const
91 { return s.allocateU(getMySubsystemIndex(), uInit); }
92 ZIndex allocateZ(State& s, const Vector& zInit) const
93 { return s.allocateZ(getMySubsystemIndex(), zInit); }
94 
97 { return s.allocateDiscreteVariable(getMySubsystemIndex(), g, v); }
98 DiscreteVariableIndex allocateAutoUpdateDiscreteVariable
99  (State& s, Stage invalidates, AbstractValue* v, Stage updateDependsOn) const
101  (getMySubsystemIndex(),invalidates,v,updateDependsOn); }
102 CacheEntryIndex allocateCacheEntry
103  (const State& s, Stage dependsOn, Stage computedBy, AbstractValue* v) const
104 { return s.allocateCacheEntry
105  (getMySubsystemIndex(), dependsOn, computedBy, v); }
106 
107 CacheEntryIndex allocateCacheEntry
108  (const State& state, Stage g, AbstractValue* v) const
109 { return allocateCacheEntry(state, g, g, v); }
110 CacheEntryIndex allocateLazyCacheEntry
111  (const State& state, Stage earliest, AbstractValue* v) const
112 { return allocateCacheEntry(state, earliest, Stage::Infinity, v); }
113 
114 QErrIndex allocateQErr(const State& s, int nqerr) const
115 { return s.allocateQErr(getMySubsystemIndex(), nqerr); }
116 UErrIndex allocateUErr(const State& s, int nuerr) const
117 { return s.allocateUErr(getMySubsystemIndex(), nuerr); }
118 UDotErrIndex allocateUDotErr(const State& s, int nudoterr) const
119 { return s.allocateUDotErr(getMySubsystemIndex(), nudoterr); }
121 allocateEventTriggersByStage(const State& s, Stage g, int ntriggers) const
122 { return s.allocateEventTrigger(getMySubsystemIndex(),g,ntriggers); }
123 
124 const Vector& getQ(const State& s) const
125 { return s.getQ(getMySubsystemIndex()); }
126 const Vector& getU(const State& s) const
127 { return s.getU(getMySubsystemIndex()); }
128 const Vector& getZ(const State& s) const
129 { return s.getZ(getMySubsystemIndex()); }
130 const Vector& getUWeights(const State& s) const
131 { return s.getUWeights(getMySubsystemIndex()); }
132 const Vector& getZWeights(const State& s) const
133 { return s.getZWeights(getMySubsystemIndex()); }
134 
135 Vector& updQ(State& s) const {return s.updQ(getMySubsystemIndex());}
136 Vector& updU(State& s) const {return s.updU(getMySubsystemIndex());}
137 Vector& updZ(State& s) const {return s.updZ(getMySubsystemIndex());}
138 
139 const Vector& getQDot (const State& s) const
140 { return s.getQDot(getMySubsystemIndex()); }
141 const Vector& getUDot (const State& s) const
142 { return s.getUDot(getMySubsystemIndex()); }
143 const Vector& getZDot (const State& s) const
144 { return s.getZDot(getMySubsystemIndex()); }
145 const Vector& getQDotDot(const State& s) const
146 { return s.getQDotDot(getMySubsystemIndex()); }
147 
148 Vector& updQDot (const State& s) const
149 { return s.updQDot(getMySubsystemIndex()); }
150 Vector& updUDot (const State& s) const
151 { return s.updUDot(getMySubsystemIndex()); }
152 Vector& updZDot (const State& s) const
153 { return s.updZDot(getMySubsystemIndex()); }
154 Vector& updQDotDot(const State& s) const
155 { return s.updQDotDot(getMySubsystemIndex()); }
156 
157 const Vector& getQErr(const State& s) const
158 { return s.getQErr(getMySubsystemIndex()); }
159 const Vector& getUErr(const State& s) const
160 { return s.getUErr(getMySubsystemIndex()); }
161 const Vector& getQErrWeights(const State& s) const
162 { return s.getQErrWeights(getMySubsystemIndex()); }
163 const Vector& getUErrWeights(const State& s) const
164 { return s.getUErrWeights(getMySubsystemIndex()); }
165 
166 const Vector& getUDotErr(const State& s) const
167 { return s.getUDotErr(getMySubsystemIndex()); }
168 const Vector& getMultipliers(const State& s) const
169 { return s.getMultipliers(getMySubsystemIndex()); }
170 const Vector& getEventTriggersByStage(const State& s, Stage g) const
171 { return s.getEventTriggersByStage(getMySubsystemIndex(),g); }
172 
173 Vector& updQErr(const State& s) const
174 { return s.updQErr(getMySubsystemIndex()); }
175 Vector& updUErr(const State& s) const
176 { return s.updUErr(getMySubsystemIndex()); }
177 Vector& updUDotErr(const State& s) const
178 { return s.updUDotErr(getMySubsystemIndex()); }
179 Vector& updMultipliers(const State& s) const
180 { return s.updMultipliers(getMySubsystemIndex()); }
182 { return s.updEventTriggersByStage(getMySubsystemIndex(),g); }
183 
184 SystemQIndex getQStart(const State& s) const
185 { return s.getQStart(getMySubsystemIndex()); }
186 int getNQ(const State& s) const
187 { return s.getNQ(getMySubsystemIndex()); }
188 
189 SystemUIndex getUStart(const State& s) const
190 { return s.getUStart(getMySubsystemIndex()); }
191 int getNU(const State& s) const
192 { return s.getNU(getMySubsystemIndex()); }
193 
194 SystemZIndex getZStart(const State& s) const
195 { return s.getZStart(getMySubsystemIndex()); }
196 int getNZ(const State& s) const
197 { return s.getNZ(getMySubsystemIndex()); }
198 
200 { return s.getQErrStart(getMySubsystemIndex()); }
201 int getNQErr(const State& s) const
202 { return s.getNQErr(getMySubsystemIndex()); }
203 
205 { return s.getUErrStart(getMySubsystemIndex()); }
206 int getNUErr(const State& s) const
207 { return s.getNUErr(getMySubsystemIndex()); }
208 
210 { return s.getUDotErrStart(getMySubsystemIndex()); }
211 int getNUDotErr(const State& s) const
212 { return s.getNUDotErr(getMySubsystemIndex()); }
213 
215 { return s.getMultipliersStart(getMySubsystemIndex()); }
216 int getNMultipliers(const State& s) const
217 { return s.getNMultipliers(getMySubsystemIndex()); }
218 
220 { return s.getEventTriggerStartByStage(getMySubsystemIndex(),g); }
221 int getNEventTriggersByStage (const State& s, Stage g) const
222 { return s.getNEventTriggersByStage(getMySubsystemIndex(),g); }
223 
224 
225 // For convenience.
226 void setQ(State& s, const Vector& q) const {
227  SimTK_ASSERT(q.size() == getNQ(s), "Subsystem::Guts::setQ()");
228  updQ(s) = q;
229 }
230 void setU(State& s, const Vector& u) const {
231  SimTK_ASSERT(u.size() == getNU(s), "Subsystem::Guts::setU()");
232  updU(s) = u;
233 }
234 void setZ(State& s, const Vector& z) const {
235  SimTK_ASSERT(z.size() == getNZ(s), "Subsystem::Guts::setZ()");
236  updZ(s) = z;
237 }
238 
239 Stage getStage(const State& s) const
240 { return s.getSubsystemStage(getMySubsystemIndex()); }
241 void advanceToStage(const State& s, Stage g) const
242 { s.advanceSubsystemToStage(getMySubsystemIndex(), g); }
243 
244 const AbstractValue&
246 { return s.getDiscreteVariable(getMySubsystemIndex(), index); }
248 { return s.updDiscreteVariable(getMySubsystemIndex(), index); }
249 const AbstractValue& getCacheEntry(const State& s, CacheEntryIndex index) const
250 { return s.getCacheEntry(getMySubsystemIndex(), index); }
252 { return s.updCacheEntry(getMySubsystemIndex(), index); }
254 { return s.getDiscreteVarLastUpdateTime(getMySubsystemIndex(),dx); }
257 { return s.getDiscreteVarUpdateIndex(getMySubsystemIndex(),dx); }
258 const AbstractValue&
260 { return s.getDiscreteVarUpdateValue(getMySubsystemIndex(),dx); }
263 { return s.updDiscreteVarUpdateValue(getMySubsystemIndex(),dx); }
264 bool isDiscreteVarUpdateValueRealized
265  (const State& s, DiscreteVariableIndex dx) const
266 { return s.isDiscreteVarUpdateValueRealized(getMySubsystemIndex(),dx); }
267 void markDiscreteVarUpdateValueRealized
268  (const State& s, DiscreteVariableIndex dx) const
269 { return s.markDiscreteVarUpdateValueRealized(getMySubsystemIndex(),dx); }
270 
271 bool isCacheValueRealized(const State& s, CacheEntryIndex cx) const
272 { return s.isCacheValueRealized(getMySubsystemIndex(), cx); }
274 { s.markCacheValueRealized(getMySubsystemIndex(), cx); }
276 { s.markCacheValueNotRealized(getMySubsystemIndex(), cx); }
288 inline const String& getName() const;
291 inline const String& getVersion() const;
292 
294 inline bool isInSystem() const;
298 inline bool isInSameSystem(const Subsystem& otherSubsystem) const;
299 
303 inline const System& getSystem() const;
307 inline System& updSystem();
310 inline void setSystem(System& system, SubsystemIndex subx);
311 
314 inline SubsystemIndex getMySubsystemIndex() const;
315 
317 inline bool isEmptyHandle() const {return guts==0;}
318 
322 inline bool isSameSubsystem(const Subsystem& otherSubsystem) const
323 { return guts && (guts==otherSubsystem.guts); }
324 
328 inline bool isOwnerHandle() const;
329 
333 inline bool subsystemTopologyHasBeenRealized() const;
342 inline void invalidateSubsystemTopologyCache() const;
343 
344 // Add a new Measure to this Subsystem. This method is generally used by Measure
345 // constructors to install a newly-constructed Measure into its Subsystem.
346 inline MeasureIndex adoptMeasure(AbstractMeasure&);
347 inline AbstractMeasure getMeasure(MeasureIndex) const;
348 template <class T> Measure_<T> getMeasure_(MeasureIndex mx) const
349 { return Measure_<T>::getAs(getMeasure(mx));}
350 
351 // dynamic_cast the returned reference to a reference to your concrete Guts
352 // class.
353 const Subsystem::Guts& getSubsystemGuts() const {assert(guts); return *guts;}
354 Subsystem::Guts& updSubsystemGuts() {assert(guts); return *guts;}
355 
356 // Put new Guts into this *empty* handle and take over ownership.
357 // If this handle is already in use, this routine will throw
358 // an exception.
359 void adoptSubsystemGuts(Subsystem::Guts* g);
360 
361 explicit Subsystem(Subsystem::Guts* g) : guts(g) { }
362 bool hasGuts() const {return guts!=0;}
365 private:
366 // This is the only data member in this class. Also, any class derived from
367 // Subsystem must have *NO* data members at all (data goes in the Guts
368 // class).
369 Guts* guts;
370 };
371 
372 } // namespace SimTK
373 
374 #endif // SimTK_SimTKCOMMON_SUBSYSTEM_H_
const Vector & getZWeights(SubsystemIndex) const
const Vector & getEventTriggersByStage(const State &s, Stage g) const
Definition: Subsystem.h:170
AbstractValue & updDiscreteVarUpdateValue(SubsystemIndex, DiscreteVariableIndex) const
For an auto-updating discrete variable, return a writable reference to the value of its associated up...
Vector & updUErr(SubsystemIndex) const
Vector & updEventTriggersByStage(const State &s, Stage g) const
Definition: Subsystem.h:181
A Subsystem is expected to be part of a larger System and to have interdependencies with other subsys...
Definition: Subsystem.h:55
const Vector & getQDotDot(SubsystemIndex) const
Vector & updQ(SubsystemIndex)
SystemYErrIndex getUErrStart() const
Returns the yErr index at which the uErr&#39;s begin. Callable at Instance stage.
#define SimTK_SimTKCOMMON_EXPORT
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:218
const Vector & getZDot(SubsystemIndex) const
const Vector & getQErr(SubsystemIndex) const
int getNQ(const State &s) const
Definition: Subsystem.h:186
const Vector & getZ(SubsystemIndex) const
Unique integer type for Subsystem-local uDotErr indexing.
Vector & updMultipliers(SubsystemIndex) const
Vector & updUErr(const State &s) const
Definition: Subsystem.h:175
Vector & updQErr(SubsystemIndex) const
SystemMultiplierIndex getMultipliersStart(const State &s) const
Definition: Subsystem.h:214
bool isDiscreteVarUpdateValueRealized(SubsystemIndex, DiscreteVariableIndex) const
Check whether the update value for this auto-update discrete variable has already been computed since...
void advanceToStage(const State &s, Stage g) const
Definition: Subsystem.h:241
const Vector & getU(const State &s) const
Definition: Subsystem.h:126
int getNEventTriggersByStage(const State &s, Stage g) const
Definition: Subsystem.h:221
const Stage & getSubsystemStage(SubsystemIndex) const
int getNU() const
Get total number of shared u&#39;s (generalized speeds; mobilities).
AbstractValue & updCacheEntry(SubsystemIndex, CacheEntryIndex) const
Retrieve a writable reference to the value contained in a particular cache entry. ...
void markCacheValueNotRealized(SubsystemIndex, CacheEntryIndex) const
Normally cache entries are invalidated automatically, however this method allows manual invalidation ...
void advanceSubsystemToStage(SubsystemIndex, Stage) const
Advance a particular Subsystem&#39;s current stage by one to the indicated stage.
QErrIndex allocateQErr(SubsystemIndex, int nqerr) const
Allocate nqerr cache slots to hold the current error for position-level (holonomic) constraint equati...
Unique integer type for Subsystem-local u indexing.
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
CacheEntryIndex allocateCacheEntry(SubsystemIndex, Stage earliest, Stage latest, AbstractValue *) const
There are two Stages supplied explicitly as arguments to this method: earliest and latest...
Vector & updMultipliers(const State &s) const
Definition: Subsystem.h:179
Real getDiscreteVarLastUpdateTime(const State &s, DiscreteVariableIndex dx) const
Definition: Subsystem.h:253
Unique integer type for Subsystem-local uErr indexing.
Real getDiscreteVarLastUpdateTime(SubsystemIndex, DiscreteVariableIndex) const
Return the time of last update for this discrete variable.
CacheEntryIndex getDiscreteVarUpdateIndex(const State &s, DiscreteVariableIndex dx) const
Definition: Subsystem.h:256
Unique integer type for Subsystem-local qErr indexing.
This class is basically a glorified enumerated type, type-safe and range checked but permitting conve...
Definition: Stage.h:50
SystemEventTriggerIndex getEventTriggerStartByStage(Stage) const
Return the index within the global event trigger array at which the first of the event triggers assoc...
Vector & updQErr(const State &s) const
Definition: Subsystem.h:173
EventTriggerByStageIndex allocateEventTriggersByStage(const State &s, Stage g, int ntriggers) const
Definition: Subsystem.h:121
int getNQErr() const
Return the total number nqerr=mp+nQuaternions of cache entries for position-level constraint errors...
SystemUIndex getUStart(const State &s) const
Definition: Subsystem.h:189
int size() const
Definition: VectorBase.h:396
AbstractValue & updDiscreteVariable(State &s, DiscreteVariableIndex index) const
Definition: Subsystem.h:247
const AbstractValue & getDiscreteVariable(SubsystemIndex, DiscreteVariableIndex) const
Get the current value of the indicated discrete variable.
UDotErrIndex allocateUDotErr(SubsystemIndex, int nudoterr) const
Allocate nudoterr cache slots to hold the current error for acceleration-level (acceleration-only, nonholonomic first derivative, and holonomic second derivative) constraint equations.
SystemYIndex getUStart() const
Returns the y index at which the u&#39;s begin. Callable at Model stage.
CacheEntryIndex getDiscreteVarUpdateIndex(SubsystemIndex, DiscreteVariableIndex) const
For an auto-updating discrete variable, return the CacheEntryIndex for its associated update cache en...
SystemEventTriggerByStageIndex getEventTriggerStartByStage(const State &s, Stage g) const
Definition: Subsystem.h:219
int getNUDotErr(const State &s) const
Definition: Subsystem.h:211
Vector & updU(State &s) const
Definition: Subsystem.h:136
#define SimTK_ASSERT(cond, msg)
Definition: ExceptionMacros.h:374
SystemUDotErrIndex getUDotErrStart(SubsystemIndex) const
void setU(State &s, const Vector &u) const
Definition: Subsystem.h:230
bool isCacheValueRealized(SubsystemIndex, CacheEntryIndex) const
Check whether the value in a particular cache entry has been recalculated since the last change to th...
const AbstractValue & getDiscreteVariable(const State &s, DiscreteVariableIndex index) const
Definition: Subsystem.h:245
int getNMultipliers() const
Return the total number of constraint multipliers; necessarily the same as the number of acceleration...
This is the base class for all Measure handle classes.
Definition: Measure.h:151
int getNZ(const State &s) const
Definition: Subsystem.h:196
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:593
int getNUErr() const
Return the total number nuerr=mp+mv of cache entries for velocity-level constraint errors (including ...
Vector & updZ(State &s) const
Definition: Subsystem.h:137
Vector & updUDotErr(SubsystemIndex) const
This unique integer type is for indexing global "multiplier-like" arrays, that is, arrays that inherently have the same dimension as the total number of Lagrange multipliers in the full System-level view of the State.
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
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:276
const Subsystem::Guts & getSubsystemGuts() const
Obtain the Subsystem name if one was given on construction of the concrete Subsystem.
Definition: Subsystem.h:353
This file declares the base class AbstractMeasure for all derived Measure handle classes, and the handle classes for built-in Measures.
int getNQ() const
Get total number of shared q&#39;s (generalized coordinates; second order state variables).
QIndex allocateQ(State &s, const Vector &qInit) const
Definition: Subsystem.h:88
const Vector & getQErrWeights(SubsystemIndex) const
SystemUErrIndex getUErrStart(const State &s) const
Definition: Subsystem.h:204
Stage getStage(const State &s) const
Definition: Subsystem.h:239
const Vector & getUWeights(SubsystemIndex) const
AbstractValue & updDiscreteVariable(SubsystemIndex, DiscreteVariableIndex)
Get a writable reference to the value stored in the indicated discrete state variable dv...
Vector & updU(SubsystemIndex)
UErrIndex allocateUErr(const State &s, int nuerr) const
Definition: Subsystem.h:116
const Vector & getUDotErr(const State &s) const
Definition: Subsystem.h:166
DiscreteVariableIndex allocateAutoUpdateDiscreteVariable(SubsystemIndex, Stage invalidates, AbstractValue *, Stage updateDependsOn)
This method allocates a DiscreteVariable whose value should be updated automatically after each time ...
void markCacheValueNotRealized(const State &s, CacheEntryIndex cx) const
Definition: Subsystem.h:275
Subsystem::Guts & updSubsystemGuts()
Obtain the Subsystem name if one was given on construction of the concrete Subsystem.
Definition: Subsystem.h:354
ZIndex allocateZ(State &s, const Vector &zInit) const
Definition: Subsystem.h:92
bool isCacheValueRealized(const State &s, CacheEntryIndex cx) const
Definition: Subsystem.h:271
const AbstractValue & getDiscreteVarUpdateValue(const State &s, DiscreteVariableIndex dx) const
Definition: Subsystem.h:259
DiscreteVariableIndex allocateDiscreteVariable(State &s, Stage g, AbstractValue *v) const
Definition: Subsystem.h:96
const Vector & getUDotErr(SubsystemIndex) const
AbstractValue & updCacheEntry(const State &s, CacheEntryIndex index) const
Definition: Subsystem.h:251
UDotErrIndex allocateUDotErr(const State &s, int nudoterr) const
Definition: Subsystem.h:118
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 "qErr-like" arrays, that is, arrays that inherently h...
Unique integer type for Subsystem-local z indexing.
void setQ(State &s, const Vector &q) const
Definition: Subsystem.h:226
This unique integer type is for indexing global "uErr-like" arrays, that is, arrays that inherently h...
const Vector & getUErr(const State &s) const
Definition: Subsystem.h:159
void markCacheValueRealized(const State &s, CacheEntryIndex cx) const
Definition: Subsystem.h:273
const Vector & getZDot(const State &s) const
Definition: Subsystem.h:143
SystemZIndex getZStart(const State &s) const
Definition: Subsystem.h:194
SystemYIndex getQStart() const
Returns the y index at which the q&#39;s begin. Callable at Model 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 ...
Unique integer type for Subsystem-local q indexing.
const Vector & getQDotDot(const State &s) const
Definition: Subsystem.h:145
Subsystem(Subsystem::Guts *g)
Obtain the Subsystem name if one was given on construction of the concrete Subsystem.
Definition: Subsystem.h:361
AbstractValue & updDiscreteVarUpdateValue(const State &s, DiscreteVariableIndex dx) const
Definition: Subsystem.h:262
The abstract parent of all Subsystem implementation classes.
Definition: SubsystemGuts.h:47
const AbstractValue & getCacheEntry(const State &s, CacheEntryIndex index) const
Definition: Subsystem.h:249
QErrIndex allocateQErr(const State &s, int nqerr) const
Definition: Subsystem.h:114
const Vector & getZ(const State &s) const
Definition: Subsystem.h:128
Higher than any legitimate Stage.
Definition: Stage.h:63
UIndex allocateU(State &s, const Vector &uInit) const
Definition: Subsystem.h:90
int getNQErr(const State &s) const
Definition: Subsystem.h:201
Vector & updQ(State &s) const
Definition: Subsystem.h:135
const Vector & getQDot(const State &s) const
Definition: Subsystem.h:139
const Vector & getUDot(const State &s) const
Definition: Subsystem.h:141
This unique integer type is for identifying a triggered event within a particular Stage of the full S...
int getNU(const State &s) const
Definition: Subsystem.h:191
const Vector & getEventTriggersByStage(Stage) const
const Vector & getMultipliers(const State &s) const
Definition: Subsystem.h:168
bool hasGuts() const
Obtain the Subsystem name if one was given on construction of the concrete Subsystem.
Definition: Subsystem.h:362
int getNUDotErr() const
Return the total number nudotErr=mp+mv+ma of cache entries for acceleration-level constraint errors (...
Vector & updQDot(SubsystemIndex) const
SimTK::String is a plug-compatible std::string replacement (plus some additional functionality) inten...
Definition: String.h:62
Declares the user-visible part of a SimTK::State, the implementation is done in a separate internal c...
const AbstractValue & getCacheEntry(SubsystemIndex, CacheEntryIndex) const
Retrieve a const reference to the value contained in a particular cache entry.
Vector & updQDot(const State &s) const
Definition: Subsystem.h:148
Abstract base class representing an arbitrary value of self-describing type.
Definition: Value.h:41
This unique integer type is for indexing global "uDotErr-like" arrays, that is, arrays that inherentl...
UErrIndex allocateUErr(SubsystemIndex, int nuerr) const
Allocate nuerr cache slots to hold the current error for velocity-level (nonholonomic and holonomic f...
const Vector & getQ(const State &s) const
Definition: Subsystem.h:124
Vector & updQDotDot(SubsystemIndex) const
SystemYIndex getZStart() const
Returns the y index at which the z&#39;s begin. Callable at Model stage.
const Vector & getZWeights(const State &s) const
Definition: Subsystem.h:132
This unique integer type is for selecting discrete variables.
const Vector & getQErrWeights(const State &s) const
Definition: Subsystem.h:161
This unique integer type is for indexing global "z-like" arrays, that is, arrays that inherently have...
Measure_< T > getMeasure_(MeasureIndex mx) const
Obtain the Subsystem name if one was given on construction of the concrete Subsystem.
Definition: Subsystem.h:348
QIndex allocateQ(SubsystemIndex, const Vector &qInit)
Allocate generalized coordinates q, which are second order continuous state variables.
const AbstractValue & getDiscreteVarUpdateValue(SubsystemIndex, DiscreteVariableIndex) const
For an auto-updating discrete variable, return the current value of its associated update cache entry...
SystemMultiplierIndex getMultipliersStart(SubsystemIndex) const
const Vector & getQ(SubsystemIndex) const
Per-subsystem access to the global shared variables.
This is the base class that serves as the parent of all SimTK System objects; most commonly Simbody&#39;s...
Definition: System.h:97
SystemUDotErrIndex getUDotErrStart(const State &s) const
Definition: Subsystem.h:209
const Vector & getMultipliers(SubsystemIndex) const
UIndex allocateU(SubsystemIndex, const Vector &uInit)
Allocate generalized speeds u, which are first order continuous state variables related to the deriva...
const Vector & getUWeights(const State &s) const
Definition: Subsystem.h:130
const Vector & getUErrWeights(SubsystemIndex) const
SystemQErrIndex getQErrStart(const State &s) const
Definition: Subsystem.h:199
Provide a unique integer type for identifying Subsystems.
const Vector & getQErr(const State &s) const
Definition: Subsystem.h:157
Subsystem()
Default constructor creates and empty handle with a null Subsystem::Guts pointer. ...
Definition: Subsystem.h:62
const Vector & getUDot(SubsystemIndex) const
Vector & updUDot(const State &s) const
Definition: Subsystem.h:150
ZIndex allocateZ(SubsystemIndex, const Vector &zInit)
Allocate auxiliary first order continuous state variables z.
This unique integer type is for selecting non-shared cache entries.
Vector & updZ(SubsystemIndex)
const Vector & getUErr(SubsystemIndex) const
This is the header which should be included in user programs that would like to make use of all the S...
Unique integer type for Subsystem-local, per-stage event indexing.
const Vector & getU(SubsystemIndex) const
int getNMultipliers(const State &s) const
Definition: Subsystem.h:216
void setZ(State &s, const Vector &z) const
Definition: Subsystem.h:234
This unique integer type is for indexing global "u-like" arrays, that is, arrays that inherently have...
void markDiscreteVarUpdateValueRealized(SubsystemIndex, DiscreteVariableIndex) const
Mark the update value for this auto-update discrete variable as up-to-date with respect to the state ...
Includes internal headers providing declarations for the basic SimTK Core classes.
Vector & updUDot(SubsystemIndex) const
bool isEmptyHandle() const
Return true if this handle has a null Subsystem::Guts pointer.
Definition: Subsystem.h:317
SystemYErrIndex getQErrStart() const
Returns the yErr index at which the qErr&#39;s begin. Callable at Instance stage.
EventTriggerByStageIndex allocateEventTrigger(SubsystemIndex, Stage stage, int nevent) const
Allocate room for nevent witness function values that will be available at the indicated stage...
Vector & updQDotDot(const State &s) const
Definition: Subsystem.h:154
const Vector & getQDot(SubsystemIndex) const
Per-subsystem access to the shared cache entries.
Vector & updZDot(const State &s) const
Definition: Subsystem.h:152
int getNUErr(const State &s) const
Definition: Subsystem.h:206
const Vector & getUErrWeights(const State &s) const
Definition: Subsystem.h:163
Vector & updZDot(SubsystemIndex) const
Vector & updEventTriggersByStage(Stage) const
Vector & updUDotErr(const State &s) const
Definition: Subsystem.h:177
This is the base handle class for all Measures whose value type is known, including all the Simbody b...
Definition: Measure.h:261
int getNZ() const
Get total number of shared z&#39;s (auxiliary state variables).
int getNEventTriggersByStage(Stage) const
Return the size of the partition of event trigger functions which are evaluated at a given Stage...
SystemQIndex getQStart(const State &s) const
Definition: Subsystem.h:184
void markCacheValueRealized(SubsystemIndex, CacheEntryIndex) const
Mark the value of a particular cache entry as up to date after it has been recalculated.