Skip to content

Commit

Permalink
Switch 'Applies' to 'Produces'-style naming in various force-related …
Browse files Browse the repository at this point in the history
…components
  • Loading branch information
adamkewley committed Sep 2, 2024
1 parent ed7aee2 commit fffbcf2
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion OpenSim/Actuators/CoordinateActuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ CreateForceSetOfCoordinateActuatorsForModel(const SimTK::State& s, Model& aModel
//==============================================================================
//_____________________________________________________________________________
/**
* Apply the actuator force to BodyA and BodyB.
* Produces the actuator force for BodyA and BodyB.
*/
void CoordinateActuator::implProduceForces(const SimTK::State& s,
ForceConsumer& forceConsumer) const
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Actuators/PointToPointActuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void PointToPointActuator::implProduceForces(

const SimTK::Vec3 force = forceMagnitude * getDirectionBAInGround(s);

// Apply equal and opposite forces to the bodies.
// Produce equal and opposite forces on the body frames.
forceConsumer.consumePointForce(s, *_bodyA, pointA_inBodyA, force);
forceConsumer.consumePointForce(s, *_bodyB, pointB_inBodyB, -force);
}
Expand Down
4 changes: 2 additions & 2 deletions OpenSim/Actuators/SpringGeneralizedForce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ getStiffness() const
//==============================================================================
//_____________________________________________________________________________
/**
* Compute all quantities necessary for applying the spring force to the
* model.
* Compute all quantities necessary for producing the spring force.
*
* Force applied = -stiffness * (_coordinateValue - restLength)
* - viscosity * _coordinateSpeed
*/
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Actuators/TorqueActuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ double TorqueActuator::computeActuation(const State& s) const
//==============================================================================
//_____________________________________________________________________________
/**
* Apply the actuator force to BodyA and BodyB.
* Produce the actuator forces for BodyA and BodyB.
*/
void TorqueActuator::implProduceForces(
const SimTK::State& s,
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Examples/CustomActuatorExample/PistonActuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void PistonActuator::implProduceForces(
setActuation(s, forceMagnitude);
SimTK::Vec3 force = forceMagnitude * calcDirectionBAInGround(s);

// Apply equal and opposite forces to the bodies.
// Produce equal and opposite forces.
forceConsumer.consumePointForce(s, frameA, pointA, force);
forceConsumer.consumePointForce(s, frameB, pointB, -force);
}
Expand Down
8 changes: 4 additions & 4 deletions OpenSim/Examples/Plugins/BodyDragExample/BodyDragForce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ void BodyDragForce::implProduceForces(
dragForceGround,
aBody);

// Apply drag force to the body
// ------------------------------
// applyForceToPoint requires the force application point to be in the inertial (ground) frame
// Produce drag force as a point force on the body
// -----------------------------------------------
// `consumePointForce` requires the force application point to be in the inertial (ground) frame
// and the force vector itself to be in the body frame
forceConsumer.consumePointForce(s, aBody, bodyCoMPosGround, dragForceBody);

Expand Down Expand Up @@ -202,7 +202,7 @@ OpenSim::Array<double> BodyDragForce::getRecordValues(const SimTK::State& s) con
SimTK::Vec3 bodyCoMPosBody, bodyCoMPosGround, bodyCoMVelGround, bodyCoMVelGroundRaisedPower, dragForceGround, dragForceBody, oppVelSign;
BodySet &bs = _model->updBodySet(); // get body set
const Ground &ground = _model->getGround(); // get ground body
Body &aBody = bs.get(get_body_name()); // get the body to apply the force to
Body &aBody = bs.get(get_body_name()); // get the body in which the force is applied

// get CoM position of body in the BODY coordinate system
bodyCoMPosBody = aBody.getMassCenter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void CoupledBushingForce::implProduceForces(
Vec6 f = fk + fv;

// convert the internal forces to into spatial forces and emit them
// into the consumer
// into the `ForceConsumer`
producePhysicalForcesFromInternal(s, f, forceConsumer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ extendAddToSystem(SimTK::MultibodySystem& system) const
//=============================================================================
// Computing
//=============================================================================
// Compute and apply the force

// compute and produce forces
void ExpressionBasedPointToPointForce::implProduceForces(
const SimTK::State& s,
ForceConsumer& forceConsumer) const
Expand Down
8 changes: 4 additions & 4 deletions OpenSim/Simulation/Model/ForceConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace OpenSim
* The `ForceConsumer` API does not dictate how concrete implementations should
* handle the forces. This is to support several use-cases (examples):
*
* - Implementations that actually apply the forces (see: `ForceProducer::computeForce`),
* - Implementations that actually apply the forces (see: `ForceProducer::computeForce`, `ForceApplier`),
* - Implementations that print force debugging information
* - Implementations that want to render force vectors in 3D (e.g. UIs)
*/
Expand Down Expand Up @@ -105,7 +105,7 @@ class ForceConsumer {
*
* @param state the state that was used to evaluate the torque
* @param body the body to which the torque applies
* @param torque the torque, specified in the inertial frame, to apply
* @param torque the torque vector, specified in the inertial frame
*/
void consumeTorque(
const SimTK::State& state,
Expand All @@ -124,7 +124,7 @@ class ForceConsumer {
* @param state the state that was used to evaluate the force
* @param frame the frame in which `point` is defined
* @param point a point in `frame` where `force` applies
* @param force the force to apply, specified in the inertial (ground) frame
* @param force the force vector, specified in the inertial (ground) frame
*/
void consumePointForce(
const SimTK::State& state,
Expand Down Expand Up @@ -171,7 +171,7 @@ class ForceConsumer {
* @param state the state that was used to evaluate the force
* @param frame the frame in which `point` is defined
* @param point a point in `frame` where `force` applies
* @param force the force to apply, specified in the inertial (ground) frame
* @param force the force vector, specified in the inertial (ground) frame
*/
virtual void implConsumePointForce(
const SimTK::State& state,
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Simulation/Model/PrescribedForce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void PrescribedForce::implProduceForces(

Vec3 point(0); // Default is body origin.
if (hasPointFunctions) {
// Apply force to a specified point on the body.
// Calculate point force at a specified point on the body.
point = Vec3(pointFunctions[0].calcValue(timeAsVector),
pointFunctions[1].calcValue(timeAsVector),
pointFunctions[2].calcValue(timeAsVector));
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Simulation/Model/TwoFrameLinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ void TwoFrameLinker<C, F>::producePhysicalForcesFromInternal(
SimTK::SpatialVec F_GB2(F_GM[0] + p_B2M_G % F_GM[1], F_GM[1]);
SimTK::SpatialVec F_GB1(F_GF[0] + p_B1F_G % F_GF[1], F_GF[1]);

// Apply (add-in) the body forces to the system set of body forces
// Produce the body forces as body spatial vectors.
forceConsumer.consumeBodySpatialVec(s, frame2, F_GB2);
forceConsumer.consumeBodySpatialVec(s, frame1, F_GB1);
}
Expand Down

0 comments on commit fffbcf2

Please sign in to comment.