DART 6.13.2
Loading...
Searching...
No Matches
ContactSurface.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2022, 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_CONTACTSURFACE_HPP_
34#define DART_CONSTRAINT_CONTACTSURFACE_HPP_
35
36#include <Eigen/Core>
37
41
42#define DART_RESTITUTION_COEFF_THRESHOLD 1e-3
43#define DART_FRICTION_COEFF_THRESHOLD 1e-3
44#define DART_BOUNCING_VELOCITY_THRESHOLD 1e-1
45#define DART_MAX_BOUNCING_VELOCITY 1e+2
46#define DART_CONTACT_CONSTRAINT_EPSILON_SQUARED 1e-12
47
48namespace dart {
49namespace constraint {
50
51constexpr double DART_DEFAULT_FRICTION_COEFF = 1.0;
52constexpr double DART_DEFAULT_RESTITUTION_COEFF = 0.0;
53// Slip compliance is combined through addition,
54// so set to half the global default value
55constexpr double DART_DEFAULT_SLIP_COMPLIANCE = 0.0;
56const Eigen::Vector3d DART_DEFAULT_FRICTION_DIR = Eigen::Vector3d::UnitZ();
58 = Eigen::Vector3d::Zero();
59
62{
65
68
71
74
77
80
87
88private:
95#if defined(__clang__)
96 #pragma clang diagnostic push
97 #pragma clang diagnostic ignored "-Wunused-private-field"
98#endif
99 void* mExtraData{nullptr};
100#if defined(__clang__)
101 #pragma clang diagnostic pop
102#endif
103};
104
108{
109public:
115 explicit ContactSurfaceHandler(ContactSurfaceHandlerPtr parent = nullptr);
116
117 virtual ~ContactSurfaceHandler() = default;
118
125 const collision::Contact& contact,
126 size_t numContactsOnCollisionObject) const;
127
131 collision::Contact& contact,
132 size_t numContactsOnCollisionObject,
133 double timeStep) const;
134
137
140
141 friend class ConstraintSolver;
142
143protected:
146};
147
152{
153public:
154 virtual ~DefaultContactSurfaceHandler() = default;
155
156 // Documentation inherited
158 const collision::Contact& contact,
159 size_t numContactsOnCollisionObject) const override;
160
161 // Documentation inherited
163 collision::Contact& contact,
164 size_t numContactsOnCollisionObject,
165 double timeStep) const override;
166
167protected:
168 static double computeFrictionCoefficient(
169 const dynamics::ShapeNode* shapeNode);
171 const dynamics::ShapeNode* shapeNode);
173 const dynamics::ShapeNode* shapeNode);
174 static double computePrimarySlipCompliance(
175 const dynamics::ShapeNode* shapeNode);
176 static double computeSecondarySlipCompliance(
177 const dynamics::ShapeNode* shapeNode);
178 static Eigen::Vector3d computeWorldFirstFrictionDir(
179 const dynamics::ShapeNode* shapenode);
180 static double computeRestitutionCoefficient(
181 const dynamics::ShapeNode* shapeNode);
182
183 friend class ContactConstraint;
184};
185
186} // namespace constraint
187} // namespace dart
188
189#endif // DART_CONSTRAINT_CONTACTSURFACE_HPP_
ConstraintSolver manages constraints and computes constraint impulses.
Definition ConstraintSolver.hpp:57
ContactConstraint represents a contact constraint between two bodies.
Definition ContactConstraint.hpp:52
Class used to determine the properties of a contact constraint based on the two colliding bodies and ...
Definition ContactSurface.hpp:108
void setParent(ContactSurfaceHandlerPtr parent)
Set the optional parent handler (ignored if parent.get() == this)
Definition ContactSurface.cpp:59
ContactSurfaceHandlerPtr mParent
The optional parent handler.
Definition ContactSurface.hpp:145
virtual ContactSurfaceParams createParams(const collision::Contact &contact, size_t numContactsOnCollisionObject) const
Create parameters of the contact constraint.
Definition ContactSurface.cpp:68
ContactSurfaceHandlerPtr getParent()
Get the optional parent handler (nullptr if none is set)
Definition ContactSurface.cpp:53
virtual ContactConstraintPtr createConstraint(collision::Contact &contact, size_t numContactsOnCollisionObject, double timeStep) const
Create the constraint that represents contact between two collision objects.
Definition ContactSurface.cpp:78
Default contact surface handler.
Definition ContactSurface.hpp:152
static Eigen::Vector3d computeWorldFirstFrictionDir(const dynamics::ShapeNode *shapenode)
Definition ContactSurface.cpp:320
ContactConstraintPtr createConstraint(collision::Contact &contact, size_t numContactsOnCollisionObject, double timeStep) const override
Create the constraint that represents contact between two collision objects.
Definition ContactSurface.cpp:187
static double computeRestitutionCoefficient(const dynamics::ShapeNode *shapeNode)
Definition ContactSurface.cpp:349
static double computeSecondarySlipCompliance(const dynamics::ShapeNode *shapeNode)
Definition ContactSurface.cpp:294
ContactSurfaceParams createParams(const collision::Contact &contact, size_t numContactsOnCollisionObject) const override
Create parameters of the contact constraint.
Definition ContactSurface.cpp:88
static double computePrimaryFrictionCoefficient(const dynamics::ShapeNode *shapeNode)
Definition ContactSurface.cpp:227
static double computePrimarySlipCompliance(const dynamics::ShapeNode *shapeNode)
Definition ContactSurface.cpp:269
static double computeSecondaryFrictionCoefficient(const dynamics::ShapeNode *shapeNode)
Definition ContactSurface.cpp:248
static double computeFrictionCoefficient(const dynamics::ShapeNode *shapeNode)
Definition ContactSurface.cpp:206
Definition ShapeNode.hpp:49
constexpr double DART_DEFAULT_RESTITUTION_COEFF
Definition ContactSurface.hpp:52
std::shared_ptr< ContactSurfaceHandler > ContactSurfaceHandlerPtr
Definition SmartPointer.hpp:48
std::shared_ptr< ContactConstraint > ContactConstraintPtr
Definition SmartPointer.hpp:47
constexpr double DART_DEFAULT_FRICTION_COEFF
Definition ContactSurface.hpp:51
const Eigen::Vector3d DART_DEFAULT_CONTACT_SURFACE_MOTION_VELOCITY
Definition ContactSurface.hpp:58
constexpr double DART_DEFAULT_SLIP_COMPLIANCE
Definition ContactSurface.hpp:55
const Eigen::Vector3d DART_DEFAULT_FRICTION_DIR
Definition ContactSurface.hpp:56
Definition BulletCollisionDetector.cpp:60
Contact information.
Definition Contact.hpp:46
Computed parameters of the contact surface.
Definition ContactSurface.hpp:62
void * mExtraData
Used for future-compatibility.
Definition ContactSurface.hpp:99
Eigen::Vector3d mContactSurfaceMotionVelocity
Velocity of the contact independent of friction x = vel.
Definition ContactSurface.hpp:85
Eigen::Vector3d mFirstFrictionalDirection
First frictional direction (in world frame)
Definition ContactSurface.hpp:79
double mRestitutionCoeff
Coefficient of restitution.
Definition ContactSurface.hpp:70
double mSecondarySlipCompliance
Secondary Coefficient of Slip Compliance.
Definition ContactSurface.hpp:76
double mSecondaryFrictionCoeff
Secondary Coefficient of Friction.
Definition ContactSurface.hpp:67
double mPrimarySlipCompliance
Primary Coefficient of Slip Compliance.
Definition ContactSurface.hpp:73
double mPrimaryFrictionCoeff
Primary Coefficient of Friction.
Definition ContactSurface.hpp:64