Simbody  3.7
MobilizedBody_Custom.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_MOBILIZED_BODY_CUSTOM_H_
2 #define SimTK_SIMBODY_MOBILIZED_BODY_CUSTOM_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm) *
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: Peter Eastman, 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 
32 
33 namespace SimTK {
34 
35 //==============================================================================
36 // MOBILIZED BODY :: CUSTOM
37 //==============================================================================
73 public:
74  class Implementation;
75  class ImplementationImpl;
76 
79  Custom() {}
80 
98  Custom(MobilizedBody& parent, Implementation* implementation,
99  const Transform& X_PF, const Body& bodyInfo, const Transform& X_BM,
100  Direction direction=Forward);
101 
104  Custom(MobilizedBody& parent, Implementation* implementation,
105  const Body& bodyInfo, Direction direction=Forward);
106  // hide from Doxygen
110 protected:
111  const Implementation& getImplementation() const;
112  Implementation& updImplementation();
113 
114 };
115 
116 // We only want the template instantiation to occur once. This symbol is
117 // defined in the Simbody compilation unit that defines the MobilizedBody class
118 // but should not be defined any other time.
119 #ifndef SimTK_SIMBODY_DEFINING_MOBILIZED_BODY
120  extern template class PIMPLHandle<MobilizedBody::Custom::Implementation,
121  MobilizedBody::Custom::ImplementationImpl>;
122 #endif
123 
124 
125 //==============================================================================
126 // MOBILIZED BODY :: CUSTOM :: IMPLEMENTATION
127 //==============================================================================
131  : public PIMPLHandle<Implementation,ImplementationImpl>
132 {
133 public:
134  // No default constructor because you have to supply at least the SimbodyMatterSubsystem
135  // to which this MobilizedBody belongs.
136 
138  virtual ~Implementation();
139 
144  virtual Implementation* clone() const = 0;
145 
169  Implementation(SimbodyMatterSubsystem&, int nu, int nq, int nAngles=0);
170 
174  Vector getQ(const State& s) const;
175 
177  Vector getU(const State& s) const;
178 
182  Vector getQDot(const State& s) const;
183 
185  Vector getUDot(const State& s) const;
186 
190  Vector getQDotDot(const State& s) const;
191 
196  Transform getMobilizerTransform(const State& s) const;
197 
204  SpatialVec getMobilizerVelocity(const State& s) const;
205 
214  bool getUseEulerAngles(const State& s) const;
215 
222  void invalidateTopologyCache() const;
223 
228 
229 
237  virtual Transform calcMobilizerTransformFromQ(const State& s, int nq, const Real* q) const = 0;
238 
239 
256  virtual SpatialVec multiplyByHMatrix(const State& s, int nu, const Real* u) const = 0;
257 
266  virtual void multiplyByHTranspose(const State& s, const SpatialVec& F, int nu, Real* f) const = 0;
267 
277  virtual SpatialVec multiplyByHDotMatrix(const State& s, int nu, const Real* u) const = 0;
278 
287  virtual void multiplyByHDotTranspose(const State& s, const SpatialVec& F, int nu, Real* f) const = 0;
288 
299  virtual void multiplyByN(const State& s, bool transposeMatrix,
300  int nIn, const Real* in, int nOut, Real* out) const;
301 
312  virtual void multiplyByNInv(const State& s, bool transposeMatrix,
313  int nIn, const Real* in, int nOut, Real* out) const;
314 
325  virtual void multiplyByNDot(const State& s, bool transposeMatrix,
326  int nIn, const Real* in, int nOut, Real* out) const;
327 
328  // Methods for setting Mobilizer initial conditions. Note -- I've stripped this
329  // down to the two basic routines but the built-ins have 8 so that you can
330  // specify only rotations or translations. I'm not sure that's needed here and
331  // I suppose you could add more routines later if needed.
332  // Eventually it might be nice to provide default implementation here that would
333  // use a root finder to attempt to solve these initial condition problems. For
334  // most joints there is a much more direct way to do it, and sometimes there
335  // are behavioral choices to make, which is why it is nice to have mobilizer-specific
336  // overrides for these.
337 
346  virtual void setQToFitTransform(const State&, const Transform& X_FM, int nq, Real* q) const;
347 
359  virtual void setUToFitVelocity(const State&, const SpatialVec& V_FM, int nu, Real* u) const;
360 
367  virtual void calcDecorativeGeometryAndAppend
368  (const State& s, Stage stage, Array_<DecorativeGeometry>& geom) const
369  {
370  }
372 
373 
382 
384  virtual void realizeTopology(State&) const { }
393 
402  virtual void realizeModel(State&) const { }
403 
407  virtual void realizeInstance(const State&) const { }
408 
413  virtual void realizeTime(const State&) const { }
414 
421  virtual void realizePosition(const State&) const { }
422 
429  virtual void realizeVelocity(const State&) const { }
430 
437  virtual void realizeDynamics(const State&) const { }
438 
445  virtual void realizeAcceleration(const State&) const { }
446 
452  virtual void realizeReport(const State&) const { }
454 
455  friend class MobilizedBody::CustomImpl;
456 };
457 
458 } // namespace SimTK
459 
460 #endif // SimTK_SIMBODY_MOBILIZED_BODY_CUSTOM_H_
461 
462 
463 
virtual void realizeTime(const State &) const
The Matter Subsystem&#39;s realizeTime() method will call this method along with the built-in MobilizedBo...
Definition: MobilizedBody_Custom.h:413
virtual void realizePosition(const State &) const
The Matter Subsystem&#39;s realizePosition() method will call this method along with the built-in Mobiliz...
Definition: MobilizedBody_Custom.h:421
virtual void realizeModel(State &) const
The Matter Subsystem&#39;s realizeModel() method will call this method along with the built-in MobilizedB...
Definition: MobilizedBody_Custom.h:402
The Body class represents a reference frame that can be used to describe mass properties and geometry...
Definition: Body.h:55
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
This class provides some infrastructure useful in making SimTK Private Implementation (PIMPL) classes...
Definition: PrivateImplementation.h:106
This class is basically a glorified enumerated type, type-safe and range checked but permitting conve...
Definition: Stage.h:66
virtual void realizeReport(const State &) const
The Matter Subsystem&#39;s realizeReport() method will call this method along with the built-in Mobilized...
Definition: MobilizedBody_Custom.h:452
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 object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:280
Custom()
Default constructor provides an empty handle that can be assigned to reference any MobilizedBody::Cus...
Definition: MobilizedBody_Custom.h:79
virtual void realizeVelocity(const State &) const
The Matter Subsystem&#39;s realizeVelocity() method will call this method along with the built-in Mobiliz...
Definition: MobilizedBody_Custom.h:429
virtual void realizeDynamics(const State &) const
The Matter Subsystem&#39;s realizeDynamics() method will call this method along with the built-in Mobiliz...
Definition: MobilizedBody_Custom.h:437
The Array_<T> container class is a plug-compatible replacement for the C++ standard template library ...
Definition: Array.h:53
#define SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(DERIVED, DERIVED_IMPL, PARENT)
Definition: PrivateImplementation.h:343
This is the implementation class for Custom mobilizers.
Definition: MobilizedBody_Custom.h:130
virtual void realizeInstance(const State &) const
The Matter Subsystem&#39;s realizeInstance() method will call this method along with the built-in Mobiliz...
Definition: MobilizedBody_Custom.h:407
Direction
Constructors can take an argument of this type to indicate that the mobilizer is being defined in the...
Definition: MobilizedBody.h:181
This defines the MobilizedBody class, which associates a new body (the "child", "outboard", or "successor" body) with a mobilizer and a reference frame on an existing body (the "parent", "inboard", or "predecessor" body) that is already part of a SimbodyMatterSubsystem.
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:68
A MobilizedBody is Simbody&#39;s fundamental body-and-joint object used to parameterize a system&#39;s motion...
Definition: MobilizedBody.h:168
virtual void realizeAcceleration(const State &) const
The Matter Subsystem&#39;s realizeAcceleration() method will call this method along with the built-in Mob...
Definition: MobilizedBody_Custom.h:445
The handle class MobilizedBody::Custom (dataless) and its companion class MobilizedBody::Custom::Impl...
Definition: MobilizedBody_Custom.h:72
This subsystem contains the bodies ("matter") in the multibody system, the mobilizers (joints) that d...
Definition: SimbodyMatterSubsystem.h:133