Simbody  3.4 (development)
SimTK::Force::DiscreteForces Class Reference

Arbitrary discrete body forces and mobility (generalized) forces. Useful for applying external forces or forces that are updated at discrete times due to the occurrence of events. More...

#include <Force_DiscreteForces.h>

+ Inheritance diagram for SimTK::Force::DiscreteForces:

List of all members.

Public Member Functions

 DiscreteForces (GeneralForceSubsystem &forces, const SimbodyMatterSubsystem &matter)
 Create a DiscreteForces force element.
 DiscreteForces ()
 Default constructor creates an empty handle.
void clearAllForces (State &state) const
 Set to zero all forces stored by this force element in the given state, including both generalized forces and body spatial forces.
void clearAllMobilityForces (State &state) const
 Set to zero all generalized forces stored by this force element in the given state.
void clearAllBodyForces (State &state) const
 Set to zero all body spatial forces (force and torques) stored by this force element in the given state.
void setOneMobilityForce (State &state, const MobilizedBody &mobod, MobilizerUIndex whichU, Real force) const
 Change the value of a generalized force to be applied in the given state.
void setOneBodyForce (State &state, const MobilizedBody &mobod, const SpatialVec &spatialForceInG) const
 Change the value of the discrete spatial force (force and torque) to be applied to a body in the given state.
void addForceToBodyPoint (State &state, const MobilizedBody &mobod, const Vec3 &pointInB, const Vec3 &forceInG) const
 Convenience method to add in a force applied at a point (station) on a particular body into the forces currently set to be applied to that body in this state.
void setAllMobilityForces (State &state, const Vector &f) const
 Set all the generalized forces at once.
void setAllBodyForces (State &state, const Vector_< SpatialVec > &bodyForcesInG) const
 Set all the body spatial forces at once.
Real getOneMobilityForce (const State &state, const MobilizedBody &mobod, MobilizerUIndex whichU) const
 Return the value for a generalized force that is stored in the given state.
SpatialVec getOneBodyForce (const State &state, const MobilizedBody &mobod) const
 Return the value for the discrete spatial force (force and torque) on a particular body that is stored in the given state.
const VectorgetAllMobilityForces (const State &state) const
 Get a reference to the internal Vector of all the generalized forces currently set to be applied by this force element.
const Vector_< SpatialVec > & getAllBodyForces (const State &state) const
 Get a reference to the internal Vector of all the body spatial forces currently set to be applied by this force element.

Detailed Description

Arbitrary discrete body forces and mobility (generalized) forces. Useful for applying external forces or forces that are updated at discrete times due to the occurrence of events.

See also:
Force::MobilityDiscreteForce

Constructor & Destructor Documentation

Create a DiscreteForces force element.

Parameters:
forcesSubsystem to which this force element should be added.
matterSubsystem containing the mobilized bodies to which these forces will be applied.

Default constructor creates an empty handle.


Member Function Documentation

void SimTK::Force::DiscreteForces::clearAllForces ( State state) const [inline]

Set to zero all forces stored by this force element in the given state, including both generalized forces and body spatial forces.

Set to zero all generalized forces stored by this force element in the given state.

Set to zero all body spatial forces (force and torques) stored by this force element in the given state.

void SimTK::Force::DiscreteForces::setOneMobilityForce ( State state,
const MobilizedBody mobod,
MobilizerUIndex  whichU,
Real  force 
) const

Change the value of a generalized force to be applied in the given state.

Set this to zero if you don't want it to do anything. You can call this method any time after realizeTopology() since the force just needs to be saved in the state.

Parameters:
stateThe state in which the generalized force is to be saved.
mobodThe mobilizer to which the force should be applied.
whichUTo which of the mobilizer's mobilities (degrees of freedom) should this force be applied (first is 0)?
forceThe scalar value of the generalized force.
See also:
getOneMobilityForce()
void SimTK::Force::DiscreteForces::setOneBodyForce ( State state,
const MobilizedBody mobod,
const SpatialVec spatialForceInG 
) const

Change the value of the discrete spatial force (force and torque) to be applied to a body in the given state.

Set this to zero if you don't want any force applied to the body. You can call this method any time after realizeTopology() since the force just needs to be saved in the state.

Parameters:
stateThe state in which the force is to be saved.
mobodThe mobilized body to which the force should be applied.
spatialForceInGThe (torque,force) pair as a SpatialVec. These are expressed in the Ground frame and the force is applied to the body origin.
See also:
getOneBodyForce(), addForceToBodyPoint()
void SimTK::Force::DiscreteForces::addForceToBodyPoint ( State state,
const MobilizedBody mobod,
const Vec3 pointInB,
const Vec3 forceInG 
) const

Convenience method to add in a force applied at a point (station) on a particular body into the forces currently set to be applied to that body in this state.

The station location is given in the body frame and the force is given in the Ground frame. Note that the state must have been realized to Stage::Position because we need to know the body orientation in order to shift the applied force to the body origin.

Be sure to call setOneBodyForce() to initialize this force to zero before you start accumulating point forces using this method.

Parameters:
stateThe state in which the force is saved. Must already have been realized to at least Stage::Position.
mobodThe mobilized body to which the force will be applied.
pointInBThe body station at which the force will be applied, measured and expressed in the body frame.
forceInGThe force vector to be applied, expressed in Ground.
See also:
setOneBodyForce()
void SimTK::Force::DiscreteForces::setAllMobilityForces ( State state,
const Vector f 
) const

Set all the generalized forces at once.

These will be applied until they are changed.

Parameters:
stateThe state in which the generalized forces are saved.
fThe set of n generalized forces. This Vector must be either empty (in which case it is treated as though it were all zero) or the same length as the number of generalized speeds (state.getNU()).
See also:
clearAllMobilityForces()
void SimTK::Force::DiscreteForces::setAllBodyForces ( State state,
const Vector_< SpatialVec > &  bodyForcesInG 
) const

Set all the body spatial forces at once.

These will be applied until they are changed.

Parameters:
stateThe state in which the forces are saved.
bodyForcesInGThe set of nb spatial forces (torque,force) pairs, expressed in the Ground frame, with the forces applied at each body frame origin. This Vector must be either empty (in which case it is treated as though it were all zero) or the same length as the number of mobilized bodies in the system (and don't forget that Ground is mobilized body 0).
See also:
clearAllBodyForces()
Real SimTK::Force::DiscreteForces::getOneMobilityForce ( const State state,
const MobilizedBody mobod,
MobilizerUIndex  whichU 
) const

Return the value for a generalized force that is stored in the given state.

If no calls to setGeneralizedForce() have been made on this state then zero will be returned.

See also:
setOneMobilityForce()
SpatialVec SimTK::Force::DiscreteForces::getOneBodyForce ( const State state,
const MobilizedBody mobod 
) const

Return the value for the discrete spatial force (force and torque) on a particular body that is stored in the given state.

The result is a force applied at the body origin and expressed in the Ground frame.

See also:
setOneBodyForce()

Get a reference to the internal Vector of all the generalized forces currently set to be applied by this force element.

This will be length zero if no forces are being applied; otherwise, its length will be the number of generalized speeds u in the given state. The returned reference is a reference into the given state object.

Get a reference to the internal Vector of all the body spatial forces currently set to be applied by this force element.

This will be length zero if no body forces are being applied; otherwise, its length will be the number of mobilized bodies in the containing MultibodySystem. The returned reference is a reference into the given state object.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines