DART 6.12.2
Loading...
Searching...
No Matches
SoftContactConstraint.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2021, 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_SOFTCONTACTCONSTRAINT_HPP_
34#define DART_CONSTRAINT_SOFTCONTACTCONSTRAINT_HPP_
35
39
40namespace dart {
41
42namespace collision {
43class SoftCollisionInfo;
44} // namespace collision
45
46namespace dynamics {
47class BodyNode;
48class SoftBodyNode;
49class PointMass;
50class Skeleton;
51} // namespace dynamics
52
53namespace constraint {
54
57{
58public:
60 SoftContactConstraint(collision::Contact& _contact, double _timeStep);
61
63 virtual ~SoftContactConstraint();
64
65 // Documentation inherited
66 const std::string& getType() const override;
67
69 static const std::string& getStaticType();
70
71 //----------------------------------------------------------------------------
72 // Property settings
73 //----------------------------------------------------------------------------
74
76 static void setErrorAllowance(double _allowance);
77
79 static double getErrorAllowance();
80
82 static void setErrorReductionParameter(double _erp);
83
85 static double getErrorReductionParameter();
86
88 static void setMaxErrorReductionVelocity(double _erv);
89
91 static double getMaxErrorReductionVelocity();
92
94 static void setConstraintForceMixing(double _cfm);
95
97 static double getConstraintForceMixing();
98
100 void setFrictionDirection(const Eigen::Vector3d& _dir);
101
103 const Eigen::Vector3d& getFrictionDirection1() const;
104
105 //----------------------------------------------------------------------------
106 // Friendship
107 //----------------------------------------------------------------------------
108
109 friend class ConstraintSolver;
110 friend class ConstrainedGroup;
111
112protected:
113 //----------------------------------------------------------------------------
114 // Constraint virtual functions
115 //----------------------------------------------------------------------------
116
117 // Documentation inherited
118 void update() override;
119
120 // Documentation inherited
121 void getInformation(ConstraintInfo* _info) override;
122
123 // Documentation inherited
124 void applyUnitImpulse(std::size_t _idx) override;
125
126 // Documentation inherited
127 void getVelocityChange(double* _vel, bool _withCfm) override;
128
129 // Documentation inherited
130 void excite() override;
131
132 // Documentation inherited
133 void unexcite() override;
134
135 // Documentation inherited
136 void applyImpulse(double* _lambda) override;
137
138 // Documentation inherited
139 dynamics::SkeletonPtr getRootSkeleton() const override;
140
141 // Documentation inherited
142 void uniteSkeletons() override;
143
144 // Documentation inherited
145 bool isActive() const override;
146
147 static double computeFrictionCoefficient(
148 const dynamics::ShapeNode* shapeNode);
149 static double computeRestitutionCoefficient(
150 const dynamics::ShapeNode* shapeNode);
151
152private:
156 void getRelVelocity(double* _vel);
157
160
162 Eigen::MatrixXd getTangentBasisMatrixODE(const Eigen::Vector3d& _n);
163
167 dynamics::SoftBodyNode* _softBodyNode,
168 const Eigen::Vector3d& _point,
169 int _faceId) const;
170
175 const dynamics::SoftBodyNode* _softBodyNode,
176 const Eigen::Vector3d& _point,
177 int _faceId) const;
178
179private:
181 double mTimeStep;
182
185
188
191
194
197
200
201 // TODO(JS): For now, there is only one contact per contact constraint
203 std::vector<collision::Contact*> mContacts;
204
206 collision::SoftCollisionInfo* mSoftCollInfo;
207
210
213
216
219
222
224 Eigen::Vector3d mBodyDirection1;
225
227 Eigen::Vector3d mBodyDirection2;
228
231
234
237
240
242 static double mErrorAllowance;
243
247
250
255};
256
257} // namespace constraint
258} // namespace dart
259
260#endif // DART_CONSTRAINT_SOFTCONTACTCONSTRAINT_HPP_
ConstrainedGroup is a group of skeletons that interact each other with constraints.
Definition ConstrainedGroup.hpp:59
Constraint is a base class of concrete constraints classes.
Definition ConstraintBase.hpp:75
ConstraintSolver manages constraints and computes constraint impulses.
Definition ConstraintSolver.hpp:57
SoftContactConstraint represents a contact constraint between two bodies.
Definition SoftContactConstraint.hpp:57
const Eigen::Vector3d & getFrictionDirection1() const
Get first frictional direction.
Definition SoftContactConstraint.cpp:429
dynamics::PointMass * selectCollidingPointMass(dynamics::SoftBodyNode *_softBodyNode, const Eigen::Vector3d &_point, int _faceId) const
Find the nearest point mass from _point in a face, of which id is _faceId in _softBodyNode.
Definition SoftContactConstraint.cpp:1118
static double getErrorReductionParameter()
Get global error reduction parameter.
Definition SoftContactConstraint.cpp:375
dynamics::PointMass * mPointMass2
Second point mass.
Definition SoftContactConstraint.hpp:199
Eigen::Vector3d mBodyDirection2
Contact normal expressed in body frame of the second body node.
Definition SoftContactConstraint.hpp:227
bool mIsBounceOn
Definition SoftContactConstraint.hpp:236
dynamics::SoftBodyNode * mSoftBodyNode1
First soft body node.
Definition SoftContactConstraint.hpp:190
dynamics::SoftBodyNode * mSoftBodyNode2
Second soft body node.
Definition SoftContactConstraint.hpp:193
dynamics::SkeletonPtr getRootSkeleton() const override
Definition SoftContactConstraint.cpp:981
std::vector< collision::Contact * > mContacts
Contacts between mBodyNode1 and mBodyNode2.
Definition SoftContactConstraint.hpp:203
static double getConstraintForceMixing()
Get global constraint force mixing parameter.
Definition SoftContactConstraint.cpp:417
virtual ~SoftContactConstraint()
Destructor.
Definition SoftContactConstraint.cpp:318
void uniteSkeletons() override
Definition SoftContactConstraint.cpp:990
common::aligned_vector< Eigen::Vector6d > mJacobians1
Local body jacobians for mBodyNode1.
Definition SoftContactConstraint.hpp:218
bool mIsFrictionOn
Definition SoftContactConstraint.hpp:230
double mFrictionCoeff
Coefficient of Friction.
Definition SoftContactConstraint.hpp:212
double mTimeStep
Time step.
Definition SoftContactConstraint.hpp:181
void getInformation(ConstraintInfo *_info) override
Fill LCP variables.
Definition SoftContactConstraint.cpp:444
dynamics::PointMass * mPointMass1
First point mass.
Definition SoftContactConstraint.hpp:196
void setFrictionDirection(const Eigen::Vector3d &_dir)
Set first frictional direction.
Definition SoftContactConstraint.cpp:423
static double mErrorReductionParameter
Global constraint error redection parameter in the range of [0, 1].
Definition SoftContactConstraint.hpp:246
static double mMaxErrorReductionVelocity
Maximum error reduction velocity.
Definition SoftContactConstraint.hpp:249
void applyImpulse(double *_lambda) override
Apply computed constraint impulse to constrained skeletons.
Definition SoftContactConstraint.cpp:756
collision::SoftCollisionInfo * mSoftCollInfo
Soft collision information.
Definition SoftContactConstraint.hpp:206
void applyUnitImpulse(std::size_t _idx) override
Apply unit impulse to constraint space.
Definition SoftContactConstraint.cpp:604
void unexcite() override
Unexcite the constraint.
Definition SoftContactConstraint.cpp:746
void getRelVelocity(double *_vel)
Get change in relative velocity at contact point due to external impulse.
Definition SoftContactConstraint.cpp:912
common::aligned_vector< Eigen::Vector6d > mJacobians2
Local body jacobians for mBodyNode2.
Definition SoftContactConstraint.hpp:221
static double getMaxErrorReductionVelocity()
Get global error reduction parameter.
Definition SoftContactConstraint.cpp:396
static void setErrorReductionParameter(double _erp)
Set global error reduction parameter.
Definition SoftContactConstraint.cpp:355
dynamics::BodyNode * mBodyNode1
Fircst body node.
Definition SoftContactConstraint.hpp:184
Eigen::MatrixXd getTangentBasisMatrixODE(const Eigen::Vector3d &_n)
Definition SoftContactConstraint.cpp:1035
void excite() override
Excite the constraint.
Definition SoftContactConstraint.cpp:736
bool mActive
Definition SoftContactConstraint.hpp:239
static double getErrorAllowance()
Get global error reduction parameter.
Definition SoftContactConstraint.cpp:349
Eigen::Vector3d mBodyDirection1
Contact normal expressed in body frame of the first body node.
Definition SoftContactConstraint.hpp:224
double mRestitutionCoeff
Coefficient of restitution.
Definition SoftContactConstraint.hpp:215
static void setConstraintForceMixing(double _cfm)
Set global constraint force mixing parameter.
Definition SoftContactConstraint.cpp:402
static double computeRestitutionCoefficient(const dynamics::ShapeNode *shapeNode)
Definition SoftContactConstraint.cpp:961
void update() override
Update constraint using updated Skeleton's states.
Definition SoftContactConstraint.cpp:435
dynamics::BodyNode * mBodyNode2
Second body node.
Definition SoftContactConstraint.hpp:187
std::size_t mAppliedImpulseIndex
Index of applied impulse.
Definition SoftContactConstraint.hpp:233
static void setMaxErrorReductionVelocity(double _erv)
Set global error reduction parameter.
Definition SoftContactConstraint.cpp:381
const std::string & getType() const override
Returns a string representing the constraint type.
Definition SoftContactConstraint.cpp:321
static double mErrorAllowance
Global constraint error allowance.
Definition SoftContactConstraint.hpp:242
bool isActive() const override
Return true if this constraint is active.
Definition SoftContactConstraint.cpp:935
static double mConstraintForceMixing
Global constraint force mixing parameter in the range of [1e-9, 1].
Definition SoftContactConstraint.hpp:254
Eigen::Vector3d mFirstFrictionalDirection
First frictional direction.
Definition SoftContactConstraint.hpp:209
static void setErrorAllowance(double _allowance)
Set global error reduction parameter.
Definition SoftContactConstraint.cpp:334
static const std::string & getStaticType()
Returns constraint type for this class.
Definition SoftContactConstraint.cpp:327
void getVelocityChange(double *_vel, bool _withCfm) override
Get velocity change due to the uint impulse.
Definition SoftContactConstraint.cpp:689
static double computeFrictionCoefficient(const dynamics::ShapeNode *shapeNode)
Definition SoftContactConstraint.cpp:941
void updateFirstFrictionalDirection()
Definition SoftContactConstraint.cpp:1021
BodyNode class represents a single node of the skeleton.
Definition BodyNode.hpp:79
Definition PointMass.hpp:53
Definition ShapeNode.hpp:49
SoftBodyNode represent a soft body that has one deformable skin.
Definition SoftBodyNode.hpp:46
std::vector< _Tp, Eigen::aligned_allocator< _Tp > > aligned_vector
Definition Memory.hpp:71
std::shared_ptr< Skeleton > SkeletonPtr
Definition SmartPointer.hpp:60
Definition BulletCollisionDetector.cpp:60
Contact information.
Definition Contact.hpp:46
ConstraintInfo.
Definition ConstraintBase.hpp:50