DART 6.10.1
Loading...
Searching...
No Matches
GenericJointAspect.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_DETAIL_GenericJointASPECT_HPP_
34#define DART_DYNAMICS_DETAIL_GenericJointASPECT_HPP_
35
38#include "dart/math/Helpers.hpp"
39
40namespace dart {
41namespace dynamics {
42
43// Forward declare the GenericJoint class
44template <class ConfigSpaceT>
45class GenericJoint;
46
47namespace detail {
48
49//==============================================================================
50template <class ConfigSpaceT>
52{
53 constexpr static std::size_t NumDofs = ConfigSpaceT::NumDofs;
54 using EuclideanPoint = typename ConfigSpaceT::EuclideanPoint;
55 using Vector = typename ConfigSpaceT::Vector;
56
59
62
65
68
71
73 const EuclideanPoint& positions = EuclideanPoint::Zero(),
74 const Vector& velocities = Vector::Zero(),
75 const Vector& accelerations = Vector::Zero(),
76 const Vector& forces = Vector::Zero(),
77 const Vector& commands = Vector::Zero());
78
79 virtual ~GenericJointState() = default;
80
81 // To get byte-aligned Eigen vectors
82 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
83};
84
85//==============================================================================
86template <class ConfigSpaceT>
88{
89 constexpr static std::size_t NumDofs = ConfigSpaceT::NumDofs;
90 using EuclideanPoint = typename ConfigSpaceT::EuclideanPoint;
91 using Vector = typename ConfigSpaceT::Vector;
92 using BoolArray = std::array<bool, NumDofs>;
93 using StringArray = std::array<std::string, NumDofs>;
94
97
100
103
106
109
112
115
118
121
124
127
130
133
136
140
143
146 const EuclideanPoint& positionLowerLimits
147 = EuclideanPoint::Constant(-math::constantsd::inf()),
148 const EuclideanPoint& positionUpperLimits
149 = EuclideanPoint::Constant(math::constantsd::inf()),
150 const EuclideanPoint& initialPositions = EuclideanPoint::Zero(),
151 const Vector& velocityLowerLimits
152 = Vector::Constant(-math::constantsd::inf()),
153 const Vector& velocityUpperLimits
154 = Vector::Constant(math::constantsd::inf()),
155 const Vector& initialVelocities = Vector::Zero(),
156 const Vector& accelerationLowerLimits
157 = Vector::Constant(-math::constantsd::inf()),
158 const Vector& accelerationUpperLimits
159 = Vector::Constant(math::constantsd::inf()),
160 const Vector& forceLowerLimits
161 = Vector::Constant(-math::constantsd::inf()),
162 const Vector& forceUpperLimits
163 = Vector::Constant(math::constantsd::inf()),
164 const Vector& springStiffness = Vector::Zero(),
165 const EuclideanPoint& restPosition = EuclideanPoint::Zero(),
166 const Vector& dampingCoefficient = Vector::Zero(),
167 const Vector& coulombFrictions = Vector::Zero());
168
170 // Note: we only need this because VS2013 lacks full support for std::array
171 // Once std::array is properly supported, this should be removed.
173
174 virtual ~GenericJointUniqueProperties() = default;
175
177 // Note: we only need this because VS2013 lacks full support for std::array
178 // Once std::array is properly supported, this should be removed.
180 const GenericJointUniqueProperties& other);
181
182public:
183 // To get byte-aligned Eigen vectors
184 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
185};
186
187//==============================================================================
188template <class ConfigSpaceT>
190 GenericJointUniqueProperties<ConfigSpaceT>
191{
193 const Joint::Properties& jointProperties = Joint::Properties(),
194 const GenericJointUniqueProperties<ConfigSpaceT>& genericProperties
196
197 virtual ~GenericJointProperties() = default;
198
199public:
200 // To get byte-aligned Eigen vectors
201 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
202};
203
204//==============================================================================
205//
206// These namespace-level definitions are required to enable ODR-use of static
207// constexpr member variables.
208//
209// See this StackOverflow answer: http://stackoverflow.com/a/14396189/111426
210//
211template <class ConfigSpaceT>
212constexpr std::size_t GenericJointState<ConfigSpaceT>::NumDofs;
213
214template <class ConfigSpaceT>
216
217//==============================================================================
218template <class ConfigSpaceT>
220 const EuclideanPoint& positions,
221 const Vector& velocities,
222 const Vector& accelerations,
223 const Vector& forces,
224 const Vector& commands)
225 : mPositions(positions),
226 mVelocities(velocities),
227 mAccelerations(accelerations),
228 mForces(forces),
229 mCommands(commands)
230{
231 // Do nothing
232}
233
234//==============================================================================
235template <class ConfigSpaceT>
237 const EuclideanPoint& positionLowerLimits,
238 const EuclideanPoint& positionUpperLimits,
239 const EuclideanPoint& initialPositions,
240 const Vector& velocityLowerLimits,
241 const Vector& velocityUpperLimits,
242 const Vector& initialVelocities,
243 const Vector& accelerationLowerLimits,
244 const Vector& accelerationUpperLimits,
245 const Vector& forceLowerLimits,
246 const Vector& forceUpperLimits,
247 const Vector& springStiffness,
250 const Vector& coulombFrictions)
251 : mPositionLowerLimits(positionLowerLimits),
252 mPositionUpperLimits(positionUpperLimits),
253 mInitialPositions(initialPositions),
254 mVelocityLowerLimits(velocityLowerLimits),
255 mVelocityUpperLimits(velocityUpperLimits),
256 mInitialVelocities(initialVelocities),
257 mAccelerationLowerLimits(accelerationLowerLimits),
258 mAccelerationUpperLimits(accelerationUpperLimits),
259 mForceLowerLimits(forceLowerLimits),
260 mForceUpperLimits(forceUpperLimits),
261 mSpringStiffnesses(springStiffness),
262 mRestPositions(restPosition),
263 mDampingCoefficients(dampingCoefficient),
264 mFrictions(coulombFrictions)
265{
266 for (auto i = 0u; i < NumDofs; ++i)
267 {
268 mPreserveDofNames[i] = false;
269 mDofNames[i] = std::string();
270 }
271}
272
273//==============================================================================
274template <class ConfigSpaceT>
276 const GenericJointUniqueProperties& _other)
277 : mPositionLowerLimits(_other.mPositionLowerLimits),
278 mPositionUpperLimits(_other.mPositionUpperLimits),
279 mInitialPositions(_other.mInitialPositions),
280 mVelocityLowerLimits(_other.mVelocityLowerLimits),
281 mVelocityUpperLimits(_other.mVelocityUpperLimits),
282 mInitialVelocities(_other.mInitialVelocities),
283 mAccelerationLowerLimits(_other.mAccelerationLowerLimits),
284 mAccelerationUpperLimits(_other.mAccelerationUpperLimits),
285 mForceLowerLimits(_other.mForceLowerLimits),
286 mForceUpperLimits(_other.mForceUpperLimits),
287 mSpringStiffnesses(_other.mSpringStiffnesses),
288 mRestPositions(_other.mRestPositions),
289 mDampingCoefficients(_other.mDampingCoefficients),
290 mFrictions(_other.mFrictions)
291{
292 for (auto i = 0u; i < NumDofs; ++i)
293 {
295 mDofNames[i] = _other.mDofNames[i];
296 }
297}
298
299//==============================================================================
300template <class ConfigSpaceT>
303 const GenericJointUniqueProperties& other)
304{
305 if (this != &other)
306 {
307 mPositionLowerLimits = other.mPositionLowerLimits;
308 mPositionUpperLimits = other.mPositionUpperLimits;
309 mInitialPositions = other.mInitialPositions;
310 mVelocityLowerLimits = other.mVelocityLowerLimits;
311 mVelocityUpperLimits = other.mVelocityUpperLimits;
312 mInitialVelocities = other.mInitialVelocities;
313 mAccelerationLowerLimits = other.mAccelerationLowerLimits;
314 mAccelerationUpperLimits = other.mAccelerationUpperLimits;
315 mForceLowerLimits = other.mForceLowerLimits;
316 mForceUpperLimits = other.mForceUpperLimits;
317 mSpringStiffnesses = other.mSpringStiffnesses;
318 mRestPositions = other.mRestPositions;
319 mDampingCoefficients = other.mDampingCoefficients;
320 mFrictions = other.mFrictions;
321
322 for (auto i = 0u; i < NumDofs; ++i)
323 {
324 mPreserveDofNames[i] = other.mPreserveDofNames[i];
325 mDofNames[i] = other.mDofNames[i];
326 }
327 }
328 return *this;
329}
330
331//==============================================================================
332template <class ConfigSpaceT>
334 const Joint::Properties& jointProperties,
335 const GenericJointUniqueProperties<ConfigSpaceT>& genericProperties)
336 : Joint::Properties(jointProperties),
337 GenericJointUniqueProperties<ConfigSpaceT>(genericProperties)
338{
339 // Do nothing
340}
341
342//==============================================================================
343template <class Derived, class ConfigSpaceT>
345 Derived,
348 Joint>;
349
350} // namespace detail
351
352} // namespace dynamics
353} // namespace dart
354
355#endif // DART_DYNAMICS_DETAIL_GenericJointASPECT_HPP_
double * springStiffness
Definition SkelParser.cpp:1691
double * dampingCoefficient
Definition SkelParser.cpp:1693
double * restPosition
Definition SkelParser.cpp:1692
This is an alternative to EmbedStateAndProperties which allows your class to also inherit other Compo...
Definition EmbeddedAspect.hpp:435
class Joint
Definition Joint.hpp:60
Definition BulletCollisionDetector.cpp:65
Definition GenericJointAspect.hpp:191
GenericJointProperties(const Joint::Properties &jointProperties=Joint::Properties(), const GenericJointUniqueProperties< ConfigSpaceT > &genericProperties=GenericJointUniqueProperties< ConfigSpaceT >())
Definition GenericJointAspect.hpp:333
Definition GenericJointAspect.hpp:52
Vector mAccelerations
Generalized acceleration.
Definition GenericJointAspect.hpp:64
static constexpr std::size_t NumDofs
Definition GenericJointAspect.hpp:53
EuclideanPoint mPositions
Position.
Definition GenericJointAspect.hpp:58
typename ConfigSpaceT::EuclideanPoint EuclideanPoint
Definition GenericJointAspect.hpp:54
Vector mCommands
Command.
Definition GenericJointAspect.hpp:70
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:219
typename ConfigSpaceT::Vector Vector
Definition GenericJointAspect.hpp:55
Vector mVelocities
Generalized velocity.
Definition GenericJointAspect.hpp:61
Vector mForces
Generalized force.
Definition GenericJointAspect.hpp:67
Definition GenericJointAspect.hpp:88
Vector mAccelerationLowerLimits
Min value allowed.
Definition GenericJointAspect.hpp:114
EuclideanPoint mPositionUpperLimits
Upper limit of position.
Definition GenericJointAspect.hpp:99
BoolArray mPreserveDofNames
True if the name of the corresponding DOF is not allowed to be overwritten.
Definition GenericJointAspect.hpp:139
GenericJointUniqueProperties & operator=(const GenericJointUniqueProperties &other)
Copy assignment operator.
Definition GenericJointAspect.hpp:302
Vector mVelocityUpperLimits
Max value allowed.
Definition GenericJointAspect.hpp:108
StringArray mDofNames
The name of the DegreesOfFreedom for this Joint.
Definition GenericJointAspect.hpp:142
Vector mAccelerationUpperLimits
upper limit of generalized acceleration
Definition GenericJointAspect.hpp:117
std::array< std::string, NumDofs > StringArray
Definition GenericJointAspect.hpp:93
Vector mDampingCoefficients
Joint damping coefficient.
Definition GenericJointAspect.hpp:132
EuclideanPoint mInitialPositions
Initial positions.
Definition GenericJointAspect.hpp:102
EuclideanPoint mPositionLowerLimits
Lower limit of position.
Definition GenericJointAspect.hpp:96
Vector mForceLowerLimits
Min value allowed.
Definition GenericJointAspect.hpp:120
typename ConfigSpaceT::EuclideanPoint EuclideanPoint
Definition GenericJointAspect.hpp:90
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:236
static constexpr std::size_t NumDofs
Definition GenericJointAspect.hpp:89
Vector mFrictions
Joint Coulomb friction.
Definition GenericJointAspect.hpp:135
Vector mVelocityLowerLimits
Min value allowed.
Definition GenericJointAspect.hpp:105
EuclideanPoint mRestPositions
Rest joint position for joint spring.
Definition GenericJointAspect.hpp:129
std::array< bool, NumDofs > BoolArray
Definition GenericJointAspect.hpp:92
typename ConfigSpaceT::Vector Vector
Definition GenericJointAspect.hpp:91
Vector mInitialVelocities
Initial velocities.
Definition GenericJointAspect.hpp:111
Vector mSpringStiffnesses
Joint spring stiffness.
Definition GenericJointAspect.hpp:126
Vector mForceUpperLimits
Max value allowed.
Definition GenericJointAspect.hpp:123
Definition JointAspect.hpp:112
static constexpr T inf()
Definition Constants.hpp:68