1 #ifndef SimTK_SIMBODY_CONDITIONAL_CONSTRAINT_H_ 
    2 #define SimTK_SIMBODY_CONDITIONAL_CONSTRAINT_H_ 
   50     assert(0 <= minCOR && minCOR <= 1);
 
   51     assert(0 <= captureSpeed && captureSpeed <= minCORSpeed);
 
   52     assert(impactSpeed >= 0);
 
   54     if (impactSpeed <= captureSpeed) 
return 0;
 
   55     if (impactSpeed >= minCORSpeed)  
return minCOR;
 
   57     const Real slope = (1-minCOR) / minCORSpeed;
 
   58     return 1 - slope*impactSpeed;
 
   67                              Real transitionSpeed, 
Real slipSpeed)
 
   69     assert(mu_s>=0 && mu_d>=0 && mu_v>=0);
 
   71     assert(transitionSpeed>=0 && slipSpeed>=0);
 
   72     const Real viscous = mu_v*slipSpeed; 
 
   73     return viscous + (slipSpeed <= transitionSpeed ? mu_s : mu_d);
 
   78 class UnilateralContact; 
 
   79 class UnilateralSpeedConstraint;
 
   80 class BoundedSpeedConstraint;
 
   82 class ConstraintLimitedFriction;
 
   83 class StateLimitedFriction;
 
  156                                   Real defaultCaptureSpeed,
 
  157                                   Real defaultMinCORSpeed,
 
  158                                   Real impactSpeed) 
const = 0;
 
  176     {   
return m_sign*getPerr(state) <= ptol; }
 
  197                                   Real defaultTransitionSpeed,
 
  198                                   Real slipSpeed)
 const 
  211     {   ix_x.invalidate(); ix_y.invalidate(); }
 
  226     UnilateralContactIndex  m_myIx;
 
  307                                   Real defaultTransitionSpeed,
 
  308                                   Real slipSpeed) 
const = 0;
 
  321     StateLimitedFrictionIndex 
getMyIndex()
 const {
return m_myIx;}
 
  323     StateLimitedFrictionIndex   m_myIx;
 
  345              Real defaultUpperLimit, 
Real minCOR);
 
  348     {   
if (m_upper.isDisabled(state)) 
return false;
 
  349         else {m_upper.disable(state); 
return true;} }
 
  351     {   
if (!m_upper.isDisabled(state)) 
return false;
 
  352         else {m_upper.enable(state); 
return true;} }
 
  354     {   
return !m_upper.isDisabled(state); }
 
  367                           Real defaultCaptureSpeed,
 
  368                           Real defaultMinCORSpeed,
 
  369                           Real impactSpeed)
 const override  
  372                (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
 
  380     Real                            m_defaultUpperLimit;
 
  403                   Real defaultLowerLimit, 
Real minCOR);
 
  406     {   
if (m_lower.isDisabled(state)) 
return false;
 
  407         else {m_lower.disable(state); 
return true;} }
 
  409     {   
if (!m_lower.isDisabled(state)) 
return false;
 
  410         else {m_lower.enable(state); 
return true;} }
 
  412     {   
return !m_lower.isDisabled(state); }
 
  425                           Real defaultCaptureSpeed,
 
  426                           Real defaultMinCORSpeed,
 
  427                           Real impactSpeed)
 const override  
  430                (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
 
  437     Real                            m_defaultLowerLimit;
 
  463          Real defaultLengthLimit, 
Real minCOR);
 
  466     {   
if (m_rod.isDisabled(state)) 
return false;
 
  467         else {m_rod.disable(state); 
return true;} }
 
  469     {   
if (!m_rod.isDisabled(state)) 
return false;
 
  470         else {m_rod.enable(state); 
return true;} }
 
  472     {   
return !m_rod.isDisabled(state); }
 
  484                           Real defaultCaptureSpeed,
 
  485                           Real defaultMinCORSpeed,
 
  486                           Real impactSpeed)
 const override  
  489                (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
 
  514         if (m_ptInPlane.isDisabled(state)) 
return false;
 
  515         m_ptInPlane.disable(state);
 
  520         if (!m_ptInPlane.isDisabled(state)) 
return false;
 
  521         m_ptInPlane.enable(state);
 
  526         return !m_ptInPlane.isDisabled(state);
 
  539     {   
return m_ptInPlane.getVelocityError(state); }
 
  541     {   
return m_ptInPlane.getAccelerationError(state); }
 
  545                           Real defaultCaptureSpeed,
 
  546                           Real defaultMinCORSpeed,
 
  547                           Real impactSpeed)
 const override  
  550                (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
 
  586         if (m_ptInPlane.isDisabled(state)) 
return false;
 
  587         m_ptInPlane.disable(state);
 
  592         if (!m_ptInPlane.isDisabled(state)) 
return false;
 
  593         m_ptInPlane.enable(state);
 
  598         return !m_ptInPlane.isDisabled(state);
 
  611     {   
return m_ptInPlane.getVelocityErrors(state)[2]; }
 
  613     {   
return m_ptInPlane.getAccelerationErrors(state)[2]; }
 
  617                           Real defaultCaptureSpeed,
 
  618                           Real defaultMinCORSpeed,
 
  619                           Real impactSpeed)
 const override  
  622                (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
 
  630         const Vec3 v = m_ptInPlane.getVelocityErrors(state);
 
  631         return Vec2(v[0], v[1]);
 
  635                           Real defaultTransitionSpeed,
 
  636                           Real slipSpeed)
 const override 
  639                (m_mu_s, m_mu_d, m_mu_v, defaultTransitionSpeed, slipSpeed);
 
  657     Real                        m_mu_s, m_mu_d, m_mu_v;
 
  678         if (m_sphereOnPlane.isDisabled(state)) 
