OpenSim::Force Class Reference

This abstract class represents a force applied to bodies or generalized coordinates during a simulation. More...

#include <Force.h>

Inheritance diagram for OpenSim::Force:
OpenSim::ModelComponent OpenSim::Object OpenSim::Actuator_ OpenSim::BushingForce OpenSim::CoordinateLimitForce OpenSim::ElasticFoundationForce OpenSim::ExternalForce OpenSim::HuntCrossleyForce OpenSim::Ligament OpenSim::LinearSpring OpenSim::PointToPointSpring OpenSim::PrescribedForce OpenSim::SpringGeneralizedForce OpenSim::TorsionalSpring

List of all members.

Public Member Functions

 Force ()
 Default constructor.
 Force (const Force &aForce)
 Copy constructor.
virtual ~Force ()
 Destructor.
 Force (DOMElement *aNode)
 deserialization from XML, necessary so that derived classes can (de)serialize
Forceoperator= (const Force &aForce)
 Assignment operator.
void copyData (const Force &aForce)
 Copy data members from one Force to another.
virtual Objectcopy () const =0
 Construct and return a copy of this object.
virtual OpenSim::Array
< std::string > 
getRecordLabels () const
 Methods to query a Force for the value actually applied during simulation The names of the quantities (column labels) is returned by this first function getRecordLabels().
virtual OpenSim::Array< double > getRecordValues (const SimTK::State &state) const
 Given SimTK::State object extract all the values necessary to report forces, application location frame, etc.
virtual bool isDisabled (const SimTK::State &s) const
 return if the Force is disabled or not
virtual void setDisabled (SimTK::State &s, bool disabled)
 Set the Force as disabled (true) or not (false).
virtual int getNumStateVariables () const
 Get the number of state variables allocated by this force.
virtual bool hasGeometryPath () const
 return a flag indicating whether the Force is applied along a Path if you override this method to return true for a specific subclass, it must also implement the getGeometryPath() mathod
 OPENSIM_DECLARE_DERIVED (Force, Object)

Protected Member Functions

virtual void setup (Model &model)
 Subclasses should override these methods appropriately.
virtual void initState (SimTK::State &state) const
 This is called after a SimTK System and State have been created for the Model.
virtual void createSystem (SimTK::MultibodySystem &system) const
 Default is to create a ForceAdapter which is a SimTK::Force::Custom as the udnerlying computational component.
virtual void setDefaultsFromState (const SimTK::State &state)
 Set all default values for this object to match those in a specified State.
virtual void computeForce (const SimTK::State &state, SimTK::Vector_< SimTK::SpatialVec > &bodyForces, SimTK::Vector &generalizedForces) const
 Subclasses must implement this method to compute the forces that should be applied to bodies and generalized speeds.
virtual double computePotentialEnergy (const SimTK::State &state) const
 Subclasses may optionally override this method to compute a contribution to the potential energy of the system.
void applyForce (const SimTK::State &s, const OpenSim::Body &aBody, const SimTK::Vec3 &aForce, SimTK::Vector_< SimTK::SpatialVec > &bodyForces) const
 Apply a force to a particular body.
void applyForceToPoint (const SimTK::State &s, const OpenSim::Body &aBody, const SimTK::Vec3 &aPoint, const SimTK::Vec3 &aForce, SimTK::Vector_< SimTK::SpatialVec > &bodyForces) const
 Apply a force to a particular body.
void applyTorque (const SimTK::State &s, const OpenSim::Body &aBody, const SimTK::Vec3 &aTorque, SimTK::Vector_< SimTK::SpatialVec > &bodyForces) const
 Apply a torque to a particular body.
void applyGeneralizedForce (const SimTK::State &s, const Coordinate &aCoord, double aForce, SimTK::Vector &generalizedForces) const
 Apply a generalized force.

Protected Attributes

PropertyBool _isDisabledProp
 Flag indicating whether the force is disabled or not.
SimTK::ForceIndex _index
 ID for the force in Simbody.

