Simbody  3.7
Measure.h
Go to the documentation of this file.
1 #ifndef SimTK_SimTKCOMMON_MEASURE_H_
2 #define SimTK_SimTKCOMMON_MEASURE_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) 2008-13 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 
37 #include "SimTKcommon/basics.h"
38 #include "SimTKcommon/Simmatrix.h"
39 
40 #include <cassert>
41 
62 // Helper macro shared by SimTK_MEASURE_HANDLE_PREAMBLE and
63 // SimTK_MEASURE_HANDLE_PREAMBLE_ABSTRACT.
64 #define SimTK_MEASURE_HANDLE_PREAMBLE_BASE(MH,PH) \
65  class Implementation; \
66  explicit MH(Implementation* imp) : PH(imp) {} \
67  MH(SimTK::Subsystem& sub, Implementation* imp, \
68  const SimTK::AbstractMeasure::SetHandle& sh) \
69  : PH(sub,imp,sh) {} \
70  MH& operator=(const MH& src) {PH::operator=(src); return *this;}\
71  MH& shallowAssign(const MH& src) {PH::shallowAssign(src); return *this;}\
72  MH& deepAssign(const MH& src) {PH::deepAssign(src); return *this;}
73 
74 
75 // The default constructor for concrete classes should instantiate
76 // a default-constructed Implementation object if no Implementation object
77 // is provided.
78 #define SimTK_MEASURE_HANDLE_PREAMBLE(MH,PH) \
79  SimTK_MEASURE_HANDLE_PREAMBLE_BASE(MH,PH) \
80  MH() : PH(new Implementation()) {} \
81  explicit MH(SimTK::Subsystem& sub) \
82  : PH(sub,new Implementation(), typename PH::SetHandle()) {}
83 
84 
85 
86 // The default constructor for a still-abstract derived class can't
87 // instantiate an Implementation.
88 #define SimTK_MEASURE_HANDLE_PREAMBLE_ABSTRACT(MH,PH) \
89  SimTK_MEASURE_HANDLE_PREAMBLE_BASE(MH,PH) \
90  MH() : PH() {}
91 
111 #define SimTK_MEASURE_HANDLE_POSTSCRIPT(MH,PH) \
112  static bool isA(const SimTK::AbstractMeasure& m) \
113  { return dynamic_cast<const Implementation*>(&m.getImpl()) != 0; } \
114  static const MH& getAs(const SimTK::AbstractMeasure& m) \
115  { assert(isA(m)); return static_cast<const MH&>(m); } \
116  static MH& updAs(SimTK::AbstractMeasure& m) \
117  { assert(isA(m)); return static_cast<MH&>(m); } \
118  const Implementation& getImpl() const \
119  { return SimTK_DYNAMIC_CAST_DEBUG<const Implementation&> \
120  (SimTK::AbstractMeasure::getImpl());} \
121  Implementation& updImpl() \
122  { return SimTK_DYNAMIC_CAST_DEBUG<Implementation&> \
123  (SimTK::AbstractMeasure::updImpl());}
124 
125 namespace SimTK {
126 
127 class State;
128 class Subsystem;
129 class System;
130 class EventId;
131 
133 SimTK_DEFINE_UNIQUE_INDEX_TYPE(MeasureIndex);
134 
135 //==============================================================================
136 // ABSTRACT MEASURE
137 //==============================================================================
152 protected:
156  class SetHandle {};
157 
158 public:
159  class Implementation; // local; name is AbstractMeasure::Implementation
160 
164  explicit AbstractMeasure(Implementation* g=0);
165 
171 
175 
180  { return shallowAssign(source); }
181 
184  ~AbstractMeasure();
185 
191  AbstractMeasure& shallowAssign(const AbstractMeasure&);
192 
197  AbstractMeasure& deepAssign(const AbstractMeasure& source);
198 
206  int getNumTimeDerivatives() const;
207 
216  Stage getDependsOnStage(int derivOrder=0) const;
217 
218 
220  bool isSameMeasure(const AbstractMeasure& other) const
221  { return impl && impl==other.impl;}
222 
223  bool isEmptyHandle() const {return !hasImpl();}
224 
226  bool isInSubsystem() const;
230  const Subsystem& getSubsystem() const;
232  bool isSameSubsystem(const Subsystem&) const;
236  MeasureIndex getSubsystemMeasureIndex() const;
237 
238  // Internal use only
239 
240  // dynamic_cast the returned reference to a reference to your concrete
241  // Implementation class.
242  const Implementation& getImpl() const {assert(impl); return *impl;}
243  Implementation& updImpl() {assert(impl); return *impl;}
244  bool hasImpl() const {return impl!=0;}
245 
246  int getRefCount() const;
247 private:
248  // This is the only data member in this class. Also, any class derived
249  // from AbstractMeasure must have *NO* data members at all (data goes
250  // in the Implementation class).
251  Implementation* impl;
252 
253 friend class Implementation;
254 };
255 
256 
257 //==============================================================================
258 // MEASURE <T>
259 //==============================================================================
262 template <class T>
263 class Measure_ : public AbstractMeasure {
264 public:
268 
276  const T& getValue(const State& s, int derivOrder=0) const
277  { return getImpl().getValue(s,derivOrder); }
278 
285  Measure_& setDefaultValue(const T& defaultValue)
286  { updImpl().setDefaultValue(defaultValue); return *this; }
287 
290  const T& getDefaultValue() const
291  { return getImpl().getDefaultValue(); }
292 
293  // These are built-in Measures with local class names.
294 
295  // Templatized measures may have restrictions on the allowable template
296  // type and may be specialized for particular types.
297  class Zero; // T is any numerical type
298  class One; // T is any numerical type
299  class Constant; // T is any assignable type
300  class Time; // T is any type for which T(t) makes sense.
301  class Variable; // T is any assignable type (state)
302  class Result; // T is any assignable type (cache)
303  class SampleAndHold;// T is any assignable type
304  class Delay; // T is any assignable type
305 
306  // This requires any numerical type.
307  class Plus;
308  class Minus;
309  class Scale;
310  class Differentiate;
311 
312  // These find extreme values *in time*, not among inputs at the same
313  // time. They perform elementwise on aggregate types.
314  class Extreme; // base class for min/max/minabs/maxabs
315  class Minimum; // most positive value
316  class Maximum; // most negative value
317  class MinAbs; // the signed quantity whose absolute value was min
318  class MaxAbs; // the signed quantity whose absolute value was max
319 
320  // These accept floating point numerical template arguments only.
321  class Integrate;
322  class Sinusoid;
323 
325 };
326 
331 
332 
333 //==============================================================================
334 // CONSTANT
335 //==============================================================================
340 template <class T>
341 class Measure_<T>::Constant : public Measure_<T> {
342 public:
344 
347  explicit Constant(const T& value)
348  : Measure_<T>(new Implementation(value)) {}
349 
352  Constant(Subsystem& sub, const T& value)
353  : Measure_<T>(sub, new Implementation(value),
355 
358  Constant& setValue(const T& value)
359  { updImpl().setValue(value); return *this; }
360 
362 };
363 
364 //==============================================================================
365 // ZERO
366 //==============================================================================
370 template <class T>
371 class Measure_<T>::Zero : public Measure_<T>::Constant {
372 public:
373  Zero();
374  explicit Zero(Subsystem& sub);
375 };
376 
377 template <>
378 class Measure_< Vector >::Zero : public Measure_< Vector >::Constant {
379 public:
380  explicit Zero(int size);
381  Zero(Subsystem& sub, int size);
382 };
383 
384 //==============================================================================
385 // ONE
386 //==============================================================================
390 template <class T>
391 class Measure_<T>::One : public Measure_<T>::Constant {
392 public:
393  One();
394  explicit One(Subsystem& sub);
395 };
396 
397 template <>
398 class Measure_< Vector >::One : public Measure_< Vector >::Constant {
399 public:
400  explicit One(int size);
401  One(Subsystem& sub, int size);
402 };
403 
404 //==============================================================================
405 // TIME
406 //==============================================================================
408 template <class T>
409 class Measure_<T>::Time : public Measure_<T> {
410 public:
412 
414 };
415 
416 //==============================================================================
417 // VARIABLE
418 //==============================================================================
421 template <class T>
422 class Measure_<T>::Variable : public Measure_<T> {
423 public:
425 
426  // TODO: should not require invalidated Stage here. Instead,
427  // should have a unique "generation" counter for this variable
428  // and allow subsequent users to check it.
429  Variable(Subsystem& sub, Stage invalidates, const T& defaultValue)
430  : Measure_<T>(sub, new Implementation(invalidates, defaultValue),
432 
433 
434  void setValue(State& state, const T& value) const
435  { getImpl().setValue(state, value); }
436 
438 };
439 
440 //==============================================================================
441 // RESULT
442 //==============================================================================
456 template <class T>
457 class Measure_<T>::Result : public Measure_<T> {
458 public:
460 
461  // TODO: should not require invalidated Stage here. Instead,
462  // should have a unique "generation" counter for this cache entry
463  // and allow subsequent users of the value to check it.
464 
479  Result(Subsystem& sub, Stage dependsOn, Stage invalidated)
480  : Measure_<T>(sub, new Implementation(dependsOn, invalidated),
482 
486  Stage getInvalidatedStage() const {return getImpl().getInvalidatedStage();}
495  { updImpl().setDependsOnStage(dependsOn); return *this; }
502  { updImpl().setInvalidatedStage(invalidated); return *this; }
503 
517  { updImpl().setIsPresumedValidAtDependsOnStage(presume); return *this; }
518 
523 
524 
530  T& updValue(const State& state) const
531  { return getImpl().updValue(state); }
532 
539  void markAsValid(const State& state) const {getImpl().markAsValid(state);}
540 
544  bool isValid(const State& state) const {return getImpl().isValid(state);}
545 
553  void markAsNotValid(const State& state) const
554  { getImpl().markAsNotValid(state); }
555 
559  void setValue(const State& state, const T& value) const
560  { updValue(state) = value; markAsValid(state); }
561 
563 };
564 
565 //==============================================================================
566 // SINUSOID
567 //==============================================================================
574 template <class T>
575 class Measure_<T>::Sinusoid : public Measure_<T> {
576 public:
578 
580  const T& amplitude,
581  const T& frequency,
582  const T& phase=T(0))
583  : Measure_<T>(sub, new Implementation(amplitude,frequency,phase),
585 
587 };
588 
589 //==============================================================================
590 // PLUS
591 //==============================================================================
596 template <class T>
597 class Measure_<T>::Plus : public Measure_<T> {
598 public:
600 
601  Plus(Subsystem& sub, const Measure_<T>& left, const Measure_<T>& right)
602  : Measure_<T>(sub, new Implementation(left, right),
605  ( this->isSameSubsystem(left.getSubsystem())
606  && this->isSameSubsystem(right.getSubsystem()),
607  "Measure_<T>::Plus::ctor()",
608  "Arguments must be in the same Subsystem as this Measure.");
609  }
610 
612 };
613 
614 //==============================================================================
615 // MINUS
616 //==============================================================================
621 template <class T>
622 class Measure_<T>::Minus : public Measure_<T> {
623 public:
625 
626  Minus(Subsystem& sub, const Measure_<T>& left, const Measure_<T>& right)
627  : Measure_<T>(sub, new Implementation(left, right),
630  ( this->isSameSubsystem(left.getSubsystem())
631  && this->isSameSubsystem(right.getSubsystem()),
632  "Measure_<T>::Minus::ctor()",
633  "Arguments must be in the same Subsystem as this Measure.");
634  }
635 
637 };
638 
639 //==============================================================================
640 // SCALE
641 //==============================================================================
646 template <class T>
647 class Measure_<T>::Scale : public Measure_<T> {
648 public:
650 
651  Scale(Subsystem& sub, Real factor, const Measure_<T>& operand)
652  : Measure_<T>(sub, new Implementation(factor, operand),
655  (this->isSameSubsystem(operand.getSubsystem()),
656  "Measure_<T>::Scale::ctor()",
657  "Argument must be in the same Subsystem as this Measure.");
658  }
659 
662  { return getImpl().getOperandMeasure(); }
663 
665 };
666 
667 //==============================================================================
668 // INTEGRATE
669 //==============================================================================
676 template <class T>
677 class Measure_<T>::Integrate : public Measure_<T> {
678 public:
680 
687  Integrate(Subsystem& subsystem,
688  const Measure_<T>& deriv,
689  const Measure_<T>& ic,
690  const T& initAlloc=T(0))
691  : Measure_<T>(subsystem, new Implementation(deriv,ic,initAlloc),
693 
696  void setValue(State& s, const T& value) const
697  { return getImpl().setValue(s, value); }
698 
701 
702  { return getImpl().getDerivativeMeasure(); }
706  { return getImpl().getInitialConditionMeasure(); }
707 
709  { updImpl().setDerivativeMeasure(d); return *this; }
711  { updImpl().setInitialConditionMeasure(ic); return *this; }
712 
714 };
715 
716 //==============================================================================
717 // DIFFERENTIATE
718 //==============================================================================
743 template <class T>
744 class Measure_<T>::Differentiate : public Measure_<T> {
745 public:
747 
752  Differentiate(Subsystem& subsystem, const Measure_<T>& operand)
753  : Measure_<T>(subsystem, new Implementation(operand),
755 
760  bool isUsingApproximation() const
761  { return getImpl().isUsingApproximation(); }
762 
766  { return getImpl().getOperandMeasure(); }
767 
772  { updImpl().setOperandMeasure(operand); return *this; }
773 
777  void setForceUseApproximation(bool mustApproximate)
778  { updImpl().setForceUseApproximation(mustApproximate); }
779 
785  { return getImpl().getForceUseApproximation(); }
786 
788 };
789 
790 //==============================================================================
791 // EXTREME, MINIMUM, MAXIMUM, MINABS, MAXABS
792 //==============================================================================
836 template <class T>
837 class Measure_<T>::Extreme : public Measure_<T> {
838 public:
840 
841  enum Operation {
842  MaxAbs, // default
846  };
847 
851  Extreme(Subsystem& sub, const Measure_<T>& operand, Operation op=MaxAbs)
852  : Measure_<T>(sub, new Implementation(operand, op),
854 
857  { updImpl().setOperation(op); return *this; }
858 
860  Operation getOperation() const {return getImpl().getOperation();}
861 
867  Real getTimeOfExtremeValue(const State& state) const
868  { return getImpl().getTimeOfExtremeValue(state); }
869 
870  void setValue(State& s, const T& value) const
871  { return getImpl().setValue(s, value); }
872 
874  { return getImpl().getOperandMeasure(); }
875 
877  { updImpl().setOperandMeasure(s); return *this; }
878 
880 };
881 
884 template <class T>
885 class Measure_<T>::Minimum : public Measure_<T>::Extreme {
886  typedef typename Measure_<T>::Extreme Super;
887 public:
888  Minimum(Subsystem& sub, const Measure_<T>& operand)
889  : Super(sub, operand, Super::Minimum) {}
890 };
891 
894 template <class T>
895 class Measure_<T>::Maximum : public Measure_<T>::Extreme {
896  typedef typename Measure_<T>::Extreme Super;
897 public:
898  Maximum(Subsystem& sub, const Measure_<T>& operand)
899  : Super(sub, operand, Super::Maximum) {}
900 };
901 
904 template <class T>
905 class Measure_<T>::MaxAbs : public Measure_<T>::Extreme {
906  typedef typename Measure_<T>::Extreme Super;
907 public:
908  MaxAbs(Subsystem& sub, const Measure_<T>& operand)
909  : Super(sub, operand, Super::MaxAbs) {}
910 };
911 
915 template <class T>
916 class Measure_<T>::MinAbs : public Measure_<T>::Extreme {
917  typedef typename Measure_<T>::Extreme Super;
918 public:
919  MinAbs(Subsystem& sub, const Measure_<T>& operand)
920  : Super(sub, operand, Super::MinAbs) {}
921 };
922 
923 //==============================================================================
924 // DELAY
925 //==============================================================================
972 template <class T>
973 class Measure_<T>::Delay : public Measure_<T> {
974 public:
981  Delay(Subsystem& sub, const Measure_<T>& source, Real delay)
982  : Measure_<T>(sub, new Implementation(source, delay),
984 
991  { updImpl().setUseLinearInterpolationOnly(linearOnly); return *this; }
992 
1006  Delay& setCanUseCurrentValue(bool canUseCurrentValue)
1007  { updImpl().setCanUseCurrentValue(canUseCurrentValue); return *this; }
1008 
1011  { updImpl().setSourceMeasure(source); return *this; }
1012 
1015  { updImpl().setDelay(delay); return *this; }
1016 
1019  { return getImpl().getUseLinearInterpolationOnly(); }
1020 
1023  { return getImpl().getCanUseCurrentValue(); }
1024 
1027  { return getImpl().getSourceMeasure(); }
1028 
1031  Real getDelay() const
1032  { return getImpl().getDelay(); }
1033 
1037 };
1038 
1039 //==============================================================================
1040 // SAMPLE AND HOLD
1041 //==============================================================================
1056 template <class T>
1057 class Measure_<T>::SampleAndHold : public Measure_<T> {
1058 public:
1060 
1061  SampleAndHold(Subsystem& sub, const Measure_<T>& source, EventId e);
1062 
1065  void setValue(State& s, const T& value) const;
1066 
1068  void sample(State& s) const;
1069 
1070  const Measure_<T>& getSource() const;
1071  EventId getEventId() const;
1072 
1073  SampleAndHold& setSource(const Measure_<T>& s);
1074  SampleAndHold& setEventId(EventId);
1075 
1077 };
1078 
1079 } // namespace SimTK
1080 
1081 #endif // SimTK_SimTKCOMMON_MEASURE_H_
Definition: MeasureImplementation.h:2028
void setIsPresumedValidAtDependsOnStage(bool presume)
Definition: MeasureImplementation.h:418
Definition: MeasureImplementation.h:610
const Measure_< T > & getOperandMeasure() const
Definition: Measure.h:873
A Subsystem is expected to be part of a larger System and to have interdependencies with other subsys...
Definition: Subsystem.h:55
Constant(const T &value)
Create a constant measure that is not part of any Subsystem, and provide the constant value...
Definition: Measure.h:347
Plus(Subsystem &sub, const Measure_< T > &left, const Measure_< T > &right)
Definition: Measure.h:601
#define SimTK_SimTKCOMMON_EXPORT
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:224
Variable(Subsystem &sub, Stage invalidates, const T &defaultValue)
Definition: Measure.h:429
SimTK_DEFINE_UNIQUE_INDEX_TYPE(AssemblyConditionIndex)
Integrate & setDerivativeMeasure(const Measure_< T > &d)
Definition: Measure.h:708
bool isUsingApproximation() const
Test whether the derivative returned as the value of this measure is being estimated numerically...
Definition: Measure.h:760
Extreme & setOperation(Operation op)
Set the operation to be performed.
Definition: Measure.h:856
const Measure_< T > & getOperandMeasure() const
Get a reference to the measure that is being differentiated by this measure.
Definition: Measure.h:765
bool getUseLinearInterpolationOnly() const
Return the value of the "use linear interpolation only" flag.
Definition: Measure.h:1018
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
Definition: Measure.h:842
void setValue(State &s, const T &value) const
Definition: Measure.h:870
This creates a Measure whose value is a discrete State variable of any type T.
Definition: Measure.h:422
const Subsystem & getSubsystem() const
Return a reference to the Subsystem that owns this Measure.
Definition: MeasureImplementation.h:229
const T & getDefaultValue() const
Obtain a reference to the default value associated with this Measure.
Definition: Measure.h:290
const Measure_< T > & getOperandMeasure() const
Get the operand (thing being scaled) measure for this measure.
Definition: Measure.h:661
const Real Zero
Real(0)
Result & setIsPresumedValidAtDependsOnStage(bool presume)
Normally a Result measure&#39;s value is not considered valid unless we are notified explicitly that it i...
Definition: Measure.h:516
This class is basically a glorified enumerated type, type-safe and range checked but permitting conve...
Definition: Stage.h:66
Extreme(Subsystem &sub, const Measure_< T > &operand, Operation op=MaxAbs)
Default behavior for the Extreme measure is to find the operand&#39;s value that is of maximum absolute v...
Definition: Measure.h:851
Track the value of the operand that is of maximum absolute value.
Definition: Measure.h:905
The abstract parent of all Measure Implementation classes.
Definition: MeasureImplementation.h:48
const Measure_< T > & getInitialConditionMeasure() const
Get the measure whose value is used as an initial condition for the integral at the start of an integ...
Definition: Measure.h:705
Measure_ & setDefaultValue(const T &defaultValue)
Change the default value associated with this Measure.
Definition: Measure.h:285
Definition: MeasureImplementation.h:790
This Measure is the sum of two Measures of the same type T.
Definition: Measure.h:597
void setForceUseApproximation(bool mustApproximate)
Force use of numerical approximation for the derivative, even if the operand measure can supply its o...
Definition: Measure.h:777
This is the base class for all Measure handle classes.
Definition: Measure.h:151
Stage getDependsOnStage(int derivOrder) const
Definition: MeasureImplementation.h:105
This Measure operator returns the time derivative of its operand measure, or a numerical approximatio...
Definition: Measure.h:744
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:606
This Measure tracks extreme values attained by the elements of its source operand since the last init...
Definition: Measure.h:837
Operation getOperation() const
Return the operation currently being performed by this measure.
Definition: Measure.h:860
(CAUTION: still under development) This is a Measure whose value at time t is the value that its sour...
Definition: Measure.h:973
const Measure_< T > & getDerivativeMeasure() const
Get the integrand (derivative) measure for this integral.
Definition: Measure.h:700
Track the minimum value of the operand (signed).
Definition: Measure.h:885
Result & setInvalidatedStage(Stage invalidated)
Change the invalidated stage for this measure&#39;s value, which must be strictly greater than the curren...
Definition: Measure.h:501
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:280
This creates a Measure::Time whose value is always T(time).
Definition: Measure.h:409
Definition: MeasureImplementation.h:1023
void setValue(State &s, const T &value) const
Set the current value of this measure by modifying the state variables that hold the integral...
Definition: Measure.h:696
This creates a Measure::Constant whose value is always T(0) and can&#39;t be changed. ...
Definition: Measure.h:371
bool isEmptyHandle() const
Definition: Measure.h:223
Real getDelay() const
Get the amount of time by which this Measure is delaying its source Measure.
Definition: Measure.h:1031
Measure_< Real > Measure
This typedef is a convenient abbreviation for the most common kind of Measure – one that returns a s...
Definition: Measure.h:330
SimTK_MEASURE_HANDLE_POSTSCRIPT(Measure_, AbstractMeasure)
bool getIsPresumedValidAtDependsOnStage() const
Definition: MeasureImplementation.h:422
Stage getInvalidatedStage() const
Get the invalidated stage for this measure&#39;s value.
Definition: Measure.h:486
Implementation & updImpl()
Definition: Measure.h:243
T & updValue(const State &state) const
Obtain write access to the Measure&#39;s value in order to modify it.
Definition: Measure.h:530
Delay(Subsystem &sub, const Measure_< T > &source, Real delay)
Create a Measure whose output is the same as the given source measure but delayed by a time delay...
Definition: Measure.h:981
Definition: MeasureImplementation.h:970
Definition: Measure.h:844
Minus(Subsystem &sub, const Measure_< T > &left, const Measure_< T > &right)
Definition: Measure.h:626
Definition: MeasureImplementation.h:1076
This Measure multiplies some other Measure by a Real scale factor.
Definition: Measure.h:647
bool hasImpl() const
Definition: Measure.h:244
#define SimTK_ERRCHK_ALWAYS(cond, whereChecked, msg)
Definition: ExceptionMacros.h:281
Delay & setDelay(Real delay)
Change the delay time.
Definition: Measure.h:1014
void setValue(const State &state, const T &value) const
Set a new value and mark it as valid.
Definition: Measure.h:559
MaxAbs(Subsystem &sub, const Measure_< T > &operand)
Definition: Measure.h:908
bool getIsPresumedValidAtDependsOnStage() const
Return the value of the "presumed valid at dependsOn stage" flag.
Definition: Measure.h:521
This creates a Measure whose value is a Topology-stage constant of any type T.
Definition: Measure.h:341
Scale(Subsystem &sub, Real factor, const Measure_< T > &operand)
Definition: Measure.h:651
Constant(Subsystem &sub, const T &value)
Create a constant measure with the given value and install it into the given Subsystem.
Definition: Measure.h:352
MinAbs(Subsystem &sub, const Measure_< T > &operand)
Definition: Measure.h:919
Extreme & setOperandMeasure(const Measure_< T > &s)
Definition: Measure.h:876
This creates a Measure::Constant whose value is always T(1) and can&#39;t be changed. ...
Definition: Measure.h:391
#define SimTK_MEASURE_HANDLE_PREAMBLE(MH, PH)
Definition: Measure.h:78
const Implementation & getImpl() const
Definition: Measure.h:242
AbstractMeasure & operator=(const AbstractMeasure &source)
Shallow assignment operator results in this handle referencing the same Implementation object as does...
Definition: Measure.h:179
Definition: MeasureImplementation.h:906
bool isValid(const State &state) const
Check whether the value contained in this Measure is currently valid.
Definition: Measure.h:544
SimTK_MEASURE_HANDLE_PREAMBLE_ABSTRACT(Measure_, AbstractMeasure)
This class is still abstract so we don&#39;t want it to allocate an Implementation object in its default ...
bool isSameSubsystem(const Subsystem &) const
Is getSubsystem() the same as the passed-in Subsystem?
Definition: MeasureImplementation.h:233
Stage getDependsOnStage() const
Get the dependsOn stage for this measure&#39;s value.
Definition: Measure.h:484
const Real One
Real(1)
Definition: MeasureImplementation.h:1443
NOT IMPLEMENTED YET – This is a Measure operator which, upon occurrence of a designated event...
Definition: Measure.h:1057
Sinusoid(Subsystem &sub, const T &amplitude, const T &frequency, const T &phase=T(0))
Definition: Measure.h:579
Definition: Measure.h:843
The implementation for Integrate measures allocates a continuous state variable or variables from the...
Definition: MeasureImplementation.h:1145
This Measure is the difference of two Measures of the same type T.
Definition: Measure.h:622
void setValue(State &state, const T &value) const
Definition: Measure.h:434
Differentiate(Subsystem &subsystem, const Measure_< T > &operand)
Create a measure whose value is the time derivative of the given operand measure. ...
Definition: Measure.h:752
void markAsValid(const State &state) const
Mark the current value as valid.
Definition: Measure.h:539
This measure produces a sinusoidal function of time:
Definition: Measure.h:575
Track the maximum value of the operand (signed).
Definition: Measure.h:895
Integrate & setInitialConditionMeasure(const Measure_< T > &ic)
Definition: Measure.h:710
This Measure holds the result of some externally-determined computation, and helps to coordinate the ...
Definition: Measure.h:457
void markAsNotValid(const State &state) const
Manually mark the contained value as invalid.
Definition: Measure.h:553
Real getTimeOfExtremeValue(const State &state) const
Return the time at which the reported extreme value first occurred.
Definition: Measure.h:867
Maximum(Subsystem &sub, const Measure_< T > &operand)
Definition: Measure.h:898
const T & getValue(const State &s, int derivOrder=0) const
Retrieve the Value of this Measure or one of its time derivatives, assuming the supplied State has be...
Definition: Measure.h:276
Minimum(Subsystem &sub, const Measure_< T > &operand)
Definition: Measure.h:888
Result(Subsystem &sub, Stage dependsOn, Stage invalidated)
Create a new Result measure and add it to the indicated subsystem.
Definition: Measure.h:479
Operation
Definition: Measure.h:841
Track the value of the operand that is of minimum absolute value (not very useful).
Definition: Measure.h:916
An object of this type is used as a dummy argument to make sure the automatically-generated handle co...
Definition: Measure.h:156
void setDefaultValue(const T &defaultValue)
Set a new default value for this Measure.
Definition: MeasureImplementation.h:407
const T & getValue(const State &s, int derivOrder) const
Definition: MeasureImplementation.h:365
const Measure_< T > & getSourceMeasure() const
Obtain a reference to the source Measure.
Definition: Measure.h:1026
const T & getDefaultValue() const
Return a reference to the value that this Measure will use to initialize its value-level state resour...
Definition: MeasureImplementation.h:416
Delay & setCanUseCurrentValue(bool canUseCurrentValue)
(Advanced) Allow the Delay measure to refer to the current value when estimating the delayed value...
Definition: Measure.h:1006
Definition: MeasureImplementation.h:710
Constant & setValue(const T &value)
Change the value returned by this Measure.
Definition: Measure.h:358
This is the header which should be included in user programs that would like to make use of all the S...
Includes internal headers providing declarations for the basic SimTK Core classes.
bool isSameMeasure(const AbstractMeasure &other) const
There can be multiple handles on the same Measure.
Definition: Measure.h:220
Differentiate & setOperandMeasure(const Measure_< T > &operand)
Set the measure that is to be differentiated by this measure.
Definition: Measure.h:771
Integrate(Subsystem &subsystem, const Measure_< T > &deriv, const Measure_< T > &ic, const T &initAlloc=T(0))
Create a new measure that will use Measure ic&#39;s value for initial conditions, and then integrate the ...
Definition: Measure.h:687
Delay & setUseLinearInterpolationOnly(bool linearOnly)
(Advanced) Restrict the Delay measure to use only linear interpolation to estimate delayed values...
Definition: Measure.h:990
Definition: MeasureImplementation.h:1303
Result & setDependsOnStage(Stage dependsOn)
Change the dependsOn stage for this measure&#39;s value, which must be strictly less than the current set...
Definition: Measure.h:494
bool getCanUseCurrentValue() const
Return the value of the "can use current value" flag.
Definition: Measure.h:1022
bool getForceUseApproximation() const
Check the current value of the flag which forces this measure to use numerical approximation regardle...
Definition: Measure.h:784
This is the base handle class for all Measures whose value type is known, including all the Simbody b...
Definition: Measure.h:263
Delay & setSourceMeasure(const Measure_< T > &source)
Replace the source measure.
Definition: Measure.h:1010
This measure yields the time integral of a given derivative measure, initializing with an initial con...
Definition: Measure.h:677
This is a class to represent unique IDs for events in a type-safe way.