return false;
 
  679         m_sphereOnPlane.disable(state);
 
  684         if (!m_sphereOnPlane.isDisabled(state)) 
return false;
 
  685         m_sphereOnPlane.enable(state);
 
  690         return !m_sphereOnPlane.isDisabled(state);
 
  703     {   
return m_sphereOnPlane.getVelocityErrors(state)[2]; }
 
  705     {   
return m_sphereOnPlane.getAccelerationErrors(state)[2]; }
 
  709                           Real defaultCaptureSpeed,
 
  710                           Real defaultMinCORSpeed,
 
  711                           Real impactSpeed)
 const override  
  714                (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
 
  722         const Vec3 v = m_sphereOnPlane.getVelocityErrors(state);
 
  723         return Vec2(v[0], v[1]);
 
  727                           Real defaultTransitionSpeed,
 
  728                           Real slipSpeed)
 const override 
  731                (m_mu_s, m_mu_d, m_mu_v, defaultTransitionSpeed, slipSpeed);
 
  742     Real                        m_mu_s, m_mu_d, m_mu_v;
 
  760         const Vec3&         defaultCenterOnF, 
 
  761         Real                defaultRadiusOnF, 
 
  763         const Vec3&         defaultCenterOnB,
 
  764         Real                defaultRadiusOnB,
 
  768         if (m_sphereOnSphere.isDisabled(state)) 
return false;
 
  769         m_sphereOnSphere.disable(state);
 
  774         if (!m_sphereOnSphere.isDisabled(state)) 
return false;
 
  775         m_sphereOnSphere.enable(state);
 
  780         return !m_sphereOnSphere.isDisabled(state);
 
  793     {   
return m_sphereOnSphere.getVelocityErrors(state)[2]; }
 
  795     {   
return m_sphereOnSphere.getAccelerationErrors(state)[2]; }
 
  799                           Real defaultCaptureSpeed,
 
  800                           Real defaultMinCORSpeed,
 
  801                           Real impactSpeed)
 const override  
  804                (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
 
  812         const Vec3 v = m_sphereOnSphere.getVelocityErrors(state);
 
  813         return Vec2(v[0], v[1]);
 
  817                           Real defaultTransitionSpeed,
 
  818                           Real slipSpeed)
 const override 
  821                (m_mu_s, m_mu_d, m_mu_v, defaultTransitionSpeed, slipSpeed);
 
  832     Real                        m_mu_s, m_mu_d, m_mu_v;
 
  857         Real                defaultHalfLengthF, 
 
  860         Real                defaultHalfLengthB,
 
  864         if (m_lineOnLine.isDisabled(state)) 
return false;
 
  865         m_lineOnLine.disable(state);
 
  870         if (!m_lineOnLine.isDisabled(state)) 
return false;
 
  871         m_lineOnLine.enable(state);
 
  876         return !m_lineOnLine.isDisabled(state);
 
  889     {   
return m_lineOnLine.getVelocityErrors(state)[2]; }
 
  891     {   
return m_lineOnLine.getAccelerationErrors(state)[2]; }
 
  895                           Real defaultCaptureSpeed,
 
  896                           Real defaultMinCORSpeed,
 
  897                           Real impactSpeed)
 const override  
  900                (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
 
  908         const Vec3 v = m_lineOnLine.getVelocityErrors(state);
 
  909         return Vec2(v[0], v[1]);
 
  913                           Real defaultTransitionSpeed,
 
  914                           Real slipSpeed)
 const override 
  917                (m_mu_s, m_mu_d, m_mu_v, defaultTransitionSpeed, slipSpeed);
 
  928     Real                        m_mu_s, m_mu_d, m_mu_v;
 
