DART 6.7.3
Loading...
Searching...
No Matches
SoftContactConstraint.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2019, 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
37
40
41namespace dart {
42
43namespace collision{
44class SoftCollisionInfo;
45} // namespace collision
46
47namespace dynamics {
48class BodyNode;
49class SoftBodyNode;
50class PointMass;
51class Skeleton;
52} // namespace dynamics
53
54namespace constraint {
55
58{
59public:
61 SoftContactConstraint(collision::Contact& _contact, double _timeStep);
62
64 virtual ~SoftContactConstraint();
65
66 //----------------------------------------------------------------------------
67 // Property settings
68 //----------------------------------------------------------------------------
69
71 static void setErrorAllowance(double _allowance);
72
74 static double getErrorAllowance();
75
77 static void setErrorReductionParameter(double _erp);
78
80 static double getErrorReductionParameter();
81
83 static void setMaxErrorReductionVelocity(double _erv);
84
86 static double getMaxErrorReductionVelocity();
87
89 static void setConstraintForceMixing(double _cfm);
90
92 static double getConstraintForceMixing();
93
95 void setFrictionDirection(const Eigen::Vector3d& _dir);
96
98 const Eigen::Vector3d& getFrictionDirection1() const;
99
100 //----------------------------------------------------------------------------
101 // Friendship
102 //----------------------------------------------------------------------------
103
104 friend class ConstraintSolver;
105 friend class ConstrainedGroup;
106
107protected:
108 //----------------------------------------------------------------------------
109 // Constraint virtual functions
110 //----------------------------------------------------------------------------
111
112 // Documentation inherited
113 void update() override;
114
115 // Documentation inherited
116 void getInformation(ConstraintInfo* _info) override;
117
118 // Documentation inherited
119 void applyUnitImpulse(std::size_t _idx) override;
120
121 // Documentation inherited
122 void getVelocityChange(double* _vel, bool _withCfm) override;
123
124 // Documentation inherited
125 void excite() override;
126
127 // Documentation inherited
128 void unexcite() override;
129
130 // Documentation inherited
131 void applyImpulse(double* _lambda) override;
132
133 // Documentation inherited
134 dynamics::SkeletonPtr getRootSkeleton() const override;
135
136 // Documentation inherited
137 void uniteSkeletons() override;
138
139 // Documentation inherited
140 bool isActive() const override;
141
142private:
146 void getRelVelocity(double* _vel);
147
150
152 Eigen::MatrixXd getTangentBasisMatrixODE(const Eigen::Vector3d& _n);
153
157 dynamics::SoftBodyNode* _softBodyNode,
158 const Eigen::Vector3d& _point,
159 int _faceId) const;
160
165 const dynamics::SoftBodyNode* _softBodyNode,
166 const Eigen::Vector3d& _point,
167 int _faceId) const;
168
169private:
171 double mTimeStep;
172
175
178
181
184
187
190
191 // TODO(JS): For now, there is only one contact per contact constraint
193 std::vector<collision::Contact*> mContacts;
194
196 collision::SoftCollisionInfo* mSoftCollInfo;
197
200
203
206
209
212
214 Eigen::Vector3d mBodyDirection1;
215
217 Eigen::Vector3d mBodyDirection2;
218
221
224
227
230
232 static double mErrorAllowance;
233
237
240
245};
246
247} // namespace constraint
248} // namespace dart
249
250#endif // DART_CONSTRAINT_SOFTCONTACTCONSTRAINT_HPP_
251
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
SoftContactConstraint represents a contact constraint between two bodies.
Definition SoftContactConstraint.hpp:58
const Eigen::Vector3d & getFrictionDirection1() const
Get first frictional direction.
Definition SoftContactConstraint.cpp:402
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:1050
static double getErrorReductionParameter()
Get global error reduction parameter.
Definition SoftContactConstraint.cpp:342
dynamics::PointMass * mPointMass2
Second point mass.
Definition SoftContactConstraint.hpp:189
Eigen::Vector3d mBodyDirection2
Contact normal expressed in body frame of the second body node.
Definition SoftContactConstraint.hpp:217
bool mIsBounceOn
Definition SoftContactConstraint.hpp:226
dynamics::SoftBodyNode * mSoftBodyNode1
First soft body node.
Definition SoftContactConstraint.hpp:180
dynamics::SoftBodyNode * mSoftBodyNode2
Second soft body node.
Definition SoftContactConstraint.hpp:183
dynamics::SkeletonPtr getRootSkeleton() const override
Definition SoftContactConstraint.cpp:912
std::vector< collision::Contact * > mContacts
Contacts between mBodyNode1 and mBodyNode2.
Definition SoftContactConstraint.hpp:193
static double getConstraintForceMixing()
Get global constraint force mixing parameter.
Definition SoftContactConstraint.cpp:389
virtual ~SoftContactConstraint()
Destructor.
Definition SoftContactConstraint.cpp:296
void uniteSkeletons() override
Definition SoftContactConstraint.cpp:921
common::aligned_vector< Eigen::Vector6d > mJacobians1
Local body jacobians for mBodyNode1.
Definition SoftContactConstraint.hpp:208
bool mIsFrictionOn
Definition SoftContactConstraint.hpp:220
double mFrictionCoeff
Coefficient of Friction.
Definition SoftContactConstraint.hpp:202
double mTimeStep
Time step.
Definition SoftContactConstraint.hpp:171
void getInformation(ConstraintInfo *_info) override
Fill LCP variables.
Definition SoftContactConstraint.cpp:417
dynamics::PointMass * mPointMass1
First point mass.
Definition SoftContactConstraint.hpp:186
void setFrictionDirection(const Eigen::Vector3d &_dir)
Set first frictional direction.
Definition SoftContactConstraint.cpp:395
static double mErrorReductionParameter
Global constraint error redection parameter in the range of [0, 1].
Definition SoftContactConstraint.hpp:236
static double mMaxErrorReductionVelocity
Maximum error reduction velocity.
Definition SoftContactConstraint.hpp:239
void applyImpulse(double *_lambda) override
Apply computed constraint impulse to constrained skeletons.
Definition SoftContactConstraint.cpp:728
collision::SoftCollisionInfo * mSoftCollInfo
Soft collision information.
Definition SoftContactConstraint.hpp:196
void applyUnitImpulse(std::size_t _idx) override
Apply unit impulse to constraint space.
Definition SoftContactConstraint.cpp:576
void unexcite() override
Unexcite the constraint.
Definition SoftContactConstraint.cpp:718
void getRelVelocity(double *_vel)
Get change in relative velocity at contact point due to external impulse.
Definition SoftContactConstraint.cpp:883
common::aligned_vector< Eigen::Vector6d > mJacobians2
Local body jacobians for mBodyNode2.
Definition SoftContactConstraint.hpp:211
static double getMaxErrorReductionVelocity()
Get global error reduction parameter.
Definition SoftContactConstraint.cpp:363
static void setErrorReductionParameter(double _erp)
Set global error reduction parameter.
Definition SoftContactConstraint.cpp:322
dynamics::BodyNode * mBodyNode1
Fircst body node.
Definition SoftContactConstraint.hpp:174
Eigen::MatrixXd getTangentBasisMatrixODE(const Eigen::Vector3d &_n)
Definition SoftContactConstraint.cpp:965
void excite() override
Excite the constraint.
Definition SoftContactConstraint.cpp:708
bool mActive
Definition SoftContactConstraint.hpp:229
static double getErrorAllowance()
Get global error reduction parameter.
Definition SoftContactConstraint.cpp:316
Eigen::Vector3d mBodyDirection1
Contact normal expressed in body frame of the first body node.
Definition SoftContactConstraint.hpp:214
double mRestitutionCoeff
Coefficient of restitution.
Definition SoftContactConstraint.hpp:205
static void setConstraintForceMixing(double _cfm)
Set global constraint force mixing parameter.
Definition SoftContactConstraint.cpp:369
void update() override
Update constraint using updated Skeleton's states.
Definition SoftContactConstraint.cpp:408
dynamics::BodyNode * mBodyNode2
Second body node.
Definition SoftContactConstraint.hpp:177
std::size_t mAppliedImpulseIndex
Index of applied impulse.
Definition SoftContactConstraint.hpp:223
static void setMaxErrorReductionVelocity(double _erv)
Set global error reduction parameter.
Definition SoftContactConstraint.cpp:348
static double mErrorAllowance
Global constraint error allowance.
Definition SoftContactConstraint.hpp:232
bool isActive() const override
Return true if this constraint is active.
Definition SoftContactConstraint.cpp:906
static double mConstraintForceMixing
Global constraint force mixing parameter in the range of [1e-9, 1].
Definition SoftContactConstraint.hpp:244
Eigen::Vector3d mFirstFrictionalDirection
First frictional direction.
Definition SoftContactConstraint.hpp:199
static void setErrorAllowance(double _allowance)
Set global error reduction parameter.
Definition SoftContactConstraint.cpp:301
void getVelocityChange(double *_vel, bool _withCfm) override
Get velocity change due to the uint impulse.
Definition SoftContactConstraint.cpp:661
void updateFirstFrictionalDirection()
Definition SoftContactConstraint.cpp:952
BodyNode class represents a single node of the skeleton.
Definition BodyNode.hpp:78
Definition PointMass.hpp:51
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: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