DART 6.12.2
Loading...
Searching...
No Matches
DegreeOfFreedom.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_DYNAMICS_DEGREEOFFREEDOM_HPP_
34#define DART_DYNAMICS_DEGREEOFFREEDOM_HPP_
35
36#include <memory>
37#include <string>
38
39#include <Eigen/Core>
40
44
45namespace dart {
46namespace dynamics {
47
48class Skeleton;
49class Joint;
50class BodyNode;
51
55class DegreeOfFreedom : public virtual common::Subject
56{
57public:
58 friend class Joint;
59 template <class>
60 friend class GenericJoint;
61 friend class Skeleton;
62
64
71 const std::string& setName(
72 const std::string& _name, bool _preserveName = true);
73
89 const std::string& getName() const;
90
95 void preserveName(bool _preserve);
96
98 bool isNamePreserved() const;
99
101 std::size_t getIndexInSkeleton() const;
102
104 std::size_t getIndexInTree() const;
105
107 std::size_t getIndexInJoint() const;
108
110 std::size_t getTreeIndex() const;
111
112 //----------------------------------------------------------------------------
114 //----------------------------------------------------------------------------
115
117 void setCommand(double _command);
118
120 double getCommand() const;
121
123 void resetCommand();
124
126
127 //----------------------------------------------------------------------------
129 //----------------------------------------------------------------------------
130
132 void setPosition(double _position);
133
135 double getPosition() const;
136
138 void setPositionLimits(double _lowerLimit, double _upperLimit);
139
141 void setPositionLimits(const std::pair<double, double>& _limits);
142
144 std::pair<double, double> getPositionLimits() const;
145
147 void setPositionLowerLimit(double _limit);
148
150 double getPositionLowerLimit() const;
151
153 void setPositionUpperLimit(double _limit);
154
156 double getPositionUpperLimit() const;
157
162 bool isCyclic() const;
163
165 bool hasPositionLimit() const;
166
168 void resetPosition();
169
171 void setInitialPosition(double _initial);
172
174 double getInitialPosition() const;
175
177
178 //----------------------------------------------------------------------------
180 //----------------------------------------------------------------------------
181
183 void setVelocity(double _velocity);
184
186 double getVelocity() const;
187
189 void setVelocityLimits(double _lowerLimit, double _upperLimit);
190
192 void setVelocityLimits(const std::pair<double, double>& _limits);
193
195 std::pair<double, double> getVelocityLimits() const;
196
198 void setVelocityLowerLimit(double _limit);
199
201 double getVelocityLowerLimit() const;
202
204 void setVelocityUpperLimit(double _limit);
205
207 double getVelocityUpperLimit() const;
208
210 void resetVelocity();
211
213 void setInitialVelocity(double _initial);
214
216 double getInitialVelocity() const;
217
219
220 //----------------------------------------------------------------------------
222 //----------------------------------------------------------------------------
223
225 void setAcceleration(double _acceleration);
226
228 double getAcceleration() const;
229
231 void resetAcceleration();
232
234 void setAccelerationLimits(double _lowerLimit, double _upperLimit);
235
237 void setAccelerationLimits(const std::pair<double, double>& _limits);
238
240 std::pair<double, double> getAccelerationLimits() const;
241
243 void setAccelerationLowerLimit(double _limit);
244
246 double getAccelerationLowerLimit() const;
247
249 void setAccelerationUpperLimit(double _limit);
250
252 double getAccelerationUpperLimit() const;
253
255
256 //----------------------------------------------------------------------------
258 //----------------------------------------------------------------------------
259
261 void setForce(double _force);
262
264 double getForce() const;
265
267 void resetForce();
268
270 void setForceLimits(double _lowerLimit, double _upperLimit);
271
273 void setForceLimits(const std::pair<double, double>& _limits);
274
276 std::pair<double, double> getForceLimits() const;
277
279 void setForceLowerLimit(double _limit);
280
282 double getForceLowerLimit() const;
283
285 void setForceUpperLimit(double _limit);
286
288 double getForceUpperLimit() const;
289
291
292 //----------------------------------------------------------------------------
294 //----------------------------------------------------------------------------
295
297 void setVelocityChange(double _velocityChange);
298
300 double getVelocityChange() const;
301
303 void resetVelocityChange();
304
306
307 //----------------------------------------------------------------------------
309 //----------------------------------------------------------------------------
310
312 void setConstraintImpulse(double _impulse);
313
315 double getConstraintImpulse() const;
316
319
321
322 //----------------------------------------------------------------------------
324 //----------------------------------------------------------------------------
325
327 void setSpringStiffness(double _k);
328
330 double getSpringStiffness() const;
331
333 void setRestPosition(double _q0);
334
336 double getRestPosition() const;
337
340 void setDampingCoefficient(double _coeff);
341
344 double getDampingCoefficient() const;
345
347 void setCoulombFriction(double _friction);
348
350 double getCoulombFriction() const;
351
353
354 //----------------------------------------------------------------------------
356 //----------------------------------------------------------------------------
357
359 Joint* getJoint();
360
362 const Joint* getJoint() const;
363
366
369
372
374 const BodyNode* getChildBodyNode() const;
375
378
380 const BodyNode* getParentBodyNode() const;
381
383
384protected:
387 DegreeOfFreedom(Joint* _joint, std::size_t _indexInJoint);
388
393 std::size_t mIndexInJoint;
394
396 std::size_t mIndexInSkeleton;
397
399 std::size_t mIndexInTree;
400
403 // Note that we do not need to store BodyNode or Skeleton, because we can
404 // access them through this joint pointer. Moreover, we never need to check
405 // whether mJoint is nullptr, because only Joints are allowed to create a
406 // DegreeOfFreedom and every DegreeOfFreedom is deleted when its Joint is
407 // destructed.
408};
410
411} // namespace dynamics
412} // namespace dart
413
414#endif // DART_DYNAMICS_DEGREEOFFREEDOM_HPP_
#define DART_DECLARE_CLASS_WITH_VIRTUAL_BASE_END
Definition ClassWithVirtualBase.hpp:44
#define DART_DECLARE_CLASS_WITH_VIRTUAL_BASE_BEGIN
Definition ClassWithVirtualBase.hpp:43
bool * preserveName
Definition SkelParser.cpp:1696
The Subject class is a base class for any object that wants to report when it gets destroyed.
Definition Subject.hpp:58
BodyNode class represents a single node of the skeleton.
Definition BodyNode.hpp:79
DegreeOfFreedom class is a proxy class for accessing single degrees of freedom (aka generalized coord...
Definition DegreeOfFreedom.hpp:56
double getDampingCoefficient() const
Get coefficient of damping (viscous friction) force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:463
void resetForce()
Set the generalized force of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:348
void setAccelerationLimits(double _lowerLimit, double _upperLimit)
Set the acceleration limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:290
void setVelocity(double _velocity)
Set the velocity of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:197
void setAccelerationUpperLimit(double _limit)
Set the upper acceleration limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:324
bool isCyclic() const
Get whether this DOF is cyclic.
Definition DegreeOfFreedom.cpp:173
void resetPosition()
Set the position of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:179
double getForceUpperLimit() const
Get the upper generalized force limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:391
double getPosition() const
Get the position of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:115
void resetConstraintImpulse()
Set the constraint impulse of this generalized coordinate to zero.
Definition DegreeOfFreedom.cpp:427
void setAcceleration(double _acceleration)
Set the acceleration of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:272
BodyNode * getChildBodyNode()
Get the BodyNode downstream of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:505
void setForce(double _force)
Set the generalized force of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:336
double getCoulombFriction() const
Get Coulomb friction force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:475
DegreeOfFreedom(const DegreeOfFreedom &)=delete
void setCoulombFriction(double _friction)
Set Coulomb friction force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:469
std::size_t getIndexInTree() const
Get this DegreeOfFreedom's index within its tree.
Definition DegreeOfFreedom.cpp:73
std::size_t getIndexInSkeleton() const
Get this DegreeOfFreedom's index within its Skeleton.
Definition DegreeOfFreedom.cpp:67
double getForce() const
Get the generalized force of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:342
Joint * getJoint()
Get the Joint that this DegreeOfFreedom belongs to.
Definition DegreeOfFreedom.cpp:481
std::size_t getTreeIndex() const
Get the index of the tree that this DegreeOfFreedom belongs to.
Definition DegreeOfFreedom.cpp:85
std::pair< double, double > getVelocityLimits() const
Get the velocity limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:229
const std::string & getName() const
Get the name of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:49
void resetCommand()
Set the command of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:103
bool hasPositionLimit() const
Get whether the position of this DegreeOfFreedom has limits.
Definition DegreeOfFreedom.cpp:167
std::pair< double, double > getForceLimits() const
Get the generalized force limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:367
std::size_t mIndexInTree
Index of this DegreeOfFreedom within its tree.
Definition DegreeOfFreedom.hpp:399
void setDampingCoefficient(double _coeff)
Set coefficient of damping (viscous friction) force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:457
double getAcceleration() const
Get the acceleration of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:278
void setRestPosition(double _q0)
Set rest position for the spring force of this generalized coordinate.
Definition DegreeOfFreedom.cpp:445
double getRestPosition() const
Get rest position for the spring force of this generalized coordinate.
Definition DegreeOfFreedom.cpp:451
std::size_t getIndexInJoint() const
Get this DegreeOfFreedom's index within its Joint.
Definition DegreeOfFreedom.cpp:79
void setVelocityLowerLimit(double _limit)
Set the lower velocity limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:236
void setAccelerationLowerLimit(double _limit)
Set the lower acceleration limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:312
void setSpringStiffness(double _k)
Set stiffness of the spring force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:433
void setCommand(double _command)
Set the command of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:91
double getAccelerationLowerLimit() const
Get the lower acceleration limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:318
double getVelocityUpperLimit() const
Get the upper Velocity limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:254
std::pair< double, double > getAccelerationLimits() const
Get the acceleration limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:305
double getVelocityChange() const
Get the velocity change of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:403
double getSpringStiffness() const
Get stiffness of the spring force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:439
void setPositionLimits(double _lowerLimit, double _upperLimit)
Set the position limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:121
void setVelocityUpperLimit(double _limit)
Set the upper velocity limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:248
void setInitialPosition(double _initial)
Change the position that resetPosition() will give to this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:185
BodyNode * getParentBodyNode()
Get the BodyNode upstream of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:517
double getInitialVelocity() const
Get the velocity that resetVelocity() will give to this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:266
void setForceLimits(double _lowerLimit, double _upperLimit)
Set the generalized force limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:354
double getCommand() const
Get the command of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:97
double getVelocityLowerLimit() const
Get the lower velocity limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:242
double getPositionLowerLimit() const
Get the lower position limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:149
std::pair< double, double > getPositionLimits() const
Get the position limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:135
double getAccelerationUpperLimit() const
Get the upper acceleration limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:330
double getConstraintImpulse() const
Get the constraint impulse of this generalized coordinate.
Definition DegreeOfFreedom.cpp:421
void setVelocityChange(double _velocityChange)
Set the velocity change of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:397
double getVelocity() const
Get the velocity of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:203
SkeletonPtr getSkeleton()
Get the Skeleton that this DegreeOfFreedom is inside of.
Definition DegreeOfFreedom.cpp:493
double getInitialPosition() const
Get the position that resetPosition() will give to this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:191
Joint * mJoint
The joint that this DegreeOfFreedom belongs to.
Definition DegreeOfFreedom.hpp:402
void setPositionUpperLimit(double _limit)
Set the upper position limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:155
std::size_t mIndexInJoint
Index of this DegreeOfFreedom within its Joint.
Definition DegreeOfFreedom.hpp:393
void setConstraintImpulse(double _impulse)
Set the constraint impulse of this generalized coordinate.
Definition DegreeOfFreedom.cpp:415
double getForceLowerLimit() const
Get the lower generalized force limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:379
bool isNamePreserved() const
Check whether DegreeOfFreedom::lockName(bool) is activate.
Definition DegreeOfFreedom.cpp:61
void setForceLowerLimit(double _limit)
Set the lower generalized force limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:373
void setVelocityLimits(double _lowerLimit, double _upperLimit)
Set the velocity limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:215
double getPositionUpperLimit() const
Get the upper position limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:161
void setInitialVelocity(double _initial)
Change the velocity that resetVelocity() will give to this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:260
void resetAcceleration()
Set the acceleration of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:284
std::size_t mIndexInSkeleton
Index of this DegreeOfFreedom within its Skeleton.
Definition DegreeOfFreedom.hpp:396
const std::string & setName(const std::string &_name, bool _preserveName=true)
Change the name of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:42
void setPosition(double _position)
Set the position of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:109
void resetVelocityChange()
Set the velocity change of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:409
void setForceUpperLimit(double _limit)
Set the upper generalized force limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:385
void setPositionLowerLimit(double _limit)
Set the lower position limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:143
void resetVelocity()
Set the velocity of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:209
Definition GenericJoint.hpp:49
class Joint
Definition Joint.hpp:61
class Skeleton
Definition Skeleton.hpp:60
std::shared_ptr< const Skeleton > ConstSkeletonPtr
Definition SmartPointer.hpp:60
std::shared_ptr< Skeleton > SkeletonPtr
Definition SmartPointer.hpp:60
Definition BulletCollisionDetector.cpp:60