This defines the base Constraint class and related classes, which are used to specify limitations on ...
 
Include the header files that define each of the built-in constraint subclasses of class Constraint.
 
This defines the MobilizedBody class, which associates a new body (the "child", "outboard",...
 
Every Simbody header and source file should include this header before any other Simbody header.
 
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:68
 
TODO: not implemented yet.
Definition: ConditionalConstraint.h:272
 
virtual Vec2 calcEffectiveBounds(const State &state) const =0
Return the currently effective lower and upper bounds on the associated multiplier as a Vec2(lower,...
 
BoundedSpeedConstraint()
Definition: ConditionalConstraint.h:274
 
virtual ~BoundedSpeedConstraint()
Definition: ConditionalConstraint.h:275
 
TODO: Simbody model element representing a conditionally-enforced constraint.
Definition: ConditionalConstraint.h:38
 
static Real calcEffectiveCOF(Real mu_s, Real mu_d, Real mu_v, Real transitionSpeed, Real slipSpeed)
Given the coefficients of friction and slip-to-rolling transition speed, calculate the effective COF ...
Definition: ConditionalConstraint.h:66
 
static Real calcEffectiveCOR(Real minCOR, Real captureSpeed, Real minCORSpeed, Real impactSpeed)
Given the specified minimum coefficient of restitution (COR), capture speed, and the speed at which t...
Definition: ConditionalConstraint.h:47
 
Constrain a single mobilizer coordinate q to have a particular value.
Definition: Constraint.h:858
 
One constraint equation.
Definition: Constraint_PointInPlane.h:47
 
This constraint consists of one constraint equation that enforces a constant distance between a point...
Definition: Constraint_Rod.h:52
 
(Experimental – API will change – use at your own risk) Set a hard limit on the minimum value of a ge...
Definition: ConditionalConstraint.h:400
 
bool enable(State &state) const override
Enable the normal and friction constraints if they were disabled.
Definition: ConditionalConstraint.h:408
 
Vec3 whereToDisplay(const State &state) const override
This returns a point in the ground frame at which you might want to say the constraint is "located",...
 
Real getAerr(const State &state) const override
Return the time derivative of the contact constraint velocity error.
 
Real calcEffectiveCOR(const State &state, Real defaultCaptureSpeed, Real defaultMinCORSpeed, Real impactSpeed) const override
Returns the effective coefficient of restitution (COR) for this contact, given an impact speed (a non...
Definition: ConditionalConstraint.h:424
 
MultiplierIndex getContactMultiplierIndex(const State &s) const override
Return the multiplier index Simbody assigned for the unilateral contact constraint (for contact,...
 
bool isEnabled(const State &state) const override
Return true if this contact is enabled.
Definition: ConditionalConstraint.h:411
 
HardStopLower(MobilizedBody &mobod, MobilizerQIndex whichQ, Real defaultLowerLimit, Real minCOR)
 
bool disable(State &state) const override
Disable the normal and friction constraints if they were enabled.
Definition: ConditionalConstraint.h:405
 
Real getVerr(const State &state) const override
Return the time derivative of the contact constraint position error.
 
Real getPerr(const State &state) const override
Return the position error for the contact constraint (usually a signed distance function).
 
(Experimental – API will change – use at your own risk) Set a hard limit on the maximum value of a ge...
Definition: ConditionalConstraint.h:342
 
MultiplierIndex getContactMultiplierIndex(const State &s) const override
Return the multiplier index Simbody assigned for the unilateral contact constraint (for contact,...
 
HardStopUpper(MobilizedBody &mobod, MobilizerQIndex whichQ, Real defaultUpperLimit, Real minCOR)
 
Real getAerr(const State &state) const override
Return the time derivative of the contact constraint velocity error.
 
bool isEnabled(const State &state) const override
Return true if this contact is enabled.
Definition: ConditionalConstraint.h:353
 
Real calcEffectiveCOR(const State &state, Real defaultCaptureSpeed, Real defaultMinCORSpeed, Real impactSpeed) const override
Returns the effective coefficient of restitution (COR) for this contact, given an impact speed (a non...
Definition: ConditionalConstraint.h:366
 
Real getPerr(const State &state) const override
Return the position error for the contact constraint (usually a signed distance function).
 
bool enable(State &state) const override
Enable the normal and friction constraints if they were disabled.
Definition: ConditionalConstraint.h:350
 
bool disable(State &state) const override
Disable the normal and friction constraints if they were enabled.
Definition: ConditionalConstraint.h:347
 
Real getVerr(const State &state) const override
Return the time derivative of the contact constraint position error.
 
Vec3 whereToDisplay(const State &state) const override
This returns a point in the ground frame at which you might want to say the constraint is "located",...
 
A MobilizedBody is Simbody's fundamental body-and-joint object used to parameterize a system's motion...
Definition: MobilizedBody.h:169
 
The Mobilizer associated with each MobilizedBody, once modeled, has a specific number of generalized ...
 
Unique integer type for Subsystem-local multiplier indexing.
 
(Experimental – API will change – use at your own risk) Set a hard upper limit on the separation betw...
Definition: ConditionalConstraint.h:459
 
bool enable(State &state) const override
Enable the normal and friction constraints if they were disabled.
Definition: ConditionalConstraint.h:468
 
MultiplierIndex getContactMultiplierIndex(const State &s) const override
Return the multiplier index Simbody assigned for the unilateral contact constraint (for contact,...
 
Real calcEffectiveCOR(const State &state, Real defaultCaptureSpeed, Real defaultMinCORSpeed, Real impactSpeed) const override
Returns the effective coefficient of restitution (COR) for this contact, given an impact speed (a non...
Definition: ConditionalConstraint.h:483
 
Rope(MobilizedBody &mobod1, const Vec3 &point1, MobilizedBody &mobod2, const Vec3 &point2, Real defaultLengthLimit, Real minCOR)
 
Real getAerr(const State &state) const override
Return the time derivative of the contact constraint velocity error.
 
Real getVerr(const State &state) const override
Return the time derivative of the contact constraint position error.
 
Real getPerr(const State &state) const override
Return the position error for the contact constraint (usually a signed distance function).
 
bool disable(State &state) const override
Disable the normal and friction constraints if they were enabled.
Definition: ConditionalConstraint.h:465
 
bool isEnabled(const State &state) const override
Return true if this contact is enabled.
Definition: ConditionalConstraint.h:471
 
Vec3 whereToDisplay(const State &state) const override
This returns a point in the ground frame at which you might want to say the constraint is "located",...
 
TODO: not implemented yet.
Definition: ConditionalConstraint.h:289
 
virtual Real getSlipSpeed(const State &state) const =0
 
StateLimitedFriction()
Definition: ConditionalConstraint.h:291
 
void setMyIndex(StateLimitedFrictionIndex fx)
Definition: ConditionalConstraint.h:320
 
virtual bool enable(State &state) const =0
Enable the friction constraints if they were disabled.
 
virtual ~StateLimitedFriction()
Definition: ConditionalConstraint.h:292
 
virtual void setInstanceParameter(State &state, const Vec3 &pos) const
TODO: kludge to set instance parameters on internal constraints; this should be the same Vec3 you got...
Definition: ConditionalConstraint.h:318
 
virtual Real calcEffectiveCOF(const State &state, Real defaultTransitionSpeed, Real slipSpeed) const =0
 
StateLimitedFrictionIndex getMyIndex() const
Definition: ConditionalConstraint.h:321
 
virtual Real getNormalForceMagnitude(const State &state) const =0
Return the current value of the state-dependent normal force magnitude that limits this friction elem...
 
virtual Vec3 getPositionInfo(const State &state) const
TODO: kludge needed because we're misusing existing constraints.
Definition: ConditionalConstraint.h:314
 
virtual bool disable(State &state) const =0
Disable the friction constraints if they were enabled.
 
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:280
 
TODO: not implemented yet.
Definition: ConditionalConstraint.h:238
 
UnilateralSpeedConstraint()
Definition: ConditionalConstraint.h:240
 
virtual ~UnilateralSpeedConstraint()
Definition: ConditionalConstraint.h:241
 
Vec< 2 > Vec2
This is the most common 2D vector type: a column of 2 Real values stored consecutively in memory (pac...
Definition: SmallMatrix.h:126
 
Vec< 3 > Vec3
This is the most common 3D vector type: a column of 3 Real values stored consecutively in memory (pac...
Definition: SmallMatrix.h:129
 
const Real NaN
This is the IEEE "not a number" constant for this implementation of the default-precision Real type; ...
 
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
 
unsigned int sign(unsigned char u)
Definition: Scalar.h:311
 
SimTK_Real Real
This is the default compiled-in floating point type for SimTK, either float or double.
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:607