DART  6.7.3
ServoMotorConstraint.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_SERVOMOTORCONSTRAINT_HPP_
34 #define DART_CONSTRAINT_SERVOMOTORCONSTRAINT_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 ServoMotorConstraint(dynamics::Joint* joint);
53 
55  virtual ~ServoMotorConstraint();
56 
57  //----------------------------------------------------------------------------
58  // Property settings
59  //----------------------------------------------------------------------------
60 
62  static void setConstraintForceMixing(double cfm);
63 
65  static double getConstraintForceMixing();
66 
67  //----------------------------------------------------------------------------
68  // Friendship
69  //----------------------------------------------------------------------------
70 
71  friend class ConstraintSolver;
72  friend class ConstrainedGroup;
73 
74 protected:
75  //----------------------------------------------------------------------------
76  // Constraint virtual functions
77  //----------------------------------------------------------------------------
78 
79  // Documentation inherited
80  void update() override;
81 
82  // Documentation inherited
83  void getInformation(ConstraintInfo* lcp) override;
84 
85  // Documentation inherited
86  void applyUnitImpulse(std::size_t index) override;
87 
88  // Documentation inherited
89  void getVelocityChange(double* delVel, bool withCfm) override;
90 
91  // Documentation inherited
92  void excite() override;
93 
94  // Documentation inherited
95  void unexcite() override;
96 
97  // Documentation inherited
98  void applyImpulse(double* lambda) override;
99 
100  // Documentation inherited
101  dynamics::SkeletonPtr getRootSkeleton() const override;
102 
103  // Documentation inherited
104  bool isActive() const override;
105 
106 private:
109 
112 
114  std::size_t mAppliedImpulseIndex;
115 
117  std::size_t mLifeTime[6];
118  // TODO(JS): Lifetime should be considered only when we use iterative lcp
119  // solver
120 
122  bool mActive[6];
123 
126 
128  double mOldX[6];
129 
131  double mUpperBound[6];
132 
134  double mLowerBound[6];
135 
139  static double mConstraintForceMixing;
140 };
141 
142 } // namespace constraint
143 } // namespace dart
144 
145 #endif // DART_CONSTRAINT_SERVOMOTORCONSTRAINT_HPP_
146 
std::size_t index
Definition: SkelParser.cpp:1617
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
Servo motor constraint.
Definition: ServoMotorConstraint.hpp:49
bool isActive() const override
Return true if this constraint is active.
Definition: ServoMotorConstraint.cpp:280
void getVelocityChange(double *delVel, bool withCfm) override
Get velocity change due to the uint impulse.
Definition: ServoMotorConstraint.cpp:211
double mUpperBound[6]
Definition: ServoMotorConstraint.hpp:131
dynamics::Joint * mJoint
Definition: ServoMotorConstraint.hpp:108
static double getConstraintForceMixing()
Get global constraint force mixing parameter.
Definition: ServoMotorConstraint.cpp:104
double mOldX[6]
Definition: ServoMotorConstraint.hpp:128
ServoMotorConstraint(dynamics::Joint *joint)
Constructor.
Definition: ServoMotorConstraint.cpp:52
static void setConstraintForceMixing(double cfm)
Set global constraint force mixing parameter.
Definition: ServoMotorConstraint.cpp:82
dynamics::BodyNode * mBodyNode
Definition: ServoMotorConstraint.hpp:111
void unexcite() override
Unexcite the constraint.
Definition: ServoMotorConstraint.cpp:248
static double mConstraintForceMixing
Global constraint force mixing parameter in the range of [1e-9, 1].
Definition: ServoMotorConstraint.hpp:139
void getInformation(ConstraintInfo *lcp) override
Fill LCP variables.
Definition: ServoMotorConstraint.cpp:155
void applyImpulse(double *lambda) override
Apply computed constraint impulse to constrained skeletons.
Definition: ServoMotorConstraint.cpp:254
double mLowerBound[6]
Definition: ServoMotorConstraint.hpp:134
void update() override
Update constraint using updated Skeleton's states.
Definition: ServoMotorConstraint.cpp:110
void excite() override
Excite the constraint.
Definition: ServoMotorConstraint.cpp:242
void applyUnitImpulse(std::size_t index) override
Apply unit impulse to constraint space.
Definition: ServoMotorConstraint.cpp:182
double mNegativeVelocityError[6]
Definition: ServoMotorConstraint.hpp:125
dynamics::SkeletonPtr getRootSkeleton() const override
Definition: ServoMotorConstraint.cpp:274
std::size_t mAppliedImpulseIndex
Index of applied impulse.
Definition: ServoMotorConstraint.hpp:114
bool mActive[6]
Definition: ServoMotorConstraint.hpp:122
virtual ~ServoMotorConstraint()
Destructor.
Definition: ServoMotorConstraint.cpp:77
std::size_t mLifeTime[6]
Definition: ServoMotorConstraint.hpp:117
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:78
class Joint
Definition: Joint.hpp:59
std::shared_ptr< Skeleton > SkeletonPtr
Definition: SmartPointer.hpp:60
Definition: BulletCollisionDetector.cpp:63
ConstraintInfo.
Definition: ConstraintBase.hpp:50