DART  6.10.1
EulerJoint.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_EULERJOINT_HPP_
34 #define DART_DYNAMICS_EULERJOINT_HPP_
35 
37 
38 namespace dart {
39 namespace dynamics {
40 
43 {
44 public:
45  friend class Skeleton;
50 
52 
53  EulerJoint(const EulerJoint&) = delete;
54 
56  virtual ~EulerJoint();
57 
59  void setProperties(const Properties& _properties);
60 
62  void setProperties(const UniqueProperties& _properties);
63 
66 
69 
71  void copy(const EulerJoint& _otherJoint);
72 
74  void copy(const EulerJoint* _otherJoint);
75 
77  EulerJoint& operator=(const EulerJoint& _otherJoint);
78 
79  // Documentation inherited
80  const std::string& getType() const override;
81 
83  static const std::string& getStaticType();
84 
85  // Documentation inherited
86  bool isCyclic(std::size_t _index) const override;
87 
92  void setAxisOrder(AxisOrder _order, bool _renameDofs = true);
93 
95  AxisOrder getAxisOrder() const;
96 
104  template <typename RotationType>
105  static Eigen::Vector3d convertToPositions(
106  const RotationType& _rotation, AxisOrder _ordering)
107  {
108  switch (_ordering)
109  {
110  case AxisOrder::XYZ:
111  return math::matrixToEulerXYZ(_rotation);
112  case AxisOrder::ZYX:
113  return math::matrixToEulerZYX(_rotation);
114  default:
115  dtwarn << "[EulerJoint::convertToPositions] Unsupported AxisOrder ("
116  << static_cast<int>(_ordering) << "), returning a zero vector\n";
117  return Eigen::Vector3d::Zero();
118  }
119  }
120 
124  template <typename RotationType>
125  Eigen::Vector3d convertToPositions(const RotationType& _rotation) const
126  {
127  return convertToPositions(_rotation, getAxisOrder());
128  }
129 
131  static Eigen::Isometry3d convertToTransform(
132  const Eigen::Vector3d& _positions, AxisOrder _ordering);
133 
137  Eigen::Isometry3d convertToTransform(const Eigen::Vector3d& _positions) const;
138 
140  static Eigen::Matrix3d convertToRotation(
141  const Eigen::Vector3d& _positions, AxisOrder _ordering);
142 
143  Eigen::Matrix3d convertToRotation(const Eigen::Vector3d& _positions) const;
144 
145  // Documentation inherited
146  Eigen::Matrix<double, 6, 3> getRelativeJacobianStatic(
147  const Eigen::Vector3d& _positions) const override;
148 
149 protected:
152 
153  // Documentation inherited
154  Joint* clone() const override;
155 
156  using Base::getRelativeJacobianStatic;
157 
160  void updateDegreeOfFreedomNames() override;
161 
162  // Documentation inherited
163  void updateRelativeTransform() const override;
164 
165  // Documentation inherited
166  void updateRelativeJacobian(bool = true) const override;
167 
168  // Documentation inherited
169  void updateRelativeJacobianTimeDeriv() const override;
170 };
171 
172 } // namespace dynamics
173 } // namespace dart
174 
175 #endif // DART_DYNAMICS_EULERJOINT_HPP_
#define dtwarn
Output a warning message.
Definition: Console.hpp:46
BodyPropPtr properties
Definition: SdfParser.cpp:80
Terminator for the variadic template.
Definition: CompositeJoiner.hpp:45
This is an alternative to EmbedProperties which allows your class to also inherit other Composite obj...
Definition: EmbeddedAspect.hpp:240
typename Impl::Aspect Aspect
Definition: EmbeddedAspect.hpp:246
typename Impl::AspectProperties AspectProperties
Definition: EmbeddedAspect.hpp:245
class EulerJoint
Definition: EulerJoint.hpp:43
static Eigen::Vector3d convertToPositions(const RotationType &_rotation, AxisOrder _ordering)
Convert a rotation into a 3D vector that can be used to set the positions of an EulerJoint with the s...
Definition: EulerJoint.hpp:105
Eigen::Vector3d convertToPositions(const RotationType &_rotation) const
This is a version of EulerJoint::convertToPositions(const RotationType&, AxisOrder) which will use th...
Definition: EulerJoint.hpp:125
detail::EulerJointProperties Properties
Definition: EulerJoint.hpp:48
void setAxisOrder(AxisOrder _order, bool _renameDofs=true)
Set the axis order.
Definition: EulerJoint.cpp:121
void copy(const EulerJoint &_otherJoint)
Copy the Properties of another EulerJoint.
Definition: EulerJoint.cpp:77
void setAspectProperties(const AspectProperties &properties)
Set the AspectProperties of this EulerJoint.
Definition: EulerJoint.cpp:64
Properties getEulerJointProperties() const
Get the Properties of this EulerJoint.
Definition: EulerJoint.cpp:70
void setProperties(const Properties &_properties)
Set the Properties of this EulerJoint.
Definition: EulerJoint.cpp:51
bool isCyclic(std::size_t _index) const override
Definition: EulerJoint.cpp:115
void updateRelativeJacobian(bool=true) const override
Definition: EulerJoint.cpp:343
static Eigen::Isometry3d convertToTransform(const Eigen::Vector3d &_positions, AxisOrder _ordering)
Convert a set of Euler angle positions into a transform.
Definition: EulerJoint.cpp:139
void updateRelativeTransform() const override
Definition: EulerJoint.cpp:333
EulerJoint(const EulerJoint &)=delete
static Eigen::Matrix3d convertToRotation(const Eigen::Vector3d &_positions, AxisOrder _ordering)
Convert a set of Euler angle positions into a rotation matrix.
Definition: EulerJoint.cpp:153
void updateDegreeOfFreedomNames() override
Set the names of this joint's DegreesOfFreedom.
Definition: EulerJoint.cpp:301
Eigen::Matrix< double, 6, 3 > getRelativeJacobianStatic(const Eigen::Vector3d &_positions) const override
Definition: EulerJoint.cpp:179
void updateRelativeJacobianTimeDeriv() const override
Definition: EulerJoint.cpp:349
Joint * clone() const override
Definition: EulerJoint.cpp:295
detail::AxisOrder AxisOrder
Definition: EulerJoint.hpp:46
const std::string & getType() const override
Definition: EulerJoint.cpp:102
AxisOrder getAxisOrder() const
Return the axis order.
Definition: EulerJoint.cpp:133
static const std::string & getStaticType()
Get joint type for this class.
Definition: EulerJoint.cpp:108
class Joint
Definition: Joint.hpp:60
class Skeleton
Definition: Skeleton.hpp:59
#define DART_BAKE_SPECIALIZED_ASPECT_IRREGULAR(TypeName, AspectName)
Definition: Composite.hpp:164
Definition: Random-impl.hpp:92
AxisOrder
Axis order.
Definition: EulerJointAspect.hpp:50
common::EmbedPropertiesOnTopOf< EulerJoint, EulerJointUniqueProperties, GenericJoint< math::R3Space > > EulerJointBase
Definition: EulerJointAspect.hpp:87
Eigen::Vector3d matrixToEulerXYZ(const Eigen::Matrix3d &_R)
get the Euler XYZ angle from R
Definition: Geometry.cpp:117
Eigen::Vector3d matrixToEulerZYX(const Eigen::Matrix3d &_R)
get the Euler ZYX angle from R
Definition: Geometry.cpp:151
Definition: BulletCollisionDetector.cpp:65
Definition: SharedLibraryManager.hpp:46
Definition: EulerJointAspect.hpp:70
Definition: EulerJointAspect.hpp:57