Friends

class ForceAdapter

Detailed Description

This abstract class represents a force applied to bodies or generalized coordinates during a simulation.

Each subclass represents a different type of force. The actual force computation is done by a SimTK::Force, which is created by createSystem().

Author:
Peter Eastman
Ajay Seth

Constructor & Destructor Documentation

OpenSim::Force::Force (  ) 

Default constructor.

OpenSim::Force::Force ( const Force aForce  ) 

Copy constructor.

Parameters:
aForce Force to be copied.
OpenSim::Force::~Force (  )  [virtual]

Destructor.

OpenSim::Force::Force ( DOMElement *  aNode  )  [inline]

deserialization from XML, necessary so that derived classes can (de)serialize


Member Function Documentation

void OpenSim::Force::applyForce ( const SimTK::State &  s,
const OpenSim::Body aBody,
const SimTK::Vec3 &  aForce,
SimTK::Vector_< SimTK::SpatialVec > &  bodyForces 
) const [protected]

Apply a force to a particular body.

This method applies only a force, not a torque, which is equivalent to applying the force at the body's center of mass.

This method may only be called from inside computeForce(). Invoking it at any other time will produce an exception.

Parameters:
aBody the body to apply the force to
aForce the force to apply, specified in the inertial frame
bodyForces the current set of system bodyForces this force is added to
void OpenSim::Force::applyForceToPoint ( const SimTK::State &  s,
const OpenSim::Body aBody,
const SimTK::Vec3 &  aPoint,
const SimTK::Vec3 &  aForce,
SimTK::Vector_< SimTK::SpatialVec > &  bodyForces 
) const [protected]

Apply a force to a particular body.

Based on what point the force is applied at, this method automatically determines the torque produced by the force and applies that as well.

This method may only be called from inside computeForce(). Invoking it at any other time will produce an exception.

Parameters:
aBody the body to apply the force to
aPoint the point at which to apply the force, specifieid in the inertial frame
aForce the force to apply, specified in the body's frame
bodyForces the current set of system bodyForces this force is added to
void OpenSim::Force::applyGeneralizedForce ( const SimTK::State &  s,
const Coordinate aCoord,
double  aForce,
SimTK::Vector &  generalizedForces 
) const [protected]

Apply a generalized force.

This method may only be called from inside computeForce(). Invoking it at any other time will produce an exception.

Parameters:
aCoord the generalized coordinate to apply the force to
aForce the force to apply
generalizedForces the current set of system generalizedForces this force is added to
void OpenSim::Force::applyTorque ( const SimTK::State &  s,
const OpenSim::Body aBody,
const SimTK::Vec3 &  aTorque,
SimTK::Vector_< SimTK::SpatialVec > &  bodyForces 
) const [protected]

Apply a torque to a particular body.

This method may only be called from inside computeForce(). Invoking it at any other time will produce an exception.

Parameters:
aBody the body to apply the force to
aTorque the torque to apply, specified in the inertial frame
bodyForces the current set of system bodyForces this force is added to
virtual void OpenSim::Force::computeForce ( const SimTK::State &  state,
SimTK::Vector_< SimTK::SpatialVec > &  bodyForces,
SimTK::Vector &  generalizedForces 
) const [inline, protected, virtual]
double OpenSim::Force::computePotentialEnergy ( const SimTK::State &  state  )  const [protected, virtual]

Subclasses may optionally override this method to compute a contribution to the potential energy of the system.

The default implementation returns 0, which is appropriate for forces that do not contribute to potential energy.

Reimplemented in OpenSim::BushingForce.

virtual Object* OpenSim::Force::copy (  )  const [pure virtual]
void OpenSim::Force::copyData ( const Force aForce  ) 
void OpenSim::Force::createSystem ( SimTK::MultibodySystem &  system  )  const [protected, virtual]

Default is to create a ForceAdapter which is a SimTK::Force::Custom as the udnerlying computational component.

Create an underlying SimTK::Force to represent the OpenSim::Force in the computational system.

