This is an abstract subclass of Force which allows you to define new Force types by overriding methods, rather than having to create a new SimTK::Force subclass. More...
#include <CustomForce.h>
Public Member Functions | |
CustomForce () | |
CustomForce (const CustomForce &aForce) | |
Copy constructor. | |
void | createSystem (SimTK::MultibodySystem &system) const |
Create a SimTK::Force which implements this CustomForce. | |
Protected Member Functions | |
virtual void | computeForce (const SimTK::State &state) const =0 |
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 OpenSim::Body &aBody, const SimTK::Vec3 &aForce) const |
Apply a force to a particular body. | |
void | applyForceToPoint (const OpenSim::Body &aBody, const SimTK::Vec3 &aPoint, const SimTK::Vec3 &aForce) const |
Apply a force to a particular body. | |
void | applyTorque (const OpenSim::Body &aBody, const SimTK::Vec3 &aTorque) const |
Apply a torque to a particular body. | |
void | applyGeneralizedForce (const Coordinate &aCoord, double aForce) const |
Apply a force to a generalized coordinate. | |
void | computeForce (const SimbodyEngine &engine, const SimTK::State &state, SimTK::Vector_< SimTK::SpatialVec > &bodyForces, SimTK::Vector &mobilityForces) const |
This is invoked by ForceAdapter to perform the force computation. | |
Friends | |
class | ForceAdapter |
This is an abstract subclass of Force which allows you to define new Force types by overriding methods, rather than having to create a new SimTK::Force subclass.
CustomForce::CustomForce | ( | ) |
CustomForce::CustomForce | ( | const CustomForce & | aForce | ) |
Copy constructor.
aActuator | Actuator to copy. |
void OpenSim::CustomForce::applyForce | ( | const OpenSim::Body & | aBody, | |
const SimTK::Vec3 & | aForce | |||
) | 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 |
void OpenSim::CustomForce::applyForceToPoint | ( | const OpenSim::Body & | aBody, | |
const SimTK::Vec3 & | aPoint, | |||
const SimTK::Vec3 & | aForce | |||
) | 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 |
void CustomForce::applyGeneralizedForce | ( | const Coordinate & | aCoord, | |
double | aForce | |||
) | const [protected] |
Apply a force to a generalized coordinate.
This method may only be called from inside computeForce(). Invoking it at any other time will produce an exception.
aU | the generalized speed to apply the force to | |
aForce | the force to apply |
void OpenSim::CustomForce::applyTorque | ( | const OpenSim::Body & | aBody, | |
const SimTK::Vec3 & | aTorque | |||
) | 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 |
void CustomForce::computeForce | ( | const SimbodyEngine & | engine, | |
const SimTK::State & | state, | |||
SimTK::Vector_< SimTK::SpatialVec > & | bodyForces, | |||
SimTK::Vector & | mobilityForces | |||
) | const [protected] |
This is invoked by ForceAdapter to perform the force computation.
virtual void OpenSim::CustomForce::computeForce | ( | const SimTK::State & | state | ) | const [protected, pure virtual] |
Subclasses must implement this method to compute the forces that should be applied to bodies and generalized speeds.
Implemented in OpenSim::SpringGeneralizedForce, OpenSim::Ligament, OpenSim::LinearSpring, OpenSim::PrescribedForce, and OpenSim::TorsionalSpring.
double CustomForce::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.
void CustomForce::createSystem | ( | SimTK::MultibodySystem & | system | ) | const [virtual] |
Create a SimTK::Force which implements this CustomForce.
Reimplemented from OpenSim::ModelComponent.
friend class ForceAdapter [friend] |