DART  6.10.1
MimicMotorConstraint.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_MIMICMOTORCONSTRAINT_HPP_
34 #define DART_CONSTRAINT_MIMICMOTORCONSTRAINT_HPP_
35 
37 
38 namespace dart {
39 
40 namespace dynamics {
41 class BodyNode;
42 class Joint;
43 } // namespace dynamics
44 
45 namespace constraint {
46 
49 {
50 public:
52  explicit MimicMotorConstraint(
53  dynamics::Joint* joint,
54  const dynamics::Joint* mimicJoint,
55  double multiplier = 1.0,
56  double offset = 0.0);
57 
59  ~MimicMotorConstraint() override;
60 
61  // Documentation inherited
62  const std::string& getType() const override;
63 
65  static const std::string& getStaticType();
66 
67  //----------------------------------------------------------------------------
68  // Property settings
69  //----------------------------------------------------------------------------
70 
72  static void setConstraintForceMixing(double cfm);
73 
75  static double getConstraintForceMixing();
76 
77  //----------------------------------------------------------------------------
78  // Friendship
79  //----------------------------------------------------------------------------
80 
81  friend class ConstraintSolver;
82  friend class ConstrainedGroup;
83 
84 protected:
85  //----------------------------------------------------------------------------
86  // Constraint virtual functions
87  //----------------------------------------------------------------------------
88 
89  // Documentation inherited
90  void update() override;
91 
92  // Documentation inherited
93  void getInformation(ConstraintInfo* lcp) override;
94 
95  // Documentation inherited
96  void applyUnitImpulse(std::size_t index) override;
97 
98  // Documentation inherited
99  void getVelocityChange(double* delVel, bool withCfm) override;
100 
101  // Documentation inherited
102  void excite() override;
103 
104  // Documentation inherited
105  void unexcite() override;
106 
107  // Documentation inherited
108  void applyImpulse(double* lambda) override;
109 
110  // Documentation inherited
111  dynamics::SkeletonPtr getRootSkeleton() const override;
112 
113  // Documentation inherited
114  bool isActive() const override;
115 
116 private:
119 
122 
125 
128 
130  std::size_t mAppliedImpulseIndex;
131 
133  std::size_t mLifeTime[6];
134  // TODO(JS): Lifetime should be considered only when we use iterative lcp
135  // solver
136 
138  bool mActive[6];
139 
142 
144  double mOldX[6];
145 
147  double mUpperBound[6];
148 
150  double mLowerBound[6];
151 
155  static double mConstraintForceMixing;
156 };
157 
158 } // namespace constraint
159 } // namespace dart
160 
161 #endif // DART_CONSTRAINT_MIMICMOTORCONSTRAINT_HPP_
std::size_t index
Definition: SkelParser.cpp:1672
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:57
Servo motor constraint.
Definition: MimicMotorConstraint.hpp:49
std::size_t mLifeTime[6]
Definition: MimicMotorConstraint.hpp:133
double mUpperBound[6]
Definition: MimicMotorConstraint.hpp:147
dynamics::BodyNode * mBodyNode
Definition: MimicMotorConstraint.hpp:127
~MimicMotorConstraint() override
Destructor.
Definition: MimicMotorConstraint.cpp:86
bool isActive() const override
Return true if this constraint is active.
Definition: MimicMotorConstraint.cpp:296
static double getConstraintForceMixing()
Get global constraint force mixing parameter.
Definition: MimicMotorConstraint.cpp:121
void getVelocityChange(double *delVel, bool withCfm) override
Get velocity change due to the uint impulse.
Definition: MimicMotorConstraint.cpp:227
const std::string & getType() const override
Returns a string representing the constraint type.
Definition: MimicMotorConstraint.cpp:92
double mOldX[6]
Definition: MimicMotorConstraint.hpp:144
std::size_t mAppliedImpulseIndex
Index of applied impulse.
Definition: MimicMotorConstraint.hpp:130
static const std::string & getStaticType()
Returns constraint type for this class.
Definition: MimicMotorConstraint.cpp:98
const dynamics::Joint * mMimicJoint
Definition: MimicMotorConstraint.hpp:121
MimicMotorConstraint(dynamics::Joint *joint, const dynamics::Joint *mimicJoint, double multiplier=1.0, double offset=0.0)
Constructor.
Definition: MimicMotorConstraint.cpp:52
double mMultiplier
Definition: MimicMotorConstraint.hpp:124
double mNegativeVelocityError[6]
Definition: MimicMotorConstraint.hpp:141
double mLowerBound[6]
Definition: MimicMotorConstraint.hpp:150
dynamics::Joint * mJoint
Definition: MimicMotorConstraint.hpp:118
static void setConstraintForceMixing(double cfm)
Set global constraint force mixing parameter.
Definition: MimicMotorConstraint.cpp:105
void update() override
Update constraint using updated Skeleton's states.
Definition: MimicMotorConstraint.cpp:127
void unexcite() override
Unexcite the constraint.
Definition: MimicMotorConstraint.cpp:264
static double mConstraintForceMixing
Global constraint force mixing parameter in the range of [1e-9, 1].
Definition: MimicMotorConstraint.hpp:155
bool mActive[6]
Definition: MimicMotorConstraint.hpp:138
void getInformation(ConstraintInfo *lcp) override
Fill LCP variables.
Definition: MimicMotorConstraint.cpp:171
void applyImpulse(double *lambda) override
Apply computed constraint impulse to constrained skeletons.
Definition: MimicMotorConstraint.cpp:270
void applyUnitImpulse(std::size_t index) override
Apply unit impulse to constraint space.
Definition: MimicMotorConstraint.cpp:198
dynamics::SkeletonPtr getRootSkeleton() const override
Definition: MimicMotorConstraint.cpp:290
void excite() override
Excite the constraint.
Definition: MimicMotorConstraint.cpp:258
double mOffset
Definition: MimicMotorConstraint.hpp:124
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:79
class Joint
Definition: Joint.hpp:60
std::shared_ptr< Skeleton > SkeletonPtr
Definition: SmartPointer.hpp:60
Definition: BulletCollisionDetector.cpp:65
ConstraintInfo.
Definition: ConstraintBase.hpp:50