Subclasses override to employ other SimTK::Forces.

Create a SimTK::Force::Custom by default.

Reimplemented from OpenSim::ModelComponent.

Reimplemented in OpenSim::ContDerivMuscle, OpenSim::CoordinateActuator, OpenSim::Delp1990Muscle, OpenSim::RigidTendonMuscle, OpenSim::Schutte1993Muscle, OpenSim::SpringGeneralizedForce, OpenSim::Thelen2003Muscle, OpenSim::ActivationFiberLengthMuscle, OpenSim::Actuator_, OpenSim::Actuator, OpenSim::BushingForce, OpenSim::ElasticFoundationForce, OpenSim::HuntCrossleyForce, OpenSim::Ligament, OpenSim::Muscle, OpenSim::PathActuator, and OpenSim::PointToPointSpring.

virtual int OpenSim::Force::getNumStateVariables (  )  const [inline, virtual]

Get the number of state variables allocated by this force.

The default implementation returns 0. Subclasses that allocate state variables must override it.

Implements OpenSim::ModelComponent.

Reimplemented in OpenSim::ActivationFiberLengthMuscle.

virtual OpenSim::Array<std::string> OpenSim::Force::getRecordLabels (  )  const [inline, virtual]
virtual OpenSim::Array<double> OpenSim::Force::getRecordValues ( const SimTK::State &  state  )  const [inline, virtual]
virtual bool OpenSim::Force::hasGeometryPath (  )  const [inline, virtual]

return a flag indicating whether the Force is applied along a Path if you override this method to return true for a specific subclass, it must also implement the getGeometryPath() mathod

Reimplemented in OpenSim::Ligament, and OpenSim::PathActuator.

void OpenSim::Force::initState ( SimTK::State &  state  )  const [protected, virtual]

This is called after a SimTK System and State have been created for the Model.

It must be implementd to set initial values of state variables.

Parameters:
state the State to initialize

Reimplemented from OpenSim::ModelComponent.

Reimplemented in OpenSim::RigidTendonMuscle, OpenSim::ActivationFiberLengthMuscle, OpenSim::Actuator_, OpenSim::Actuator, OpenSim::Ligament, OpenSim::LinearSpring, and OpenSim::Muscle.

bool OpenSim::Force::isDisabled ( const SimTK::State &  s  )  const [virtual]

return if the Force is disabled or not

OpenSim::Force::OPENSIM_DECLARE_DERIVED ( Force  ,
Object   
)
Force & OpenSim::Force::operator= ( const Force aForce  ) 
void OpenSim::Force::setDefaultsFromState ( const SimTK::State &  state  )  [protected, virtual]

Set all default values for this object to match those in a specified State.

It must be implemented/overriden to set any default values defined by each subclass.

Parameters:
state the State from which to take values that should become the defaults for this object

Reimplemented from OpenSim::ModelComponent.

Reimplemented in OpenSim::RigidTendonMuscle, OpenSim::ActivationFiberLengthMuscle, OpenSim::Actuator_, OpenSim::Actuator, and OpenSim::Muscle.

void OpenSim::Force::setDisabled ( SimTK::State &  s,
bool  isDisabled 
) [virtual]

Set the Force as disabled (true) or not (false).

Set whether or not this Force is disabled.

Simbody multibody system instance is realized every time the isDisabled changes, BUT multiple sets to the same value have no cost.

Parameters:
isDisabled If true the force is disabled; if false the Force is enabled.
void OpenSim::Force::setup ( Model model  )  [protected, virtual]

Friends And Related Function Documentation

friend class ForceAdapter [friend]

Member Data Documentation

SimTK::ForceIndex OpenSim::Force::_index [protected]

ID for the force in Simbody.

Flag indicating whether the force is disabled or not.

Disabled means that the force is not active in subsequent dynamics realizations.


The documentation for this class was generated from the following files:

Generated on Sun Sep 25 00:19:58 2011 for OpenSim by  doxygen 1.6.1