This abstract class represents a force applied to bodies or generalized coordinates during a simulation. More...
#include <Force.h>
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 | |
Force & | operator= (const Force &aForce) |
Assignment operator. | |
void | copyData (const Force &aForce) |
Copy data members from one Force to another. | |
virtual Object * | copy () 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 |
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().
OpenSim::Force::Force | ( | ) |
Default constructor.
OpenSim::Force::Force | ( | const Force & | aForce | ) |
Copy constructor.
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
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.
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.
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.
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.
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] |
Subclasses must implement this method to compute the forces that should be applied to bodies and generalized speeds.
This is invoked by ForceAdapter to perform the force computation.
Reimplemented in OpenSim::CoordinateActuator, OpenSim::CoordinateLimitForce, OpenSim::PointActuator, OpenSim::PointToPointActuator, OpenSim::RigidTendonMuscle, OpenSim::SpringGeneralizedForce, OpenSim::TorqueActuator, OpenSim::ActivationFiberLengthMuscle, OpenSim::ExternalForce, OpenSim::Ligament, OpenSim::LinearSpring, OpenSim::Muscle, OpenSim::PathActuator, OpenSim::PrescribedForce, and OpenSim::TorsionalSpring.
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] |
Construct and return a copy of this object.
The object is allocated using the new operator, so the caller is responsible for deleting the returned object.
Reimplemented from OpenSim::Object.
Implemented in OpenSim::ContDerivMuscle, OpenSim::CoordinateActuator, OpenSim::CoordinateLimitForce, OpenSim::Delp1990Muscle, OpenSim::PointActuator, OpenSim::PointToPointActuator, OpenSim::RigidTendonMuscle, OpenSim::Schutte1993Muscle, OpenSim::SpringGeneralizedForce, OpenSim::Thelen2003Muscle, OpenSim::TorqueActuator, OpenSim::ActivationFiberLengthMuscle, OpenSim::Actuator_, OpenSim::Actuator, OpenSim::BushingForce, OpenSim::ElasticFoundationForce, OpenSim::ElasticFoundationForce, OpenSim::ElasticFoundationForce, OpenSim::ExternalForce, OpenSim::HuntCrossleyForce, OpenSim::HuntCrossleyForce, OpenSim::HuntCrossleyForce, OpenSim::Ligament, OpenSim::LinearSpring, OpenSim::Muscle, OpenSim::PathActuator, OpenSim::PointToPointSpring, OpenSim::PrescribedForce, and OpenSim::TorsionalSpring.
void OpenSim::Force::copyData | ( | const Force & | aForce | ) |
Copy data members from one Force to another.
aForce | Force to be copied. |
Reimplemented in OpenSim::ContDerivMuscle, OpenSim::CoordinateActuator, OpenSim::Delp1990Muscle, OpenSim::PointActuator, OpenSim::PointToPointActuator, OpenSim::RigidTendonMuscle, OpenSim::Schutte1993Muscle, OpenSim::Thelen2003Muscle, OpenSim::TorqueActuator, OpenSim::ActivationFiberLengthMuscle, OpenSim::BushingForce, OpenSim::ElasticFoundationForce, OpenSim::HuntCrossleyForce, OpenSim::Ligament, OpenSim::Muscle, OpenSim::PathActuator, and OpenSim::PointToPointSpring.
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] |
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().
Reimplemented in OpenSim::CoordinateActuator, OpenSim::CoordinateLimitForce, OpenSim::PointActuator, OpenSim::PointToPointActuator, OpenSim::RigidTendonMuscle, OpenSim::SpringGeneralizedForce, OpenSim::TorqueActuator, OpenSim::ActivationFiberLengthMuscle, OpenSim::BushingForce, OpenSim::ElasticFoundationForce, OpenSim::ExternalForce, OpenSim::HuntCrossleyForce, OpenSim::Muscle, OpenSim::PathActuator, OpenSim::PointToPointSpring, and OpenSim::PrescribedForce.
virtual OpenSim::Array<double> OpenSim::Force::getRecordValues | ( | const SimTK::State & | state | ) | const [inline, virtual] |
Given SimTK::State object extract all the values necessary to report forces, application location frame, etc.
used in conjunction with getRecordLabels and should return same size Array
Reimplemented in OpenSim::CoordinateActuator, OpenSim::CoordinateLimitForce, OpenSim::PointActuator, OpenSim::PointToPointActuator, OpenSim::RigidTendonMuscle, OpenSim::SpringGeneralizedForce, OpenSim::TorqueActuator, OpenSim::ActivationFiberLengthMuscle, OpenSim::BushingForce, OpenSim::ElasticFoundationForce, OpenSim::ExternalForce, OpenSim::HuntCrossleyForce, OpenSim::Muscle, OpenSim::PathActuator, OpenSim::PointToPointSpring, and OpenSim::PrescribedForce.
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.
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
Assignment operator.
Reimplemented from OpenSim::ModelComponent.
Reimplemented in OpenSim::ContDerivMuscle, OpenSim::CoordinateActuator, OpenSim::CoordinateLimitForce, OpenSim::Delp1990Muscle, OpenSim::PointActuator, OpenSim::PointToPointActuator, OpenSim::RigidTendonMuscle, OpenSim::Schutte1993Muscle, OpenSim::SpringGeneralizedForce, OpenSim::Thelen2003Muscle, OpenSim::TorqueActuator, OpenSim::ActivationFiberLengthMuscle, OpenSim::Actuator_, OpenSim::Actuator, OpenSim::BushingForce, OpenSim::ExternalForce, OpenSim::Ligament, OpenSim::Muscle, OpenSim::PathActuator, OpenSim::PointToPointSpring, and OpenSim::PrescribedForce.
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.
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.
isDisabled | If true the force is disabled; if false the Force is enabled. |
void OpenSim::Force::setup | ( | Model & | model | ) | [protected, virtual] |
Subclasses should override these methods appropriately.
Reimplemented from OpenSim::ModelComponent.
Reimplemented in OpenSim::ContDerivMuscle, OpenSim::CoordinateActuator, OpenSim::CoordinateLimitForce, OpenSim::Delp1990Muscle, OpenSim::PointActuator, OpenSim::PointToPointActuator, OpenSim::RigidTendonMuscle, OpenSim::Schutte1993Muscle, OpenSim::SpringGeneralizedForce, OpenSim::Thelen2003Muscle, OpenSim::TorqueActuator, OpenSim::ActivationFiberLengthMuscle, OpenSim::Actuator_, OpenSim::Actuator, OpenSim::BushingForce, OpenSim::ExternalForce, OpenSim::Ligament, OpenSim::LinearSpring, OpenSim::Muscle, OpenSim::PathActuator, OpenSim::PointToPointSpring, and OpenSim::PrescribedForce.
friend class ForceAdapter [friend] |
SimTK::ForceIndex OpenSim::Force::_index [protected] |
ID for the force in Simbody.
PropertyBool OpenSim::Force::_isDisabledProp [protected] |
Flag indicating whether the force is disabled or not.
Disabled means that the force is not active in subsequent dynamics realizations.