DART 6.12.2
Loading...
Searching...
No Matches
JointConstraint.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_JOINTCONSTRAINT_HPP_
34#define DART_CONSTRAINT_JOINTCONSTRAINT_HPP_
35
36#include <Eigen/Dense>
37
39
40namespace dart {
41
42namespace dynamics {
43class BodyNode;
44class Joint;
45} // namespace dynamics
46
47namespace constraint {
48
49// TODO(JS): Merge JointCoulombFrictionConstraint into this class
50
54{
55public:
57 explicit JointConstraint(dynamics::Joint* joint);
58
60 ~JointConstraint() override = default;
61
62 // Documentation inherited
63 const std::string& getType() const override;
64
66 static const std::string& getStaticType();
67
68 //----------------------------------------------------------------------------
69 // Property settings
70 //----------------------------------------------------------------------------
71
73 static void setErrorAllowance(double allowance);
74
76 static double getErrorAllowance();
77
79 static void setErrorReductionParameter(double erp);
80
82 static double getErrorReductionParameter();
83
85 static void setMaxErrorReductionVelocity(double erv);
86
88 static double getMaxErrorReductionVelocity();
89
91 static void setConstraintForceMixing(double cfm);
92
94 static double getConstraintForceMixing();
95
96 //----------------------------------------------------------------------------
97 // Friendship
98 //----------------------------------------------------------------------------
99
100 friend class ConstraintSolver;
101 friend class ConstrainedGroup;
102
103protected:
104 //----------------------------------------------------------------------------
105 // Constraint virtual functions
106 //----------------------------------------------------------------------------
107
108 // Documentation inherited
109 void update() override;
110
111 // Documentation inherited
112 void getInformation(ConstraintInfo* lcp) override;
113
114 // Documentation inherited
115 void applyUnitImpulse(std::size_t index) override;
116
117 // Documentation inherited
118 void getVelocityChange(double* delVel, bool withCfm) override;
119
120 // Documentation inherited
121 void excite() override;
122
123 // Documentation inherited
124 void unexcite() override;
125
126 // Documentation inherited
127 void applyImpulse(double* lambda) override;
128
129 // Documentation inherited
130 dynamics::SkeletonPtr getRootSkeleton() const override;
131
132 // Documentation inherited
133 bool isActive() const override;
134
135private:
138
141
144
146 Eigen::Matrix<std::size_t, 6, 1> mLifeTime;
147
149 Eigen::Matrix<bool, 6, 1> mActive;
150
152 Eigen::Matrix<double, 6, 1> mDesiredVelocityChange;
153
155 Eigen::Matrix<double, 6, 1> mOldX;
156
158 Eigen::Matrix<double, 6, 1> mImpulseUpperBound;
159
161 Eigen::Matrix<double, 6, 1> mImpulseLowerBound;
162
164 static double mErrorAllowance;
165
169
172
177};
178
179} // namespace constraint
180} // namespace dart
181
182#endif // DART_CONSTRAINT_JOINTCONSTRAINT_HPP_
std::size_t index
Definition SkelParser.cpp:1672
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
JointConstraint handles multiple constraints that are defined in the joint space, such as joint posit...
Definition JointConstraint.hpp:54
void getVelocityChange(double *delVel, bool withCfm) override
Get velocity change due to the uint impulse.
Definition JointConstraint.cpp:472
void applyImpulse(double *lambda) override
Apply computed constraint impulse to constrained skeletons.
Definition JointConstraint.cpp:517
static const std::string & getStaticType()
Returns constraint type for this class.
Definition JointConstraint.cpp:76
Eigen::Matrix< double, 6, 1 > mDesiredVelocityChange
The desired delta velocity to satisfy the joint limit constraint.
Definition JointConstraint.hpp:152
static double getErrorReductionParameter()
Get global error reduction parameter.
Definition JointConstraint.cpp:124
static void setErrorAllowance(double allowance)
Set global error reduction parameter.
Definition JointConstraint.cpp:83
static double mErrorReductionParameter
Global constraint error redection parameter in the range of [0, 1].
Definition JointConstraint.hpp:168
static double mMaxErrorReductionVelocity
Maximum error reduction velocity.
Definition JointConstraint.hpp:171
dynamics::Joint * mJoint
The Joint that this constraint is associated with.
Definition JointConstraint.hpp:137
static double mConstraintForceMixing
Global constraint force mixing parameter in the range of [1e-9, 1].
Definition JointConstraint.hpp:176
static double getMaxErrorReductionVelocity()
Get global error reduction parameter.
Definition JointConstraint.cpp:145
static void setConstraintForceMixing(double cfm)
Set global constraint force mixing parameter.
Definition JointConstraint.cpp:151
Eigen::Matrix< double, 6, 1 > mImpulseLowerBound
Lower limit of the constraint impulse.
Definition JointConstraint.hpp:161
dynamics::BodyNode * mBodyNode
The child BodyNode of the Joint that this constraint is associated with.
Definition JointConstraint.hpp:140
void unexcite() override
Unexcite the constraint.
Definition JointConstraint.cpp:511
Eigen::Matrix< double, 6, 1 > mOldX
Constraint impulse of the previous step.
Definition JointConstraint.hpp:155
void update() override
Update constraint using updated Skeleton's states.
Definition JointConstraint.cpp:172
std::size_t mAppliedImpulseIndex
Index of applied impulse.
Definition JointConstraint.hpp:143
Eigen::Matrix< std::size_t, 6, 1 > mLifeTime
Life time of constraint of each DOF.
Definition JointConstraint.hpp:146
static double getConstraintForceMixing()
Get global constraint force mixing parameter.
Definition JointConstraint.cpp:166
static double mErrorAllowance
Global constraint error allowance.
Definition JointConstraint.hpp:164
void excite() override
Excite the constraint.
Definition JointConstraint.cpp:505
static void setMaxErrorReductionVelocity(double erv)
Set global error reduction parameter.
Definition JointConstraint.cpp:130
Eigen::Matrix< double, 6, 1 > mImpulseUpperBound
Upper limit of the constraint impulse.
Definition JointConstraint.hpp:158
void getInformation(ConstraintInfo *lcp) override
Fill LCP variables.
Definition JointConstraint.cpp:397
void applyUnitImpulse(std::size_t index) override
Apply unit impulse to constraint space.
Definition JointConstraint.cpp:441
bool isActive() const override
Return true if this constraint is active.
Definition JointConstraint.cpp:544
~JointConstraint() override=default
Destructor.
dynamics::SkeletonPtr getRootSkeleton() const override
Definition JointConstraint.cpp:538
const std::string & getType() const override
Returns a string representing the constraint type.
Definition JointConstraint.cpp:70
static double getErrorAllowance()
Get global error reduction parameter.
Definition JointConstraint.cpp:98
static void setErrorReductionParameter(double erp)
Set global error reduction parameter.
Definition JointConstraint.cpp:104
Eigen::Matrix< bool, 6, 1 > mActive
Whether any of the joint contraint is active of each joint.
Definition JointConstraint.hpp:149
BodyNode class represents a single node of the skeleton.
Definition BodyNode.hpp:79
class Joint
Definition Joint.hpp:61
std::shared_ptr< Skeleton > SkeletonPtr
Definition SmartPointer.hpp:60
Definition BulletCollisionDetector.cpp:60
ConstraintInfo.
Definition ConstraintBase.hpp:50