Simbody  3.8
Force.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_FORCE_H_
2 #define SimTK_SIMBODY_FORCE_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 
27 #include "SimTKcommon.h"
30 
31 namespace SimTK {
32 
33 class SimbodyMatterSubsystem;
34 class GeneralForceSubsystem;
35 class MobilizedBody;
36 class Force;
37 class ForceImpl;
38 
39 // We only want the template instantiation to occur once. This symbol is defined
40 // in the SimTK core compilation unit that defines the Force class but should
41 // not be defined any other time.
42 #ifndef SimTK_SIMBODY_DEFINING_FORCE
43  extern template class PIMPLHandle<Force, ForceImpl, true>;
44 #endif
45 
51 public:
62  void disable(State&) const;
66  void enable(State&) const;
70  bool isDisabled(const State&) const;
76  void setDisabledByDefault(bool shouldBeDisabled);
80  bool isDisabledByDefault() const;
130  void calcForceContribution(const State& state,
131  Vector_<SpatialVec>& bodyForces,
132  Vector_<Vec3>& particleForces,
133  Vector& mobilityForces) const;
154  Force() {}
158  operator ForceIndex() const {return getForceIndex();}
169  class TwoPointLinearSpring;
170  class TwoPointLinearDamper;
171  class TwoPointConstantForce;
172  class MobilityLinearSpring;
173  class MobilityLinearDamper;
174  class MobilityConstantForce;
175  class MobilityLinearStop;
176  class MobilityDiscreteForce;
177  class DiscreteForces;
178  class LinearBushing;
179  class ConstantForce;
180  class ConstantTorque;
181  class GlobalDamper;
182  class Thermostat;
183  class UniformGravity;
184  class Gravity;
185  class Custom;
186 
187  class TwoPointLinearSpringImpl;
188  class TwoPointLinearDamperImpl;
189  class TwoPointConstantForceImpl;
190  class MobilityLinearSpringImpl;
191  class MobilityLinearDamperImpl;
192  class MobilityConstantForceImpl;
193  class MobilityLinearStopImpl;
194  class MobilityDiscreteForceImpl;
195  class DiscreteForcesImpl;
196  class LinearBushingImpl;
197  class ConstantForceImpl;
198  class ConstantTorqueImpl;
199  class GlobalDamperImpl;
200  class ThermostatImpl;
201  class UniformGravityImpl;
202  class GravityImpl;
203  class CustomImpl;
204 
205 protected:
208  explicit Force(ForceImpl* r) : HandleBase(r) { }
209 };
210 
211 
224 public:
236  TwoPointLinearSpring(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real k, Real x0);
237 
240 
242 };
243 
257 public:
268  TwoPointLinearDamper(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real damping);
269 
272 
274 };
275 
288 public:
299  TwoPointConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real force);
300 
303 
305 };
306 
307 
316 public:
317  ConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body, const Vec3& station, const Vec3& force);
318 
321 
323 };
324 
333 public:
334  ConstantTorque(GeneralForceSubsystem& forces, const MobilizedBody& body, const Vec3& torque);
335 
338 
340 };
341 
357 public:
359 
362 
364 };
365 
377 public:
379  const SimbodyMatterSubsystem& matter,
380  const Vec3& g, Real zeroHeight=0);
381 
384 
385  Vec3 getGravity() const;
386  void setGravity(const Vec3& g);
388  void setZeroHeight(Real height);
390 };
391 
392 } // namespace SimTK
393 
394 #endif // SimTK_SIMBODY_FORCE_H_
Includes internal headers providing declarations for the basic SimTK Core classes,...
Every Simbody header and source file should include this header before any other Simbody header.
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:68
This type represents the index of a Force element within its subsystem.
A constant force applied to a body station.
Definition: Force.h:315
ConstantForce()
Default constructor creates an empty handle.
Definition: Force.h:320
ConstantForce(GeneralForceSubsystem &forces, const MobilizedBody &body, const Vec3 &station, const Vec3 &force)
SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(ConstantForce, ConstantForceImpl, Force)
A constant torque to a body.
Definition: Force.h:332
ConstantTorque()
Default constructor creates an empty handle.
Definition: Force.h:337
ConstantTorque(GeneralForceSubsystem &forces, const MobilizedBody &body, const Vec3 &torque)
SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(ConstantTorque, ConstantTorqueImpl, Force)
This class is used to define new force elements.
Definition: Force_Custom.h:193
Arbitrary discrete body forces and mobility (generalized) forces. Useful for applying external forces...
Definition: Force_DiscreteForces.h:41
A general energy "drain" on the system.
Definition: Force.h:356
SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(GlobalDamper, GlobalDamperImpl, Force)
GlobalDamper()
Default constructor creates an empty handle.
Definition: Force.h:361
GlobalDamper(GeneralForceSubsystem &forces, const SimbodyMatterSubsystem &matter, Real damping)
This force element represents a uniform gravitational field applied to a set of bodies.
Definition: Force_Gravity.h:70
This force element represents a bushing acting to connect a frame F fixed on one body (B1) to a frame...
Definition: Force_LinearBushing.h:101
A constant generalized force f (a scalar) applied to a mobility.
Definition: Force_MobilityConstantForce.h:45
A discrete mobility (generalized) force f applied to a particular mobility that is specified at const...
Definition: Force_MobilityDiscreteForce.h:52
A linear damper that acts along or around a mobility coordinate to apply a generalized force there.
Definition: Force_MobilityLinearDamper.h:46
A linear spring that acts along or around a mobility coordinate to apply a generalized force there.
Definition: Force_MobilityLinearSpring.h:49
Model a compliant stop element that acts to keep a mobilizer coordinate q within specified bounds.
Definition: Force_MobilityLinearStop.h:65
This is a feedback-controlled force that uses Nose'-Hoover chains to maintain a particular temperatur...
Definition: Force_Thermostat.h:131
A constant force f (a signed scalar) which acts along the line between two points,...
Definition: Force.h:287
TwoPointConstantForce(GeneralForceSubsystem &forces, const MobilizedBody &body1, const Vec3 &station1, const MobilizedBody &body2, const Vec3 &station2, Real force)
Create a TwoPointConstantForce.
TwoPointConstantForce()
Default constructor creates an empty handle.
Definition: Force.h:302
SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointConstantForce, TwoPointConstantForceImpl, Force)
A force which resists changes in the distance between two points, acting along the line between those...
Definition: Force.h:256
SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointLinearDamper, TwoPointLinearDamperImpl, Force)
TwoPointLinearDamper()
Default constructor creates an empty handle.
Definition: Force.h:271
TwoPointLinearDamper(GeneralForceSubsystem &forces, const MobilizedBody &body1, const Vec3 &station1, const MobilizedBody &body2, const Vec3 &station2, Real damping)
Create a TwoPointLinearDamper.
A linear spring between two points, specified as a station on each of two bodies.
Definition: Force.h:223
TwoPointLinearSpring(GeneralForceSubsystem &forces, const MobilizedBody &body1, const Vec3 &station1, const MobilizedBody &body2, const Vec3 &station2, Real k, Real x0)
Create a TwoPointLinearSpring.
SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointLinearSpring, TwoPointLinearSpringImpl, Force)
TwoPointLinearSpring()
Default constructor creates an empty handle.
Definition: Force.h:239
A uniform gravitational force applied to every body in the system. See Force::Gravity for a more flex...
Definition: Force.h:376
UniformGravity(GeneralForceSubsystem &forces, const SimbodyMatterSubsystem &matter, const Vec3 &g, Real zeroHeight=0)
void setGravity(const Vec3 &g)
UniformGravity()
Default constructor creates an empty handle.
Definition: Force.h:383
SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(UniformGravity, UniformGravityImpl, Force)
void setZeroHeight(Real height)
This is the base class from which all Force element handle classes derive.
Definition: Force.h:50
void disable(State &) const
Disable this force element, effectively removing it from the System for computational purposes (it is...
bool isDisabledByDefault() const
Test whether this force element is disabled by default in which case it must be explicitly enabled be...
Force()
Default constructor for Force handle base class does nothing.
Definition: Force.h:154
const GeneralForceSubsystem & getForceSubsystem() const
Get the GeneralForceSubsystem of which this Force is an element.
ForceIndex getForceIndex() const
Get the index of this force element within its parent force subsystem.
void calcForceContribution(const State &state, Vector_< SpatialVec > &bodyForces, Vector_< Vec3 > &particleForces, Vector &mobilityForces) const
Calculate the force that would be applied by this force element if the given state were realized to D...
void enable(State &) const
Enable this force element if it was previously disabled.
void setDisabledByDefault(bool shouldBeDisabled)
Normally force elements are enabled when defined and can be disabled later.
bool isDisabled(const State &) const
Test whether this force element is currently disabled in the supplied State.
Real calcPotentialEnergyContribution(const State &state) const
Calculate the potential energy contribution that is made by this force element at the given state.
Force(ForceImpl *r)
Use this in a derived Force handle class constructor to supply the concrete implementation object to ...
Definition: Force.h:208
This is a concrete subsystem which can apply arbitrary forces to a MultibodySystem.
Definition: GeneralForceSubsystem.h:47
A MobilizedBody is Simbody's fundamental body-and-joint object used to parameterize a system's motion...
Definition: MobilizedBody.h:169
This subsystem contains the bodies ("matter") in the multibody system, the mobilizers (joints) that d...
Definition: SimbodyMatterSubsystem.h:133
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:280
This is the vector class intended to appear in user code for large, variable size column vectors.
Definition: Vector_.h:50
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