DART 6.6.2
Loading...
Searching...
No Matches
ContactConstraint.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2018, The DART development contributors
3 * All rights reserved.
4 *
5 * The list of contributors can be found at:
6 * https://github.com/dartsim/dart/blob/master/LICENSE
7 *
8 * This file is provided under the following "BSD-style" License:
9 * Redistribution and use in source and binary forms, with or
10 * without modification, are permitted provided that the following
11 * conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef DART_CONSTRAINT_CONTACTCONSTRAINT_HPP_
34#define DART_CONSTRAINT_CONTACTCONSTRAINT_HPP_
35
37
40
41namespace dart {
42
43namespace dynamics {
44class BodyNode;
45class Skeleton;
46} // namespace dynamics
47
48namespace constraint {
49
52{
53public:
55 ContactConstraint(collision::Contact& _contact, double _timeStep);
56
58 virtual ~ContactConstraint();
59
60 //----------------------------------------------------------------------------
61 // Property settings
62 //----------------------------------------------------------------------------
63
65 static void setErrorAllowance(double _allowance);
66
68 static double getErrorAllowance();
69
71 static void setErrorReductionParameter(double _erp);
72
74 static double getErrorReductionParameter();
75
77 static void setMaxErrorReductionVelocity(double _erv);
78
80 static double getMaxErrorReductionVelocity();
81
83 static void setConstraintForceMixing(double _cfm);
84
86 static double getConstraintForceMixing();
87
89 void setFrictionDirection(const Eigen::Vector3d& _dir);
90
92 const Eigen::Vector3d& getFrictionDirection1() const;
93
94 //----------------------------------------------------------------------------
95 // Friendship
96 //----------------------------------------------------------------------------
97
98 friend class ConstraintSolver;
99 friend class ConstrainedGroup;
100
101protected:
102 //----------------------------------------------------------------------------
103 // Constraint virtual functions
104 //----------------------------------------------------------------------------
105
106 // Documentation inherited
107 void update() override;
108
109 // Documentation inherited
110 void getInformation(ConstraintInfo* _info) override;
111
112 // Documentation inherited
113 void applyUnitImpulse(std::size_t _idx) override;
114
115 // Documentation inherited
116 void getVelocityChange(double* _vel, bool _withCfm) override;
117
118 // Documentation inherited
119 void excite() override;
120
121 // Documentation inherited
122 void unexcite() override;
123
124 // Documentation inherited
125 void applyImpulse(double* _lambda) override;
126
127 // Documentation inherited
128 dynamics::SkeletonPtr getRootSkeleton() const override;
129
130 // Documentation inherited
131 void uniteSkeletons() override;
132
133 // Documentation inherited
134 bool isActive() const override;
135
136private:
137 using TangentBasisMatrix = Eigen::Matrix<double, 3, 2>;
138
142 void getRelVelocity(double* _relVel);
143
146
148 TangentBasisMatrix getTangentBasisMatrixODE(const Eigen::Vector3d& _n);
149
150private:
152 double mTimeStep;
153
156
159
161 std::vector<collision::Contact*> mContacts;
162
165
168
171
174
177
180
183
186
189
191 static double mErrorAllowance;
192
196
199
204};
205
206} // namespace constraint
207} // namespace dart
208
209#endif // DART_CONSTRAINT_CONTACTCONSTRAINT_HPP_
210
ConstrainedGroup is a group of skeletons that interact each other with constraints.
Definition ConstrainedGroup.hpp:58
Constraint is a base class of concrete constraints classes.
Definition ConstraintBase.hpp:75
ConstraintSolver manages constraints and computes constraint impulses.
Definition ConstraintSolver.hpp:56
ContactConstraint represents a contact constraint between two bodies.
Definition ContactConstraint.hpp:52
void getVelocityChange(double *_vel, bool _withCfm) override
Get velocity change due to the uint impulse.
Definition ContactConstraint.cpp:605
double mTimeStep
Time step.
Definition ContactConstraint.hpp:152
const Eigen::Vector3d & getFrictionDirection1() const
Get first frictional direction.
Definition ContactConstraint.cpp:366
bool mIsFrictionOn
Definition ContactConstraint.hpp:179
void update() override
Update constraint using updated Skeleton's states.
Definition ContactConstraint.cpp:372
common::aligned_vector< Eigen::Vector6d > mJacobians2
Local body jacobians for mBodyNode2.
Definition ContactConstraint.hpp:176
dynamics::BodyNode * mBodyNode1
Fircst body node.
Definition ContactConstraint.hpp:155
void excite() override
Excite the constraint.
Definition ContactConstraint.cpp:636
static void setConstraintForceMixing(double _cfm)
Set global constraint force mixing parameter.
Definition ContactConstraint.cpp:333
static double mMaxErrorReductionVelocity
Maximum error reduction velocity.
Definition ContactConstraint.hpp:198
void applyUnitImpulse(std::size_t _idx) override
Apply unit impulse to constraint space.
Definition ContactConstraint.cpp:538
bool mActive
Definition ContactConstraint.hpp:188
bool isActive() const override
Return true if this constraint is active.
Definition ContactConstraint.cpp:756
common::aligned_vector< Eigen::Vector6d > mJacobians1
Local body jacobians for mBodyNode1.
Definition ContactConstraint.hpp:173
static double getConstraintForceMixing()
Get global constraint force mixing parameter.
Definition ContactConstraint.cpp:353
void setFrictionDirection(const Eigen::Vector3d &_dir)
Set first frictional direction.
Definition ContactConstraint.cpp:359
dynamics::BodyNode * mBodyNode2
Second body node.
Definition ContactConstraint.hpp:158
void applyImpulse(double *_lambda) override
Apply computed constraint impulse to constrained skeletons.
Definition ContactConstraint.cpp:656
void getInformation(ConstraintInfo *_info) override
Fill LCP variables.
Definition ContactConstraint.cpp:381
double mFrictionCoeff
Coefficient of Friction.
Definition ContactConstraint.hpp:167
void updateFirstFrictionalDirection()
Definition ContactConstraint.cpp:773
static double mErrorReductionParameter
Global constraint error redection parameter in the range of [0, 1].
Definition ContactConstraint.hpp:195
static double getErrorAllowance()
Get global error reduction parameter.
Definition ContactConstraint.cpp:280
static double getMaxErrorReductionVelocity()
Get global error reduction parameter.
Definition ContactConstraint.cpp:327
void getRelVelocity(double *_relVel)
Get change in relative velocity at contact point due to external impulse.
Definition ContactConstraint.cpp:741
virtual ~ContactConstraint()
Destructor.
Definition ContactConstraint.cpp:260
std::size_t mAppliedImpulseIndex
Index of applied impulse.
Definition ContactConstraint.hpp:182
void unexcite() override
Unexcite the constraint.
Definition ContactConstraint.cpp:646
static void setMaxErrorReductionVelocity(double _erv)
Set global error reduction parameter.
Definition ContactConstraint.cpp:312
static double getErrorReductionParameter()
Get global error reduction parameter.
Definition ContactConstraint.cpp:306
TangentBasisMatrix getTangentBasisMatrixODE(const Eigen::Vector3d &_n)
Definition ContactConstraint.cpp:787
static double mErrorAllowance
Global constraint error allowance.
Definition ContactConstraint.hpp:191
bool mIsBounceOn
Definition ContactConstraint.hpp:185
double mRestitutionCoeff
Coefficient of restitution.
Definition ContactConstraint.hpp:170
void uniteSkeletons() override
Definition ContactConstraint.cpp:843
static void setErrorAllowance(double _allowance)
Set global error reduction parameter.
Definition ContactConstraint.cpp:265
Eigen::Matrix< double, 3, 2 > TangentBasisMatrix
Definition ContactConstraint.hpp:137
static double mConstraintForceMixing
Global constraint force mixing parameter in the range of [1e-9, 1].
Definition ContactConstraint.hpp:203
std::vector< collision::Contact * > mContacts
Contacts between mBodyNode1 and mBodyNode2.
Definition ContactConstraint.hpp:161
dynamics::SkeletonPtr getRootSkeleton() const override
Definition ContactConstraint.cpp:762
static void setErrorReductionParameter(double _erp)
Set global error reduction parameter.
Definition ContactConstraint.cpp:286
Eigen::Vector3d mFirstFrictionalDirection
First frictional direction.
Definition ContactConstraint.hpp:164
BodyNode class represents a single node of the skeleton.
Definition BodyNode.hpp:78
std::vector< _Tp, Eigen::aligned_allocator< _Tp > > aligned_vector
Definition Memory.hpp:66
std::shared_ptr< Skeleton > SkeletonPtr
Definition SmartPointer.hpp:60
Definition BulletCollisionDetector.cpp:63
Contact information.
Definition Contact.hpp:45
ConstraintInfo.
Definition ConstraintBase.hpp:50