DART 6.7.3
Loading...
Searching...
No Matches
DegreeOfFreedom.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_DYNAMICS_DEGREEOFFREEDOM_HPP_
34#define DART_DYNAMICS_DEGREEOFFREEDOM_HPP_
35
36#include <string>
37#include <memory>
38#include <Eigen/Core>
39
42
43namespace dart {
44namespace dynamics {
45
46class Skeleton;
47class Joint;
48class BodyNode;
49
52class DegreeOfFreedom : public virtual common::Subject
53{
54public:
55
56 friend class Joint;
57 template<class> friend class GenericJoint;
58 friend class Skeleton;
59
61
68 const std::string& setName(const std::string& _name, bool _preserveName=true);
69
85 const std::string& getName() const;
86
91 void preserveName(bool _preserve);
92
94 bool isNamePreserved() const;
95
97 std::size_t getIndexInSkeleton() const;
98
100 std::size_t getIndexInTree() const;
101
103 std::size_t getIndexInJoint() const;
104
106 std::size_t getTreeIndex() const;
107
108 //----------------------------------------------------------------------------
110 //----------------------------------------------------------------------------
111
113 void setCommand(double _command);
114
116 double getCommand() const;
117
119 void resetCommand();
120
122
123 //----------------------------------------------------------------------------
125 //----------------------------------------------------------------------------
126
128 void setPosition(double _position);
129
131 double getPosition() const;
132
134 void setPositionLimits(double _lowerLimit, double _upperLimit);
135
137 void setPositionLimits(const std::pair<double,double>& _limits);
138
140 std::pair<double,double> getPositionLimits() const;
141
143 void setPositionLowerLimit(double _limit);
144
146 double getPositionLowerLimit() const;
147
149 void setPositionUpperLimit(double _limit);
150
152 double getPositionUpperLimit() const;
153
158 bool isCyclic() const;
159
161 bool hasPositionLimit() const;
162
164 void resetPosition();
165
167 void setInitialPosition(double _initial);
168
170 double getInitialPosition() const;
171
173
174 //----------------------------------------------------------------------------
176 //----------------------------------------------------------------------------
177
179 void setVelocity(double _velocity);
180
182 double getVelocity() const;
183
185 void setVelocityLimits(double _lowerLimit, double _upperLimit);
186
188 void setVelocityLimits(const std::pair<double,double>& _limits);
189
191 std::pair<double,double> getVelocityLimits() const;
192
194 void setVelocityLowerLimit(double _limit);
195
197 double getVelocityLowerLimit() const;
198
200 void setVelocityUpperLimit(double _limit);
201
203 double getVelocityUpperLimit() const;
204
206 void resetVelocity();
207
209 void setInitialVelocity(double _initial);
210
212 double getInitialVelocity() const;
213
215
216 //----------------------------------------------------------------------------
218 //----------------------------------------------------------------------------
219
221 void setAcceleration(double _acceleration);
222
224 double getAcceleration() const;
225
227 void resetAcceleration();
228
230 void setAccelerationLimits(double _lowerLimit, double _upperLimit);
231
233 void setAccelerationLimits(const std::pair<double,double>& _limits);
234
236 std::pair<double,double> getAccelerationLimits() const;
237
239 void setAccelerationLowerLimit(double _limit);
240
242 double getAccelerationLowerLimit() const;
243
245 void setAccelerationUpperLimit(double _limit);
246
248 double getAccelerationUpperLimit() const;
249
251
252 //----------------------------------------------------------------------------
254 //----------------------------------------------------------------------------
255
257 void setForce(double _force);
258
260 double getForce() const;
261
263 void resetForce();
264
266 void setForceLimits(double _lowerLimit, double _upperLimit);
267
269 void setForceLimits(const std::pair<double,double>& _limits);
270
272 std::pair<double,double> getForceLimits() const;
273
275 void setForceLowerLimit(double _limit);
276
278 double getForceLowerLimit() const;
279
281 void setForceUpperLimit(double _limit);
282
284 double getForceUpperLimit() const;
285
287
288 //----------------------------------------------------------------------------
290 //----------------------------------------------------------------------------
291
293 void setVelocityChange(double _velocityChange);
294
296 double getVelocityChange() const;
297
299 void resetVelocityChange();
300
302
303 //----------------------------------------------------------------------------
305 //----------------------------------------------------------------------------
306
308 void setConstraintImpulse(double _impulse);
309
311 double getConstraintImpulse() const;
312
315
317
318 //----------------------------------------------------------------------------
320 //----------------------------------------------------------------------------
321
323 void setSpringStiffness(double _k);
324
326 double getSpringStiffness() const;
327
329 void setRestPosition(double _q0);
330
332 double getRestPosition() const;
333
336 void setDampingCoefficient(double _coeff);
337
340 double getDampingCoefficient() const;
341
343 void setCoulombFriction(double _friction);
344
346 double getCoulombFriction() const;
347
349
350 //----------------------------------------------------------------------------
352 //----------------------------------------------------------------------------
353
355 Joint* getJoint();
356
358 const Joint* getJoint() const;
359
362
365
368
370 const BodyNode* getChildBodyNode() const;
371
374
376 const BodyNode* getParentBodyNode() const;
377
379
380protected:
383 DegreeOfFreedom(Joint* _joint, std::size_t _indexInJoint);
384
389 std::size_t mIndexInJoint;
390
392 std::size_t mIndexInSkeleton;
393
395 std::size_t mIndexInTree;
396
399 // Note that we do not need to store BodyNode or Skeleton, because we can
400 // access them through this joint pointer. Moreover, we never need to check
401 // whether mJoint is nullptr, because only Joints are allowed to create a
402 // DegreeOfFreedom and every DegreeOfFreedom is deleted when its Joint is
403 // destructed.
404
405};
406
407} // namespace dynamics
408} // namespace dart
409
410#endif // DART_DYNAMICS_DEGREEOFFREEDOM_HPP_
bool * preserveName
Definition SkelParser.cpp:1641
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:78
DegreeOfFreedom class is a proxy class for accessing single degrees of freedom (aka generalized coord...
Definition DegreeOfFreedom.hpp:53
double getDampingCoefficient() const
Get coefficient of damping (viscous friction) force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:460
void resetForce()
Set the generalized force of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:345
void setAccelerationLimits(double _lowerLimit, double _upperLimit)
Set the acceleration limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:287
void setVelocity(double _velocity)
Set the velocity of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:195
void setAccelerationUpperLimit(double _limit)
Set the upper acceleration limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:321
bool isCyclic() const
Get whether this DOF is cyclic.
Definition DegreeOfFreedom.cpp:171
void resetPosition()
Set the position of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:177
double getForceUpperLimit() const
Get the upper generalized force limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:388
double getPosition() const
Get the position of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:114
void resetConstraintImpulse()
Set the constraint impulse of this generalized coordinate to zero.
Definition DegreeOfFreedom.cpp:424
void setAcceleration(double _acceleration)
Set the acceleration of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:269
BodyNode * getChildBodyNode()
Get the BodyNode downstream of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:502
void setForce(double _force)
Set the generalized force of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:333
double getCoulombFriction() const
Get Coulomb friction force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:472
DegreeOfFreedom(const DegreeOfFreedom &)=delete
void setCoulombFriction(double _friction)
Set Coulomb friction force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:466
std::size_t getIndexInTree() const
Get this DegreeOfFreedom's index within its tree.
Definition DegreeOfFreedom.cpp:72
std::size_t getIndexInSkeleton() const
Get this DegreeOfFreedom's index within its Skeleton.
Definition DegreeOfFreedom.cpp:66
double getForce() const
Get the generalized force of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:339
Joint * getJoint()
Get the Joint that this DegreeOfFreedom belongs to.
Definition DegreeOfFreedom.cpp:478
std::size_t getTreeIndex() const
Get the index of the tree that this DegreeOfFreedom belongs to.
Definition DegreeOfFreedom.cpp:84
std::pair< double, double > getVelocityLimits() const
Get the velocity limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:226
const std::string & getName() const
Get the name of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:48
void resetCommand()
Set the command of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:102
bool hasPositionLimit() const
Get whether the position of this DegreeOfFreedom has limits.
Definition DegreeOfFreedom.cpp:165
std::pair< double, double > getForceLimits() const
Get the generalized force limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:364
std::size_t mIndexInTree
Index of this DegreeOfFreedom within its tree.
Definition DegreeOfFreedom.hpp:395
void setDampingCoefficient(double _coeff)
Set coefficient of damping (viscous friction) force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:454
double getAcceleration() const
Get the acceleration of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:275
void setRestPosition(double _q0)
Set rest position for the spring force of this generalized coordinate.
Definition DegreeOfFreedom.cpp:442
double getRestPosition() const
Get rest position for the spring force of this generalized coordinate.
Definition DegreeOfFreedom.cpp:448
std::size_t getIndexInJoint() const
Get this DegreeOfFreedom's index within its Joint.
Definition DegreeOfFreedom.cpp:78
void setVelocityLowerLimit(double _limit)
Set the lower velocity limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:233
void setAccelerationLowerLimit(double _limit)
Set the lower acceleration limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:309
void setSpringStiffness(double _k)
Set stiffness of the spring force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:430
void setCommand(double _command)
Set the command of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:90
double getAccelerationLowerLimit() const
Get the lower acceleration limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:315
double getVelocityUpperLimit() const
Get the upper Velocity limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:251
std::pair< double, double > getAccelerationLimits() const
Get the acceleration limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:302
double getVelocityChange() const
Get the velocity change of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:400
double getSpringStiffness() const
Get stiffness of the spring force for this generalized coordinate.
Definition DegreeOfFreedom.cpp:436
void setPositionLimits(double _lowerLimit, double _upperLimit)
Set the position limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:120
void setVelocityUpperLimit(double _limit)
Set the upper velocity limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:245
void setInitialPosition(double _initial)
Change the position that resetPosition() will give to this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:183
BodyNode * getParentBodyNode()
Get the BodyNode upstream of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:514
double getInitialVelocity() const
Get the velocity that resetVelocity() will give to this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:263
void setForceLimits(double _lowerLimit, double _upperLimit)
Set the generalized force limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:351
double getCommand() const
Get the command of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:96
double getVelocityLowerLimit() const
Get the lower velocity limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:239
double getPositionLowerLimit() const
Get the lower position limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:147
std::pair< double, double > getPositionLimits() const
Get the position limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:133
double getAccelerationUpperLimit() const
Get the upper acceleration limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:327
double getConstraintImpulse() const
Get the constraint impulse of this generalized coordinate.
Definition DegreeOfFreedom.cpp:418
void setVelocityChange(double _velocityChange)
Set the velocity change of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:394
double getVelocity() const
Get the velocity of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:201
SkeletonPtr getSkeleton()
Get the Skeleton that this DegreeOfFreedom is inside of.
Definition DegreeOfFreedom.cpp:490
double getInitialPosition() const
Get the position that resetPosition() will give to this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:189
Joint * mJoint
The joint that this DegreeOfFreedom belongs to.
Definition DegreeOfFreedom.hpp:398
void setPositionUpperLimit(double _limit)
Set the upper position limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:153
std::size_t mIndexInJoint
Index of this DegreeOfFreedom within its Joint.
Definition DegreeOfFreedom.hpp:389
void setConstraintImpulse(double _impulse)
Set the constraint impulse of this generalized coordinate.
Definition DegreeOfFreedom.cpp:412
double getForceLowerLimit() const
Get the lower generalized force limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:376
bool isNamePreserved() const
Check whether DegreeOfFreedom::lockName(bool) is activate.
Definition DegreeOfFreedom.cpp:60
void setForceLowerLimit(double _limit)
Set the lower generalized force limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:370
void setVelocityLimits(double _lowerLimit, double _upperLimit)
Set the velocity limits of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:213
double getPositionUpperLimit() const
Get the upper position limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:159
void setInitialVelocity(double _initial)
Change the velocity that resetVelocity() will give to this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:257
void resetAcceleration()
Set the acceleration of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:281
std::size_t mIndexInSkeleton
Index of this DegreeOfFreedom within its Skeleton.
Definition DegreeOfFreedom.hpp:392
const std::string & setName(const std::string &_name, bool _preserveName=true)
Change the name of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:41
void setPosition(double _position)
Set the position of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:108
void resetVelocityChange()
Set the velocity change of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:406
void setForceUpperLimit(double _limit)
Set the upper generalized force limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:382
void setPositionLowerLimit(double _limit)
Set the lower position limit of this DegreeOfFreedom.
Definition DegreeOfFreedom.cpp:141
void resetVelocity()
Set the velocity of this DegreeOfFreedom to zero.
Definition DegreeOfFreedom.cpp:207
Definition GenericJoint.hpp:49
class Joint
Definition Joint.hpp:59
class Skeleton
Definition Skeleton.hpp:59
std::shared_ptr< const Skeleton > ConstSkeletonPtr
Definition SmartPointer.hpp:60
std::shared_ptr< Skeleton > SkeletonPtr
Definition SmartPointer.hpp:60
Definition BulletCollisionDetector.cpp:63