Simbody 3.7
Loading...
Searching...
No Matches
ConditionalConstraint.h
Go to the documentation of this file.
1#ifndef SimTK_SIMBODY_CONDITIONAL_CONSTRAINT_H_
2#define SimTK_SIMBODY_CONDITIONAL_CONSTRAINT_H_
3
4/* -------------------------------------------------------------------------- *
5 * Simbody(tm) *
6 * -------------------------------------------------------------------------- *
7 * This is part of the SimTK biosimulation toolkit originating from *
8 * Simbios, the NIH National Center for Physics-Based Simulation of *
9 * Biological Structures at Stanford, funded under the NIH Roadmap for *
10 * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11 * *
12 * Portions copyright (c) 2014 Stanford University and the Authors. *
13 * Authors: Michael Sherman *
14 * Contributors: *
15 * *
16 * Licensed under the Apache License, Version 2.0 (the "License"); you may *
17 * not use this file except in compliance with the License. You may obtain a *
18 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19 * *
20 * Unless required by applicable law or agreed to in writing, software *
21 * distributed under the License is distributed on an "AS IS" BASIS, *
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23 * See the License for the specific language governing permissions and *
24 * limitations under the License. *
25 * -------------------------------------------------------------------------- */
26
27#include "SimTKmath.h"
32
33namespace SimTK {
34
39public:
40
47static Real calcEffectiveCOR(Real minCOR, Real captureSpeed, Real minCORSpeed,
48 Real impactSpeed)
49{
50 assert(0 <= minCOR && minCOR <= 1);
51 assert(0 <= captureSpeed && captureSpeed <= minCORSpeed);
52 assert(impactSpeed >= 0);
53
54 if (impactSpeed <= captureSpeed) return 0;
55 if (impactSpeed >= minCORSpeed) return minCOR;
56 // captureSpeed < impactSpeed < minCORSpeed
57 const Real slope = (1-minCOR) / minCORSpeed;
58 return 1 - slope*impactSpeed;
59}
60
66static Real calcEffectiveCOF(Real mu_s, Real mu_d, Real mu_v,
67 Real transitionSpeed, Real slipSpeed)
68{
69 assert(mu_s>=0 && mu_d>=0 && mu_v>=0);
70 assert(mu_s>=mu_d);
71 assert(transitionSpeed>=0 && slipSpeed>=0);
72 const Real viscous = mu_v*slipSpeed; // typically zero
73 return viscous + (slipSpeed <= transitionSpeed ? mu_s : mu_d);
74}
75
76};
77
78class UnilateralContact; // normal + friction
79class UnilateralSpeedConstraint;
80class BoundedSpeedConstraint;
81
82class ConstraintLimitedFriction;
83class StateLimitedFriction;
84
85//==============================================================================
86// UNILATERAL CONTACT CONSTRAINT
87//==============================================================================
121public:
125 explicit UnilateralContact(int sign=1) : m_sign((Real)sign)
126 { assert(sign==1 || sign==-1); }
127
129
131 Real getSignConvention() const {return m_sign;}
132
135 virtual bool disable(State& state) const = 0;
136
139 virtual bool enable(State& state) const = 0;
140
142 virtual bool isEnabled(const State& state) const = 0;
143
146 virtual Vec3 whereToDisplay(const State& state) const = 0;
147
155 virtual Real calcEffectiveCOR(const State& state,
156 Real defaultCaptureSpeed,
157 Real defaultMinCORSpeed,
158 Real impactSpeed) const = 0;
159
163 virtual Real getPerr(const State& state) const = 0;
166 virtual Real getVerr(const State& state) const = 0;
169 virtual Real getAerr(const State& state) const = 0;
170
175 virtual bool isProximal(const State& state, Real ptol) const
176 { return m_sign*getPerr(state) <= ptol; }
177
182 virtual MultiplierIndex
183 getContactMultiplierIndex(const State& state) const = 0;
184
187 virtual bool hasFriction(const State& state) const {return false;}
188
196 virtual Real calcEffectiveCOF(const State& state,
197 Real defaultTransitionSpeed,
198 Real slipSpeed) const
199 { return NaN; }
200
201 virtual Vec2 getSlipVelocity(const State& state) const
202 { return Vec2(NaN); }
203
207 virtual void
209 MultiplierIndex& ix_x,
210 MultiplierIndex& ix_y) const
211 { ix_x.invalidate(); ix_y.invalidate(); }
212
215 virtual Vec3 getPositionInfo(const State& state) const
216 { return Vec3(NaN); }
219 virtual void setInstanceParameter(State& state, const Vec3& pos) const {}
220
221
222 void setMyIndex(UnilateralContactIndex cx) {m_myIx = cx;}
223 UnilateralContactIndex getMyIndex() const {return m_myIx;}
224private:
225 Real m_sign; // 1 or -1
226 UnilateralContactIndex m_myIx;
227};
228
229//==============================================================================
230// UNILATERAL SPEED CONSTRAINT
231//==============================================================================
245
246//==============================================================================
247// BOUNDED SPEED CONSTRAINT
248//==============================================================================
273public:
276
281 virtual Vec2 calcEffectiveBounds(const State& state) const = 0;
282private:
283};
284
285//==============================================================================
286// STATE LIMITED FRICTION
287//==============================================================================
290public:
293
296 virtual bool disable(State& state) const = 0;
297
300 virtual bool enable(State& state) const = 0;
301
304 virtual Real getNormalForceMagnitude(const State& state) const = 0;
305
306 virtual Real calcEffectiveCOF(const State& state,
307 Real defaultTransitionSpeed,
308 Real slipSpeed) const = 0;
309
310 virtual Real getSlipSpeed(const State& state) const = 0;
311
314 virtual Vec3 getPositionInfo(const State& state) const
315 { return Vec3(NaN); }
318 virtual void setInstanceParameter(State& state, const Vec3& pos) const {}
319
320 void setMyIndex(StateLimitedFrictionIndex fx) {m_myIx = fx;}
321 StateLimitedFrictionIndex getMyIndex() const {return m_myIx;}
322private:
323 StateLimitedFrictionIndex m_myIx;
324};
325
326
327//==============================================================================
328// HARD STOP UPPER
329//==============================================================================
343public:
345 Real defaultUpperLimit, Real minCOR);
346
347 bool disable(State& state) const override
348 { if (m_upper.isDisabled(state)) return false;
349 else {m_upper.disable(state); return true;} }
350 bool enable(State& state) const override
351 { if (!m_upper.isDisabled(state)) return false;
352 else {m_upper.enable(state); return true;} }
353 bool isEnabled(const State& state) const override
354 { return !m_upper.isDisabled(state); }
355
356 // Returns the contact point in the Ground frame.
357 Vec3 whereToDisplay(const State& state) const override;
358
359 // Currently have to fake the perr because the constraint might be
360 // disabled in which case it won't calculate perr. Also, we want
361 // negative to mean violated so may need to adjust the sign.
362 Real getPerr(const State& state) const override;
363 Real getVerr(const State& state) const override;
364 Real getAerr(const State& state) const override;
365
367 Real defaultCaptureSpeed,
368 Real defaultMinCORSpeed,
369 Real impactSpeed) const override
370 {
371 return ConditionalConstraint::calcEffectiveCOR
372 (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
373 impactSpeed);
374 }
375
377
378private:
379 MobilizedBody m_mobod;
380 Real m_defaultUpperLimit;
381 Real m_minCOR;
383};
384
385//==============================================================================
386// HARD STOP LOWER
387//==============================================================================
401public:
403 Real defaultLowerLimit, Real minCOR);
404
405 bool disable(State& state) const override
406 { if (m_lower.isDisabled(state)) return false;
407 else {m_lower.disable(state); return true;} }
408 bool enable(State& state) const override
409 { if (!m_lower.isDisabled(state)) return false;
410 else {m_lower.enable(state); return true;} }
411 bool isEnabled(const State& state) const override
412 { return !m_lower.isDisabled(state); }
413
414 // Returns the contact point in the Ground frame.
415 Vec3 whereToDisplay(const State& state) const override;
416
417 // Currently have to fake the perr because the constraint might be
418 // disabled in which case it won't calculate perr. Also, we want
419 // negative to mean violated so may need to adjust the sign.
420 Real getPerr(const State& state) const override;
421 Real getVerr(const State& state) const override;
422 Real getAerr(const State& state) const override;
423
425 Real defaultCaptureSpeed,
426 Real defaultMinCORSpeed,
427 Real impactSpeed) const override
428 {
429 return ConditionalConstraint::calcEffectiveCOR
430 (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
431 impactSpeed);
432 }
433
435private:
436 MobilizedBody m_mobod;
437 Real m_defaultLowerLimit;
438 Real m_minCOR;
440};
441
442
443
444//==============================================================================
445// ROPE
446//==============================================================================
460public:
461 Rope(MobilizedBody& mobod1, const Vec3& point1,
462 MobilizedBody& mobod2, const Vec3& point2,
463 Real defaultLengthLimit, Real minCOR);
464
465 bool disable(State& state) const override
466 { if (m_rod.isDisabled(state)) return false;
467 else {m_rod.disable(state); return true;} }
468 bool enable(State& state) const override
469 { if (!m_rod.isDisabled(state)) return false;
470 else {m_rod.enable(state); return true;} }
471 bool isEnabled(const State& state) const override
472 { return !m_rod.isDisabled(state); }
473
474 // Returns half-way location in the Ground frame.
475 Vec3 whereToDisplay(const State& state) const override;
476
477 // Currently have to fake the perr because the constraint might be
478 // disabled in which case it won't calculate perr.
479 Real getPerr(const State& state) const override;
480 Real getVerr(const State& state) const override;
481 Real getAerr(const State& state) const override;
482
484 Real defaultCaptureSpeed,
485 Real defaultMinCORSpeed,
486 Real impactSpeed) const override
487 {
488 return ConditionalConstraint::calcEffectiveCOR
489 (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
490 impactSpeed);
491 }
492
494private:
495 Real m_minCOR;
496 Constraint::Rod m_rod;
497};
498
499//==============================================================================
500// POINT PLANE FRICTIONLESS CONTACT
501//==============================================================================
507: public UnilateralContact {
508public:
510 MobilizedBody& planeBodyB, const UnitVec3& normal_B, Real height,
511 MobilizedBody& followerBodyF, const Vec3& point_F, Real minCOR);
512
513 bool disable(State& state) const override {
514 if (m_ptInPlane.isDisabled(state)) return false;
515 m_ptInPlane.disable(state);
516 return true;
517 }
518
519 bool enable(State& state) const override {
520 if (!m_ptInPlane.isDisabled(state)) return false;
521 m_ptInPlane.enable(state);
522 return true;
523 }
524
525 bool isEnabled(const State& state) const override {
526 return !m_ptInPlane.isDisabled(state);
527 }
528
529 // Returns the contact point in the Ground frame.
530 Vec3 whereToDisplay(const State& state) const override;
531
532 // Currently have to fake the perr because the constraint might be
533 // disabled in which case it won't calculate perr.
534 Real getPerr(const State& state) const override;
535
536 // We won't need to look at these except for proximal constraints which
537 // will already have been enabled, so no need to fake.
538 Real getVerr(const State& state) const override
539 { return m_ptInPlane.getVelocityError(state); }
540 Real getAerr(const State& state) const override
541 { return m_ptInPlane.getAccelerationError(state); }
542
543
545 Real defaultCaptureSpeed,
546 Real defaultMinCORSpeed,
547 Real impactSpeed) const override
548 {
549 return ConditionalConstraint::calcEffectiveCOR
550 (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
551 impactSpeed);
552 }
553
555
556private:
557 MobilizedBody m_planeBody; // body P
558 const Rotation m_frame; // z is normal; expressed in P
559 const Real m_height;
560
561 MobilizedBody m_follower; // body F
562 const Vec3 m_point; // measured & expressed in F
563
564 Real m_minCOR;
565
566 Constraint::PointInPlane m_ptInPlane;
567};
568
569
570//==============================================================================
571// POINT PLANE CONTACT
572//==============================================================================
579public:
581 MobilizedBody& planeBodyB, const UnitVec3& normal_B, Real height,
582 MobilizedBody& followerBodyF, const Vec3& point_F,
583 Real minCOR, Real mu_s, Real mu_d, Real mu_v);
584
585 bool disable(State& state) const override {
586 if (m_ptInPlane.isDisabled(state)) return false;
587 m_ptInPlane.disable(state);
588 return true;
589 }
590
591 bool enable(State& state) const override {
592 if (!m_ptInPlane.isDisabled(state)) return false;
593 m_ptInPlane.enable(state);
594 return true;
595 }
596
597 bool isEnabled(const State& state) const override {
598 return !m_ptInPlane.isDisabled(state);
599 }
600
601 // Returns the contact point in the Ground frame.
602 Vec3 whereToDisplay(const State& state) const override;
603
604 // Currently have to fake the perr because the constraint might be
605 // disabled in which case it won't calculate perr.
606 Real getPerr(const State& state) const override;
607
608 // We won't need to look at these except for proximal constraints which
609 // will already have been enabled, so no need to fake.
610 Real getVerr(const State& state) const override
611 { return m_ptInPlane.getVelocityErrors(state)[2]; }
612 Real getAerr(const State& state) const override
613 { return m_ptInPlane.getAccelerationErrors(state)[2]; }
614
615
617 Real defaultCaptureSpeed,
618 Real defaultMinCORSpeed,
619 Real impactSpeed) const override
620 {
621 return ConditionalConstraint::calcEffectiveCOR
622 (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
623 impactSpeed);
624 }
625
626 bool hasFriction(const State& state) const override
627 { return true; }
628
629 Vec2 getSlipVelocity(const State& state) const override {
630 const Vec3 v = m_ptInPlane.getVelocityErrors(state);
631 return Vec2(v[0], v[1]);
632 }
633
635 Real defaultTransitionSpeed,
636 Real slipSpeed) const override
637 {
638 return ConditionalConstraint::calcEffectiveCOF
639 (m_mu_s, m_mu_d, m_mu_v, defaultTransitionSpeed, slipSpeed);
640 }
641
643
645 MultiplierIndex& ix_x,
646 MultiplierIndex& ix_y) const override;
647
648private:
649 MobilizedBody m_planeBody; // body P
650 const Rotation m_frame; // z is normal; expressed in P
651 const Real m_height;
652
653 MobilizedBody m_follower; // body F
654 const Vec3 m_point; // measured & expressed in F
655
656 Real m_minCOR;
657 Real m_mu_s, m_mu_d, m_mu_v;
658
660};
661
662//==============================================================================
663// SPHERE PLANE CONTACT
664//==============================================================================
671public:
673 MobilizedBody& planeBodyB, const UnitVec3& normal_B, Real height,
674 MobilizedBody& followerBodyF, const Vec3& point_F, Real radius,
675 Real minCOR, Real mu_s, Real mu_d, Real mu_v);
676
677 bool disable(State& state) const override {
678 if (m_sphereOnPlane.isDisabled(state)) return false;
679 m_sphereOnPlane.disable(state);
680 return true;
681 }
682
683 bool enable(State& state) const override {
684 if (!m_sphereOnPlane.isDisabled(state)) return false;
685 m_sphereOnPlane.enable(state);
686 return true;
687 }
688
689 bool isEnabled(const State& state) const override {
690 return !m_sphereOnPlane.isDisabled(state);
691 }
692
693 // Returns the contact point in the Ground frame.
694 Vec3 whereToDisplay(const State& state) const override;
695
696 // Currently have to fake the perr because the constraint might be
697 // disabled in which case it won't calculate perr.
698 Real getPerr(const State& state) const override;
699
700 // We won't need to look at these except for proximal constraints which
701 // will already have been enabled, so no need to fake.
702 Real getVerr(const State& state) const override
703 { return m_sphereOnPlane.getVelocityErrors(state)[2]; }
704 Real getAerr(const State& state) const override
705 { return m_sphereOnPlane.getAccelerationErrors(state)[2]; }
706
707
709 Real defaultCaptureSpeed,
710 Real defaultMinCORSpeed,
711 Real impactSpeed) const override
712 {
713 return ConditionalConstraint::calcEffectiveCOR
714 (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
715 impactSpeed);
716 }
717
718 bool hasFriction(const State& state) const override
719 { return true; }
720
721 Vec2 getSlipVelocity(const State& state) const override {
722 const Vec3 v = m_sphereOnPlane.getVelocityErrors(state);
723 return Vec2(v[0], v[1]);
724 }
725
727 Real defaultTransitionSpeed,
728 Real slipSpeed) const override
729 {
730 return ConditionalConstraint::calcEffectiveCOF
731 (m_mu_s, m_mu_d, m_mu_v, defaultTransitionSpeed, slipSpeed);
732 }
733
735
737 MultiplierIndex& ix_x,
738 MultiplierIndex& ix_y) const override;
739
740private:
741 Real m_minCOR;
742 Real m_mu_s, m_mu_d, m_mu_v;
743
744 Constraint::SphereOnPlaneContact m_sphereOnPlane;
745};
746
747//==============================================================================
748// SPHERE SPHERE CONTACT
749//==============================================================================
757public:
759 MobilizedBody& mobod_F,
760 const Vec3& defaultCenterOnF,
761 Real defaultRadiusOnF,
762 MobilizedBody& mobod_B,
763 const Vec3& defaultCenterOnB,
764 Real defaultRadiusOnB,
765 Real minCOR, Real mu_s, Real mu_d, Real mu_v);
766
767 bool disable(State& state) const override {
768 if (m_sphereOnSphere.isDisabled(state)) return false;
769 m_sphereOnSphere.disable(state);
770 return true;
771 }
772
773 bool enable(State& state) const override {
774 if (!m_sphereOnSphere.isDisabled(state)) return false;
775 m_sphereOnSphere.enable(state);
776 return true;
777 }
778
779 bool isEnabled(const State& state) const override {
780 return !m_sphereOnSphere.isDisabled(state);
781 }
782
783 // Returns the contact point in the Ground frame.
784 Vec3 whereToDisplay(const State& state) const override;
785
786 // Currently have to fake the perr because the constraint might be
787 // disabled in which case it won't calculate perr.
788 Real getPerr(const State& state) const override;
789
790 // We won't need to look at these except for proximal constraints which
791 // will already have been enabled, so no need to fake.
792 Real getVerr(const State& state) const override
793 { return m_sphereOnSphere.getVelocityErrors(state)[2]; }
794 Real getAerr(const State& state) const override
795 { return m_sphereOnSphere.getAccelerationErrors(state)[2]; }
796
797
799 Real defaultCaptureSpeed,
800 Real defaultMinCORSpeed,
801 Real impactSpeed) const override
802 {
803 return ConditionalConstraint::calcEffectiveCOR
804 (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
805 impactSpeed);
806 }
807
808 bool hasFriction(const State& state) const override
809 { return true; }
810
811 Vec2 getSlipVelocity(const State& state) const override {
812 const Vec3 v = m_sphereOnSphere.getVelocityErrors(state);
813 return Vec2(v[0], v[1]);
814 }
815
817 Real defaultTransitionSpeed,
818 Real slipSpeed) const override
819 {
820 return ConditionalConstraint::calcEffectiveCOF
821 (m_mu_s, m_mu_d, m_mu_v, defaultTransitionSpeed, slipSpeed);
822 }
823
825
827 MultiplierIndex& ix_x,
828 MultiplierIndex& ix_y) const override;
829
830private:
831 Real m_minCOR;
832 Real m_mu_s, m_mu_d, m_mu_v;
833
834 Constraint::SphereOnSphereContact m_sphereOnSphere;
835};
836
837
838//==============================================================================
839// EDGE EDGE CONTACT
840//==============================================================================
853public:
855 MobilizedBody& mobod_F,
856 const Transform& defaultEdgeFrameF,
857 Real defaultHalfLengthF,
858 MobilizedBody& mobod_B,
859 const Transform& defaultEdgeFrameB,
860 Real defaultHalfLengthB,
861 Real minCOR, Real mu_s, Real mu_d, Real mu_v);
862
863 bool disable(State& state) const override {
864 if (m_lineOnLine.isDisabled(state)) return false;
865 m_lineOnLine.disable(state);
866 return true;
867 }
868
869 bool enable(State& state) const override {
870 if (!m_lineOnLine.isDisabled(state)) return false;
871 m_lineOnLine.enable(state);
872 return true;
873 }
874
875 bool isEnabled(const State& state) const override {
876 return !m_lineOnLine.isDisabled(state);
877 }
878
879 // Returns the contact point in the Ground frame.
880 Vec3 whereToDisplay(const State& state) const override;
881
882 // Currently have to fake the perr because the constraint might be
883 // disabled in which case it won't calculate perr.
884 Real getPerr(const State& state) const override;
885
886 // We won't need to look at these except for proximal constraints which
887 // will already have been enabled, so no need to fake.
888 Real getVerr(const State& state) const override
889 { return m_lineOnLine.getVelocityErrors(state)[2]; }
890 Real getAerr(const State& state) const override
891 { return m_lineOnLine.getAccelerationErrors(state)[2]; }
892
893
895 Real defaultCaptureSpeed,
896 Real defaultMinCORSpeed,
897 Real impactSpeed) const override
898 {
899 return ConditionalConstraint::calcEffectiveCOR
900 (m_minCOR, defaultCaptureSpeed, defaultMinCORSpeed,
901 impactSpeed);
902 }
903
904 bool hasFriction(const State& state) const override
905 { return true; }
906
907 Vec2 getSlipVelocity(const State& state) const override {
908 const Vec3 v = m_lineOnLine.getVelocityErrors(state);
909 return Vec2(v[0], v[1]);
910 }
911
913 Real defaultTransitionSpeed,
914 Real slipSpeed) const override
915 {
916 return ConditionalConstraint::calcEffectiveCOF
917 (m_mu_s, m_mu_d, m_mu_v, defaultTransitionSpeed, slipSpeed);
918 }
919
921
923 MultiplierIndex& ix_x,
924 MultiplierIndex& ix_y) const override;
925
926private:
927 Real m_minCOR;
928 Real m_mu_s, m_mu_d, m_mu_v;
929
931};
932
933} // namespace SimTK
934
935#endif // SimTK_SIMBODY_CONDITIONAL_CONSTRAINT_H_
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
This constraint represents a bilateral connection between an edge on one body and a non-parallel edge...
Definition Constraint_LineOnLineContact.h:143
One constraint equation.
Definition Constraint_PointInPlane.h:47
(Advanced) This is the underlying constraint for unilateral contact with friction but must be combine...
Definition Constraint_PointOnPlaneContact.h:88
This constraint consists of one constraint equation that enforces a constant distance between a point...
Definition Constraint_Rod.h:52
This constraint represents a bilateral connection between a sphere on one body and a plane on another...
Definition Constraint_SphereOnPlaneContact.h:87
This constraint represents a bilateral connection between a sphere on one body and a sphere on anothe...
Definition Constraint_SphereOnSphereContact.h:103
(Experimental – API will change – use at your own risk) Define an edge on each of two bodies,...
Definition ConditionalConstraint.h:852
bool hasFriction(const State &state) const override
Returns true if there is a friction constraint associated with this contact constraint.
Definition ConditionalConstraint.h:904
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",...
bool enable(State &state) const override
Enable the normal and friction constraints if they were disabled.
Definition ConditionalConstraint.h:869
Real calcEffectiveCOF(const State &state, Real defaultTransitionSpeed, Real slipSpeed) const override
Returns the effective coefficient of friction mu for this contact, given a relative slip speed (a non...
Definition ConditionalConstraint.h:912
Real getPerr(const State &state) const override
Return the position error for the contact constraint (usually a signed distance function).
EdgeEdgeContact(MobilizedBody &mobod_F, const Transform &defaultEdgeFrameF, Real defaultHalfLengthF, MobilizedBody &mobod_B, const Transform &defaultEdgeFrameB, Real defaultHalfLengthB, Real minCOR, Real mu_s, Real mu_d, Real mu_v)
MultiplierIndex getContactMultiplierIndex(const State &s) const override
Return the multiplier index Simbody assigned for the unilateral contact constraint (for contact,...
Real getVerr(const State &state) const override
Return the time derivative of the contact constraint position error.
Definition ConditionalConstraint.h:888
Vec2 getSlipVelocity(const State &state) const override
Definition ConditionalConstraint.h:907
bool isEnabled(const State &state) const override
Return true if this contact is enabled.
Definition ConditionalConstraint.h:875
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:894
void getFrictionMultiplierIndices(const State &s, MultiplierIndex &ix_x, MultiplierIndex &ix_y) const override
If hasFriction(), this method returns the multipliers used for the x- and y-direction friction constr...
Real getAerr(const State &state) const override
Return the time derivative of the contact constraint velocity error.
Definition ConditionalConstraint.h:890
bool disable(State &state) const override
Disable the normal and friction constraints if they were enabled.
Definition ConditionalConstraint.h:863
(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) Define a point on one body that cannot penetr...
Definition ConditionalConstraint.h:578
void getFrictionMultiplierIndices(const State &s, MultiplierIndex &ix_x, MultiplierIndex &ix_y) const override
If hasFriction(), this method returns the multipliers used for the x- and y-direction friction constr...
PointPlaneContact(MobilizedBody &planeBodyB, const UnitVec3 &normal_B, Real height, MobilizedBody &followerBodyF, const Vec3 &point_F, Real minCOR, Real mu_s, Real mu_d, Real mu_v)
bool isEnabled(const State &state) const override
Return true if this contact is enabled.
Definition ConditionalConstraint.h:597
MultiplierIndex getContactMultiplierIndex(const State &s) const override
Return the multiplier index Simbody assigned for the unilateral contact constraint (for contact,...
bool disable(State &state) const override
Disable the normal and friction constraints if they were enabled.
Definition ConditionalConstraint.h:585
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",...
bool enable(State &state) const override
Enable the normal and friction constraints if they were disabled.
Definition ConditionalConstraint.h:591
Real calcEffectiveCOF(const State &state, Real defaultTransitionSpeed, Real slipSpeed) const override
Returns the effective coefficient of friction mu for this contact, given a relative slip speed (a non...
Definition ConditionalConstraint.h:634
Real getVerr(const State &state) const override
Return the time derivative of the contact constraint position error.
Definition ConditionalConstraint.h:610
Vec2 getSlipVelocity(const State &state) const override
Definition ConditionalConstraint.h:629
Real getPerr(const State &state) const override
Return the position error for the contact constraint (usually a signed distance function).
Real getAerr(const State &state) const override
Return the time derivative of the contact constraint velocity error.
Definition ConditionalConstraint.h:612
bool hasFriction(const State &state) const override
Returns true if there is a friction constraint associated with this contact constraint.
Definition ConditionalConstraint.h:626
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:616
(Experimental – API will change – use at your own risk) Define a point on one body that cannot penetr...
Definition ConditionalConstraint.h:507
Real getVerr(const State &state) const override
Return the time derivative of the contact constraint position error.
Definition ConditionalConstraint.h:538
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:544
Real getAerr(const State &state) const override
Return the time derivative of the contact constraint velocity error.
Definition ConditionalConstraint.h:540
bool enable(State &state) const override
Enable the normal and friction constraints if they were disabled.
Definition ConditionalConstraint.h:519
Real getPerr(const State &state) const override
Return the position error for the contact constraint (usually a signed distance function).
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",...
PointPlaneFrictionlessContact(MobilizedBody &planeBodyB, const UnitVec3 &normal_B, Real height, MobilizedBody &followerBodyF, const Vec3 &point_F, Real minCOR)
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:525
bool disable(State &state) const override
Disable the normal and friction constraints if they were enabled.
Definition ConditionalConstraint.h:513
(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",...
(Experimental – API will change – use at your own risk) Define a sphere on one body that cannot penet...
Definition ConditionalConstraint.h:670
Real getPerr(const State &state) const override
Return the position error for the contact constraint (usually a signed distance function).
bool hasFriction(const State &state) const override
Returns true if there is a friction constraint associated with this contact constraint.
Definition ConditionalConstraint.h:718
Real getAerr(const State &state) const override
Return the time derivative of the contact constraint velocity error.
Definition ConditionalConstraint.h:704
bool enable(State &state) const override
Enable the normal and friction constraints if they were disabled.
Definition ConditionalConstraint.h:683
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:708
bool isEnabled(const State &state) const override
Return true if this contact is enabled.
Definition ConditionalConstraint.h:689
bool disable(State &state) const override
Disable the normal and friction constraints if they were enabled.
Definition ConditionalConstraint.h:677
void getFrictionMultiplierIndices(const State &s, MultiplierIndex &ix_x, MultiplierIndex &ix_y) const override
If hasFriction(), this method returns the multipliers used for the x- and y-direction friction constr...
Real getVerr(const State &state) const override
Return the time derivative of the contact constraint position error.
Definition ConditionalConstraint.h:702
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 calcEffectiveCOF(const State &state, Real defaultTransitionSpeed, Real slipSpeed) const override
Returns the effective coefficient of friction mu for this contact, given a relative slip speed (a non...
Definition ConditionalConstraint.h:726
SpherePlaneContact(MobilizedBody &planeBodyB, const UnitVec3 &normal_B, Real height, MobilizedBody &followerBodyF, const Vec3 &point_F, Real radius, Real minCOR, Real mu_s, Real mu_d, Real mu_v)
Vec2 getSlipVelocity(const State &state) const override
Definition ConditionalConstraint.h:721
(Experimental – API will change – use at your own risk) Define a sphere on each of two bodies.
Definition ConditionalConstraint.h:756
Vec2 getSlipVelocity(const State &state) const override
Definition ConditionalConstraint.h:811
void getFrictionMultiplierIndices(const State &s, MultiplierIndex &ix_x, MultiplierIndex &ix_y) const override
If hasFriction(), this method returns the multipliers used for the x- and y-direction friction constr...
Real getVerr(const State &state) const override
Return the time derivative of the contact constraint position error.
Definition ConditionalConstraint.h:792
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:798
Real calcEffectiveCOF(const State &state, Real defaultTransitionSpeed, Real slipSpeed) const override
Returns the effective coefficient of friction mu for this contact, given a relative slip speed (a non...
Definition ConditionalConstraint.h:816
bool disable(State &state) const override
Disable the normal and friction constraints if they were enabled.
Definition ConditionalConstraint.h:767
bool isEnabled(const State &state) const override
Return true if this contact is enabled.
Definition ConditionalConstraint.h:779
bool hasFriction(const State &state) const override
Returns true if there is a friction constraint associated with this contact constraint.
Definition ConditionalConstraint.h:808
Real getPerr(const State &state) const override
Return the position error for the contact constraint (usually a signed distance function).
Real getAerr(const State &state) const override
Return the time derivative of the contact constraint velocity error.
Definition ConditionalConstraint.h:794
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",...
bool enable(State &state) const override
Enable the normal and friction constraints if they were disabled.
Definition ConditionalConstraint.h:773
MultiplierIndex getContactMultiplierIndex(const State &s) const override
Return the multiplier index Simbody assigned for the unilateral contact constraint (for contact,...
SphereSphereContact(MobilizedBody &mobod_F, const Vec3 &defaultCenterOnF, Real defaultRadiusOnF, MobilizedBody &mobod_B, const Vec3 &defaultCenterOnB, Real defaultRadiusOnB, Real minCOR, Real mu_s, Real mu_d, Real mu_v)
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
(Experimental – API will change – use at your own risk) A unilateral contact constraint uses a single...
Definition ConditionalConstraint.h:120
virtual Real getPerr(const State &state) const =0
Return the position error for the contact constraint (usually a signed distance function).
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:219
virtual Real getAerr(const State &state) const =0
Return the time derivative of the contact constraint velocity error.
UnilateralContactIndex getMyIndex() const
Definition ConditionalConstraint.h:223
virtual MultiplierIndex getContactMultiplierIndex(const State &state) const =0
Return the multiplier index Simbody assigned for the unilateral contact constraint (for contact,...
virtual bool isProximal(const State &state, Real ptol) const
Given the position constraint tolerance currently in use, is this contact close enough to contacting ...
Definition ConditionalConstraint.h:175
Real getSignConvention() const
Report the sign convention (1 or -1) supplied at construction.
Definition ConditionalConstraint.h:131
virtual bool enable(State &state) const =0
Enable the normal and friction constraints if they were disabled.
virtual void getFrictionMultiplierIndices(const State &state, MultiplierIndex &ix_x, MultiplierIndex &ix_y) const
If hasFriction(), this method returns the multipliers used for the x- and y-direction friction constr...
Definition ConditionalConstraint.h:208
virtual ~UnilateralContact()
Definition ConditionalConstraint.h:128
void setMyIndex(UnilateralContactIndex cx)
Definition ConditionalConstraint.h:222
virtual Real calcEffectiveCOF(const State &state, Real defaultTransitionSpeed, Real slipSpeed) const
Returns the effective coefficient of friction mu for this contact, given a relative slip speed (a non...
Definition ConditionalConstraint.h:196
virtual Vec3 whereToDisplay(const State &state) const =0
This returns a point in the ground frame at which you might want to say the constraint is "located",...
virtual Real calcEffectiveCOR(const State &state, Real defaultCaptureSpeed, Real defaultMinCORSpeed, Real impactSpeed) const =0
Returns the effective coefficient of restitution (COR) for this contact, given an impact speed (a non...
virtual Real getVerr(const State &state) const =0
Return the time derivative of the contact constraint position error.
virtual bool isEnabled(const State &state) const =0
Return true if this contact is enabled.
virtual Vec2 getSlipVelocity(const State &state) const
Definition ConditionalConstraint.h:201
virtual bool disable(State &state) const =0
Disable the normal and friction constraints if they were enabled.
UnilateralContact(int sign=1)
The base class constructor allows specification of the sign convention to be used with this constrain...
Definition ConditionalConstraint.h:125
virtual Vec3 getPositionInfo(const State &state) const
TODO: kludge needed because we're misusing existing constraints.
Definition ConditionalConstraint.h:215
virtual bool hasFriction(const State &state) const
Returns true if there is a friction constraint associated with this contact constraint.
Definition ConditionalConstraint.h:187
TODO: not implemented yet.
Definition ConditionalConstraint.h:238
UnilateralSpeedConstraint()
Definition ConditionalConstraint.h:240
virtual ~UnilateralSpeedConstraint()
Definition ConditionalConstraint.h:241
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:606