DART  6.7.3
GenericJointAspect.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_DETAIL_GenericJointASPECT_HPP_
34 #define DART_DYNAMICS_DETAIL_GenericJointASPECT_HPP_
35 
36 #include "dart/math/Helpers.hpp"
37 #include "dart/dynamics/Joint.hpp"
39 
40 namespace dart {
41 namespace dynamics {
42 
43 // Forward declare the GenericJoint class
44 template <class ConfigSpaceT> class GenericJoint;
45 
46 namespace detail {
47 
48 //==============================================================================
49 template <class ConfigSpaceT>
51 {
52  constexpr static std::size_t NumDofs = ConfigSpaceT::NumDofs;
53  using EuclideanPoint = typename ConfigSpaceT::EuclideanPoint;
54  using Vector = typename ConfigSpaceT::Vector;
55 
58 
61 
64 
67 
70 
72  const EuclideanPoint& positions = EuclideanPoint::Zero(),
73  const Vector& velocities = Vector::Zero(),
74  const Vector& accelerations = Vector::Zero(),
75  const Vector& forces = Vector::Zero(),
76  const Vector& commands = Vector::Zero());
77 
78  virtual ~GenericJointState() = default;
79 
80  // To get byte-aligned Eigen vectors
81  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
82 };
83 
84 //==============================================================================
85 template <class ConfigSpaceT>
87 {
88  constexpr static std::size_t NumDofs = ConfigSpaceT::NumDofs;
89  using EuclideanPoint = typename ConfigSpaceT::EuclideanPoint;
90  using Vector = typename ConfigSpaceT::Vector;
91  using BoolArray = std::array<bool, NumDofs>;
92  using StringArray = std::array<std::string, NumDofs>;
93 
96 
99 
102 
105 
108 
111 
114 
117 
120 
123 
126 
129 
132 
135 
139 
142 
145  const EuclideanPoint& positionLowerLimits = EuclideanPoint::Constant(-math::constantsd::inf()),
146  const EuclideanPoint& positionUpperLimits = EuclideanPoint::Constant( math::constantsd::inf()),
147  const EuclideanPoint& initialPositions = EuclideanPoint::Zero(),
148  const Vector& velocityLowerLimits = Vector::Constant(-math::constantsd::inf()),
149  const Vector& velocityUpperLimits = Vector::Constant( math::constantsd::inf()),
150  const Vector& initialVelocities = Vector::Zero(),
151  const Vector& accelerationLowerLimits = Vector::Constant(-math::constantsd::inf()),
152  const Vector& accelerationUpperLimits = Vector::Constant( math::constantsd::inf()),
153  const Vector& forceLowerLimits = Vector::Constant(-math::constantsd::inf()),
154  const Vector& forceUpperLimits = Vector::Constant( math::constantsd::inf()),
155  const Vector& springStiffness = Vector::Zero(),
156  const EuclideanPoint& restPosition = EuclideanPoint::Zero(),
157  const Vector& dampingCoefficient = Vector::Zero(),
158  const Vector& coulombFrictions = Vector::Zero());
159 
161  // Note: we only need this because VS2013 lacks full support for std::array
162  // Once std::array is properly supported, this should be removed.
164 
165  virtual ~GenericJointUniqueProperties() = default;
166 
167 public:
168  // To get byte-aligned Eigen vectors
169  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
170 
171 };
172 
173 //==============================================================================
174 template <class ConfigSpaceT>
177  GenericJointUniqueProperties<ConfigSpaceT>
178 {
180  const Joint::Properties& jointProperties = Joint::Properties(),
181  const GenericJointUniqueProperties<ConfigSpaceT>& genericProperties =
183 
184  virtual ~GenericJointProperties() = default;
185 
186 public:
187  // To get byte-aligned Eigen vectors
188  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
189 };
190 
191 //==============================================================================
192 //
193 // These namespace-level definitions are required to enable ODR-use of static
194 // constexpr member variables.
195 //
196 // See this StackOverflow answer: http://stackoverflow.com/a/14396189/111426
197 //
198 template <class ConfigSpaceT>
199 constexpr std::size_t GenericJointState<ConfigSpaceT>::NumDofs;
200 
201 template <class ConfigSpaceT>
203 
204 //==============================================================================
205 template <class ConfigSpaceT>
207  const EuclideanPoint& positions,
208  const Vector& velocities,
209  const Vector& accelerations,
210  const Vector& forces,
211  const Vector& commands)
212  : mPositions(positions),
213  mVelocities(velocities),
214  mAccelerations(accelerations),
215  mForces(forces),
216  mCommands(commands)
217 {
218  // Do nothing
219 }
220 
221 //==============================================================================
222 template <class ConfigSpaceT>
224  const EuclideanPoint& positionLowerLimits,
225  const EuclideanPoint& positionUpperLimits,
226  const EuclideanPoint& initialPositions,
227  const Vector& velocityLowerLimits,
228  const Vector& velocityUpperLimits,
229  const Vector& initialVelocities,
230  const Vector& accelerationLowerLimits,
231  const Vector& accelerationUpperLimits,
232  const Vector& forceLowerLimits,
233  const Vector& forceUpperLimits,
234  const Vector& springStiffness,
236  const Vector& dampingCoefficient,
237  const Vector& coulombFrictions)
238  : mPositionLowerLimits(positionLowerLimits),
239  mPositionUpperLimits(positionUpperLimits),
240  mInitialPositions(initialPositions),
241  mVelocityLowerLimits(velocityLowerLimits),
242  mVelocityUpperLimits(velocityUpperLimits),
243  mInitialVelocities(initialVelocities),
244  mAccelerationLowerLimits(accelerationLowerLimits),
245  mAccelerationUpperLimits(accelerationUpperLimits),
246  mForceLowerLimits(forceLowerLimits),
247  mForceUpperLimits(forceUpperLimits),
248  mSpringStiffnesses(springStiffness),
249  mRestPositions(restPosition),
250  mDampingCoefficients(dampingCoefficient),
251  mFrictions(coulombFrictions)
252 {
253  for (auto i = 0u; i < NumDofs; ++i)
254  {
255  mPreserveDofNames[i] = false;
256  mDofNames[i] = std::string();
257  }
258 }
259 
260 //==============================================================================
261 template <class ConfigSpaceT>
263  const GenericJointUniqueProperties& _other)
264  : mPositionLowerLimits(_other.mPositionLowerLimits),
265  mPositionUpperLimits(_other.mPositionUpperLimits),
266  mInitialPositions(_other.mInitialPositions),
267  mVelocityLowerLimits(_other.mVelocityLowerLimits),
268  mVelocityUpperLimits(_other.mVelocityUpperLimits),
269  mInitialVelocities(_other.mInitialVelocities),
270  mAccelerationLowerLimits(_other.mAccelerationLowerLimits),
271  mAccelerationUpperLimits(_other.mAccelerationUpperLimits),
272  mForceLowerLimits(_other.mForceLowerLimits),
273  mForceUpperLimits(_other.mForceUpperLimits),
274  mSpringStiffnesses(_other.mSpringStiffnesses),
275  mRestPositions(_other.mRestPositions),
276  mDampingCoefficients(_other.mDampingCoefficients),
277  mFrictions(_other.mFrictions)
278 {
279  for (auto i = 0u; i < NumDofs; ++i)
280  {
281  mPreserveDofNames[i] = _other.mPreserveDofNames[i];
282  mDofNames[i] = _other.mDofNames[i];
283  }
284 }
285 
286 //==============================================================================
287 template <class ConfigSpaceT>
289  const Joint::Properties& jointProperties,
290  const GenericJointUniqueProperties<ConfigSpaceT>& genericProperties)
291  : Joint::Properties(jointProperties),
292  GenericJointUniqueProperties<ConfigSpaceT>(genericProperties)
293 {
294  // Do nothing
295 }
296 
297 //==============================================================================
298 template <class Derived, class ConfigSpaceT>
300  Derived,
303  Joint>;
304 
305 } // namespace detail
306 
307 } // namespace dynamics
308 } // namespace dart
309 
310 #endif // DART_DYNAMICS_DETAIL_GenericJointASPECT_HPP_
double * springStiffness
Definition: SkelParser.cpp:1636
double * dampingCoefficient
Definition: SkelParser.cpp:1638
double * restPosition
Definition: SkelParser.cpp:1637
This is an alternative to EmbedStateAndProperties which allows your class to also inherit other Compo...
Definition: EmbeddedAspect.hpp:438
class Joint
Definition: Joint.hpp:59
Definition: BulletCollisionDetector.cpp:63
Definition: GenericJointAspect.hpp:178
GenericJointProperties(const Joint::Properties &jointProperties=Joint::Properties(), const GenericJointUniqueProperties< ConfigSpaceT > &genericProperties=GenericJointUniqueProperties< ConfigSpaceT >())
Definition: GenericJointAspect.hpp:288
Definition: GenericJointAspect.hpp:51
Vector mAccelerations
Generalized acceleration.
Definition: GenericJointAspect.hpp:63
constexpr static std::size_t NumDofs
Definition: GenericJointAspect.hpp:52
EuclideanPoint mPositions
Position.
Definition: GenericJointAspect.hpp:57
typename ConfigSpaceT::EuclideanPoint EuclideanPoint
Definition: GenericJointAspect.hpp:53
Vector mCommands
Command.
Definition: GenericJointAspect.hpp:69
GenericJointState(const EuclideanPoint &positions=EuclideanPoint::Zero(), const Vector &velocities=Vector::Zero(), const Vector &accelerations=Vector::Zero(), const Vector &forces=Vector::Zero(), const Vector &commands=Vector::Zero())
Definition: GenericJointAspect.hpp:206
typename ConfigSpaceT::Vector Vector
Definition: GenericJointAspect.hpp:54
Vector mVelocities
Generalized velocity.
Definition: GenericJointAspect.hpp:60
Vector mForces
Generalized force.
Definition: GenericJointAspect.hpp:66
Definition: GenericJointAspect.hpp:87
Vector mAccelerationLowerLimits
Min value allowed.
Definition: GenericJointAspect.hpp:113
EuclideanPoint mPositionUpperLimits
Upper limit of position.
Definition: GenericJointAspect.hpp:98
BoolArray mPreserveDofNames
True if the name of the corresponding DOF is not allowed to be overwritten.
Definition: GenericJointAspect.hpp:138
Vector mVelocityUpperLimits
Max value allowed.
Definition: GenericJointAspect.hpp:107
StringArray mDofNames
The name of the DegreesOfFreedom for this Joint.
Definition: GenericJointAspect.hpp:141
Vector mAccelerationUpperLimits
upper limit of generalized acceleration
Definition: GenericJointAspect.hpp:116
std::array< std::string, NumDofs > StringArray
Definition: GenericJointAspect.hpp:92
Vector mDampingCoefficients
Joint damping coefficient.
Definition: GenericJointAspect.hpp:131
EuclideanPoint mInitialPositions
Initial positions.
Definition: GenericJointAspect.hpp:101
EuclideanPoint mPositionLowerLimits
Lower limit of position.
Definition: GenericJointAspect.hpp:95
Vector mForceLowerLimits
Min value allowed.
Definition: GenericJointAspect.hpp:119
typename ConfigSpaceT::EuclideanPoint EuclideanPoint
Definition: GenericJointAspect.hpp:89
GenericJointUniqueProperties(const EuclideanPoint &positionLowerLimits=EuclideanPoint::Constant(-math::constantsd::inf()), const EuclideanPoint &positionUpperLimits=EuclideanPoint::Constant(math::constantsd::inf()), const EuclideanPoint &initialPositions=EuclideanPoint::Zero(), const Vector &velocityLowerLimits=Vector::Constant(-math::constantsd::inf()), const Vector &velocityUpperLimits=Vector::Constant(math::constantsd::inf()), const Vector &initialVelocities=Vector::Zero(), const Vector &accelerationLowerLimits=Vector::Constant(-math::constantsd::inf()), const Vector &accelerationUpperLimits=Vector::Constant(math::constantsd::inf()), const Vector &forceLowerLimits=Vector::Constant(-math::constantsd::inf()), const Vector &forceUpperLimits=Vector::Constant(math::constantsd::inf()), const Vector &springStiffness=Vector::Zero(), const EuclideanPoint &restPosition=EuclideanPoint::Zero(), const Vector &dampingCoefficient=Vector::Zero(), const Vector &coulombFrictions=Vector::Zero())
Default constructor.
Definition: GenericJointAspect.hpp:223
constexpr static std::size_t NumDofs
Definition: GenericJointAspect.hpp:88
Vector mFrictions
Joint Coulomb friction.
Definition: GenericJointAspect.hpp:134
Vector mVelocityLowerLimits
Min value allowed.
Definition: GenericJointAspect.hpp:104
EuclideanPoint mRestPositions
Rest joint position for joint spring.
Definition: GenericJointAspect.hpp:128
std::array< bool, NumDofs > BoolArray
Definition: GenericJointAspect.hpp:91
typename ConfigSpaceT::Vector Vector
Definition: GenericJointAspect.hpp:90
Vector mInitialVelocities
Initial velocities.
Definition: GenericJointAspect.hpp:110
Vector mSpringStiffnesses
Joint spring stiffness.
Definition: GenericJointAspect.hpp:125
Vector mForceUpperLimits
Max value allowed.
Definition: GenericJointAspect.hpp:122
Definition: JointAspect.hpp:112
static constexpr T inf()
Definition: Constants.hpp:54