Simbody
3.4 (development)
|
A discrete mobility (generalized) force f applied to a particular mobility that is specified at construction. Useful for applying external forces or forces that are updated at discrete times due to the occurrence of events. More...
#include <Force_MobilityDiscreteForce.h>
Public Member Functions | |
MobilityDiscreteForce (GeneralForceSubsystem &forces, const MobilizedBody &mobod, MobilizerUIndex whichU, Real defaultForce=0) | |
Create a MobilityDiscreteForce. | |
MobilityDiscreteForce (GeneralForceSubsystem &forces, const MobilizedBody &mobod, Real defaultForce=0) | |
Alternate constructor signature for when the mobilizer has only a single generalized speed, in which case we'll use MobilizerUIndex(0). | |
MobilityDiscreteForce () | |
Default constructor creates an empty handle. | |
MobilityDiscreteForce & | setDefaultMobilityForce (Real defaultForce) |
Provide a new value for the defaultForce, overriding the one provided in the constructor. | |
Real | getDefaultMobilityForce () const |
Return the value that this generalized force will have by default. | |
void | setMobilityForce (State &state, Real f) const |
Change the value of the generalized force to be applied in the given state. | |
Real | getMobilityForce (const State &state) const |
Return the value for this generalized force that is stored in the given state. |
A discrete mobility (generalized) force f applied to a particular mobility that is specified at construction. Useful for applying external forces or forces that are updated at discrete times due to the occurrence of events.
Note that a mobility is a generalized speed (u), not a generalized coordinate (q). The meaning of a generalized force depends on the definition of the generalized speed. If that speed is a translation then this is a force; if a rotation then this is a torque; if something else then f has a comparable definition (the defining condition is that f*u should always have physically meaningful units of power). This force does not contribute to the potential energy, so adding it to a system will cause potential+kinetic energy not to be conserved.
If you want to be able to apply discrete forces to any body or mobilizer specifying which one in advance, see Force::DiscreteForces.
SimTK::Force::MobilityDiscreteForce::MobilityDiscreteForce | ( | GeneralForceSubsystem & | forces, |
const MobilizedBody & | mobod, | ||
MobilizerUIndex | whichU, | ||
Real | defaultForce = 0 |
||
) |
Create a MobilityDiscreteForce.
forces | subsystem to which this force element should be added |
mobod | mobilizer to which the force should be applied |
whichU | to which of the mobilizer's mobilities (degrees of freedom) should this force be applied (first is 0)? |
defaultForce | initial value for the generalized force to be applied (default 0) |
Note that if you have an integer value for the generalized speed (u) index, you have to cast it to a MobilizerUIndex here. The generalized speeds are numbered starting with 0 for each mobilizer. Here is an example:
GeneralForceSubsystem forces; MobilizedBody::Pin pinJoint(...); MobilityDiscreteForce myForce(forces, pinJoint, MobilizerUIndex(0));
SimTK::Force::MobilityDiscreteForce::MobilityDiscreteForce | ( | GeneralForceSubsystem & | forces, |
const MobilizedBody & | mobod, | ||
Real | defaultForce = 0 |
||
) | [inline] |
Alternate constructor signature for when the mobilizer has only a single generalized speed, in which case we'll use MobilizerUIndex(0).
See the other signature for documentation.
Default constructor creates an empty handle.
MobilityDiscreteForce& SimTK::Force::MobilityDiscreteForce::setDefaultMobilityForce | ( | Real | defaultForce | ) |
Provide a new value for the defaultForce, overriding the one provided in the constructor.
This is a topological change because it affects the value that the containing System's default state will have when realizeTopology() is called. This is for use during construction, not for during a simulation where you should be using setGeneralizedForce().
defaultForce | the value this generalized force should have by default |
Real SimTK::Force::MobilityDiscreteForce::getDefaultMobilityForce | ( | ) | const |
Return the value that this generalized force will have by default.
This is normally set in the constructor, or left to its default value of 0. It can also be set in setDefaultMobilityForce(). Note that this is not the same as the value that may be set in any particular State.
void SimTK::Force::MobilityDiscreteForce::setMobilityForce | ( | State & | state, |
Real | f | ||
) | const |
Change the value of the generalized force to be applied in the given state.
Set this to zero if you don't want it to do anything.
Real SimTK::Force::MobilityDiscreteForce::getMobilityForce | ( | const State & | state | ) | const |
Return the value for this generalized force that is stored in the given state.
If no calls to setMobilityForce() have been made on this state then it will have the defaultForce value that was supplied on construction or via setDefaultMobilityForce().