#include <LinearSpring.h>
Public Member Functions | |
LinearSpring (const Body &aBody, double start, double stop) | |
Construct a Linear Spring. | |
virtual | ~LinearSpring () |
Destructor. | |
void | setTargetPosition (VectorFunction *aTargetVelocity) |
Set the vector function containing the (t,x,y,z) of the position that the point should be corrected towards, expressed in the global ref frame. | |
VectorFunction * | getTargetPosition () const |
Get the vector function containing the (t,x,y,z) of the poisiton that the point should be corrected towards, expressed in the global ref frame. | |
void | setPointFunction (VectorFunction *aPointFunction) |
Set the vector function containing the (t,x,y,z) of the point at which the force should be applied in the local coordinate frame. | |
void | setTargetVelocity (VectorFunction *aTargetVelocity) |
Set the vector function containing the (t,x,y,z) of the velocity that the point should be corrected towards, expressed in the global ref frame. | |
VectorFunction * | getTargetVelocity () const |
Get the vector function containing the (t,x,y,z) of the velocity that the point should be corrected towards, expressed in the global ref frame. | |
void | setScaleFunction (Function *_scaleFunction) |
Set the function containing the scale factor as a function of time. | |
Function * | getScaleFunction () const |
Get the function containing the scale factor as a function of time. | |
void | setScaleFactor (double aScaleFactor) |
Set the scale factor that pre-multiplies the applied torque. | |
double | getScaleFactor () |
Get the scale factor that pre-multiplies the applied torque. | |
void | setKValue (const SimTK::Vec3 &aK) |
Set the spring constant, k. | |
void | getKValue (SimTK::Vec3 &aK) const |
Get the spring constant, k. | |
void | setBValue (const SimTK::Vec3 &aB) |
Set the damping constant, b. | |
void | getBValue (SimTK::Vec3 &aB) const |
Get the damping constant, b. | |
void | setThreshold (double aThreshold) |
Set the magnitude theshold below which no force is applied. | |
double | getThreshold () const |
Get the magnitude theshold below which no force is applied. | |
void | computePointAndTargetFunctions (SimTK::State &s, const Storage &aQStore, const Storage &aUStore, VectorFunction &aPGlobal) |
Compute the local point on a body and the point's target position and velocity in space that it should track. | |
void | computePointFunction (SimTK::State &s, const Storage &aQStore, const Storage &aUStore, VectorFunction &aPGlobal) |
Compute the position and velocity functions that set the position and velocity of the point at which the linear spring applies its force. | |
void | computeTargetFunctions (SimTK::State &s, const Storage &aQStoreForTarget, const Storage &aUStoreForTarget) |
virtual void | computeForce (const SimTK::State &s) const |
Callback called right after actuation has been applied by the model. | |
Protected Attributes | |
VectorFunction * | _pointFunction |
VectorFunction containing points of force application (t,x,y,z). | |
VectorFunction * | _forceFunction |
VectorFunction containing force to be applied (t,x,y,z). | |
VectorFunction * | _targetPosition |
Vector function containing the target position of the point expressed in the global reference frame. | |
VectorFunction * | _targetVelocity |
Vector function containing the target velocity of the point expressed in the global reference frame. | |
Function * | _scaleFunction |
Function containing values for the time-dependent scaling factor. | |
double | _scaleFactor |
Scale factor that pre-multiplies the applied torque. | |
SimTK::Vec3 | _k |
Stiffness. | |
SimTK::Vec3 | _b |
Damping. | |
double | _threshold |
If the magnitude of the spring force is below this threshold, no spring force is applied. | |
const Body & | _body |
bool | _on |
On, off flag. | |
double | _startTime |
Start time for the force. | |
double | _endTime |
End time for the force. |
LinearSpring::LinearSpring | ( | const Body & | aBody, | |
double | startTime, | |||
double | endTime | |||
) |
Construct a Linear Spring.
aBody | Body upon which spring forces are to be applied. |
LinearSpring::~LinearSpring | ( | ) | [virtual] |
Destructor.
void LinearSpring::computeForce | ( | const SimTK::State & | s | ) | const [virtual] |
Callback called right after actuation has been applied by the model.
*
aT | Real time. | |
aX | Controls. | |
aY | States. |
Implements OpenSim::CustomForce.
void LinearSpring::computePointAndTargetFunctions | ( | SimTK::State & | s, | |
const Storage & | aQStore, | |||
const Storage & | aUStore, | |||
VectorFunction & | aPGlobal | |||
) |
Compute the local point on a body and the point's target position and velocity in space that it should track.
A spring force is applied based on the difference between the point's position and velocity and the target position and velocity. The point is specified in the local frame; the target position and velocity are specified in the global frame.
aQStore | Storage containing the time history of generalized coordinates for the model. Note that all generalized coordinates must be specified and in radians and Euler parameters. | |
aUStore | Stoarge containing the time history of generalized speeds for the model. Note that all generalized speeds must be specified and in radians. | |
aPStore | Storage containing the time history of the position of the point in the global frame. |
void LinearSpring::computePointFunction | ( | SimTK::State & | s, | |
const Storage & | aQStore, | |||
const Storage & | aUStore, | |||
VectorFunction & | aPGlobal | |||
) |
Compute the position and velocity functions that set the position and velocity of the point at which the linear spring applies its force.
This method takes the time histories of a point's position and velocity in the inertial frame and converts them to the local (body) frame.
aQStore | Storage containing the time history of generalized coordinates for the model. Note that all generalized coordinates must be specified and in radians and Euler parameters. | |
aUStore | Storage containing the time history of generalized speeds for the model. Note that all generalized speeds must be specified and in radians. | |
aPStore | Storage containing the time history of the position at which the force is to be applied in the global frame. |
void LinearSpring::computeTargetFunctions | ( | SimTK::State & | s, | |
const Storage & | aQStoreForTarget, | |||
const Storage & | aUStoreForTarget | |||
) |
void LinearSpring::getBValue | ( | SimTK::Vec3 & | aB | ) | const |
Get the damping constant, b.
void LinearSpring::getKValue | ( | SimTK::Vec3 & | aK | ) | const |
Get the spring constant, k.
double LinearSpring::getScaleFactor | ( | ) |
Get the scale factor that pre-multiplies the applied torque.
Function * LinearSpring::getScaleFunction | ( | ) | const |
Get the function containing the scale factor as a function of time.
VectorFunction * LinearSpring::getTargetPosition | ( | ) | const |
Get the vector function containing the (t,x,y,z) of the poisiton that the point should be corrected towards, expressed in the global ref frame.
VectorFunction * LinearSpring::getTargetVelocity | ( | ) | const |
Get the vector function containing the (t,x,y,z) of the velocity that the point should be corrected towards, expressed in the global ref frame.
double LinearSpring::getThreshold | ( | ) | const |
Get the magnitude theshold below which no force is applied.
aThreshold | Magnitude threshold. A negative value or 0 will result in the force always being applied. |
void LinearSpring::setBValue | ( | const SimTK::Vec3 & | aB | ) |
Set the damping constant, b.
aK | Vector of three values of b. |
void LinearSpring::setKValue | ( | const SimTK::Vec3 & | aK | ) |
Set the spring constant, k.
aK | Vector of three values of k. |
void LinearSpring::setPointFunction | ( | VectorFunction * | aPointFunction | ) |
Set the vector function containing the (t,x,y,z) of the point at which the force should be applied in the local coordinate frame.
aPointFunction | containing force application point function. |
void LinearSpring::setScaleFactor | ( | double | aScaleFactor | ) |
Set the scale factor that pre-multiplies the applied torque.
aScaleFactor |
void LinearSpring::setScaleFunction | ( | Function * | aScaleFunction | ) |
Set the function containing the scale factor as a function of time.
aScaleFunction. |
void LinearSpring::setTargetPosition | ( | VectorFunction * | aTargetPosition | ) |
Set the vector function containing the (t,x,y,z) of the position that the point should be corrected towards, expressed in the global ref frame.
aTargetPosition | Vector function containing the target position expressed in the global reference frame. |
void LinearSpring::setTargetVelocity | ( | VectorFunction * | aTargetVelocity | ) |
Set the vector function containing the (t,x,y,z) of the velocity that the point should be corrected towards, expressed in the global ref frame.
aTargetVelocity | Vector function containing the target velocity expressed in the global reference frame. |
void LinearSpring::setThreshold | ( | double | aThreshold | ) |
Set the magnitude theshold below which no force is applied.
aThreshold | Magnitude threshold. A negative value or 0 will result in the force always being applied. |
SimTK::Vec3 OpenSim::LinearSpring::_b [protected] |
Damping.
const Body& OpenSim::LinearSpring::_body [protected] |
double OpenSim::LinearSpring::_endTime [protected] |
End time for the force.
VectorFunction* OpenSim::LinearSpring::_forceFunction [protected] |
VectorFunction containing force to be applied (t,x,y,z).
SimTK::Vec3 OpenSim::LinearSpring::_k [protected] |
Stiffness.
bool OpenSim::LinearSpring::_on [protected] |
On, off flag.
VectorFunction* OpenSim::LinearSpring::_pointFunction [protected] |
VectorFunction containing points of force application (t,x,y,z).
double OpenSim::LinearSpring::_scaleFactor [protected] |
Scale factor that pre-multiplies the applied torque.
Function* OpenSim::LinearSpring::_scaleFunction [protected] |
Function containing values for the time-dependent scaling factor.
double OpenSim::LinearSpring::_startTime [protected] |
Start time for the force.
VectorFunction* OpenSim::LinearSpring::_targetPosition [protected] |
Vector function containing the target position of the point expressed in the global reference frame.
VectorFunction* OpenSim::LinearSpring::_targetVelocity [protected] |
Vector function containing the target velocity of the point expressed in the global reference frame.
double OpenSim::LinearSpring::_threshold [protected] |
If the magnitude of the spring force is below this threshold, no spring force is applied.