DART  6.10.1
BallJoint.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_BALLJOINT_HPP_
34 #define DART_DYNAMICS_BALLJOINT_HPP_
35 
36 #include <Eigen/Dense>
37 
39 
40 namespace dart {
41 namespace dynamics {
42 
44 class BallJoint : public GenericJoint<math::SO3Space>
45 {
46 public:
47  friend class Skeleton;
48 
50 
52  {
54 
56 
57  virtual ~Properties() = default;
58  };
59 
61  virtual ~BallJoint();
62 
63  // Documentation inherited
64  const std::string& getType() const override;
65 
67  static const std::string& getStaticType();
68 
69  // Documentation inherited
70  bool isCyclic(std::size_t _index) const override;
71 
74 
81  template <typename RotationType>
82  static Eigen::Vector3d convertToPositions(const RotationType& _rotation)
83  {
84  return math::logMap(_rotation);
85  }
86 
88  static Eigen::Isometry3d convertToTransform(
89  const Eigen::Vector3d& _positions);
90 
92  static Eigen::Matrix3d convertToRotation(const Eigen::Vector3d& _positions);
93 
94  // Documentation inherited
95  Eigen::Matrix<double, 6, 3> getRelativeJacobianStatic(
96  const Eigen::Vector3d& _positions) const override;
97 
98  // Documentation inherited
99  Eigen::Vector3d getPositionDifferencesStatic(
100  const Eigen::Vector3d& _q2, const Eigen::Vector3d& _q1) const override;
101 
102 protected:
105 
106  // Documentation inherited
107  Joint* clone() const override;
108 
110 
111  // Documentation inherited
112  void integratePositions(double _dt) override;
113 
114  // Documentation inherited
115  void updateDegreeOfFreedomNames() override;
116 
117  // Documentation inherited
118  void updateRelativeTransform() const override;
119 
120  // Documentation inherited
121  void updateRelativeJacobian(bool _mandatory = true) const override;
122 
123  // Documentation inherited
124  void updateRelativeJacobianTimeDeriv() const override;
125 
126 protected:
128  const Eigen::Isometry3d& getR() const;
129 
133  mutable Eigen::Isometry3d mR;
134 
135 public:
136  // To get byte-aligned Eigen vectors
137  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
138 };
139 
140 } // namespace dynamics
141 } // namespace dart
142 
143 #endif // DART_DYNAMICS_BALLJOINT_HPP_
#define DART_DEFINE_ALIGNED_SHARED_OBJECT_CREATOR(class_name)
Definition: Memory.hpp:155
BodyPropPtr properties
Definition: SdfParser.cpp:80
Terminator for the variadic template.
Definition: CompositeJoiner.hpp:45
class BallJoint
Definition: BallJoint.hpp:45
static const std::string & getStaticType()
Get joint type for this class.
Definition: BallJoint.cpp:64
static Eigen::Isometry3d convertToTransform(const Eigen::Vector3d &_positions)
Convert a BallJoint-style position vector into a transform.
Definition: BallJoint.cpp:84
static Eigen::Matrix3d convertToRotation(const Eigen::Vector3d &_positions)
Convert a BallJoint-style position vector into a rotation matrix.
Definition: BallJoint.cpp:91
bool isCyclic(std::size_t _index) const override
Definition: BallJoint.cpp:71
Properties getBallJointProperties() const
Get the Properties of this BallJoint.
Definition: BallJoint.cpp:78
void updateRelativeJacobian(bool _mandatory=true) const override
Definition: BallJoint.cpp:163
const Eigen::Isometry3d & getR() const
Access mR, which is an auto-updating variable.
Definition: BallJoint.cpp:179
void updateDegreeOfFreedomNames() override
Definition: BallJoint.cpp:141
static Eigen::Vector3d convertToPositions(const RotationType &_rotation)
Convert a rotation into a 3D vector that can be used to set the positions of a BallJoint.
Definition: BallJoint.hpp:82
Eigen::Isometry3d mR
Rotation matrix dependent on the generalized coordinates.
Definition: BallJoint.hpp:133
const std::string & getType() const override
Definition: BallJoint.cpp:58
void integratePositions(double _dt) override
Definition: BallJoint.cpp:132
void updateRelativeTransform() const override
Definition: BallJoint.cpp:152
void updateRelativeJacobianTimeDeriv() const override
Definition: BallJoint.cpp:173
virtual ~BallJoint()
Destructor.
Definition: BallJoint.cpp:52
Eigen::Vector3d getPositionDifferencesStatic(const Eigen::Vector3d &_q2, const Eigen::Vector3d &_q1) const override
Definition: BallJoint.cpp:122
BallJoint(const Properties &properties)
Constructor called by Skeleton class.
Definition: BallJoint.cpp:97
Joint * clone() const override
Definition: BallJoint.cpp:109
Definition: GenericJoint.hpp:48
const GenericJoint< math::SO3Space >::JacobianMatrix & getRelativeJacobianStatic() const
Fixed-size version of getRelativeJacobian()
Definition: GenericJoint.hpp:1570
detail::GenericJointProperties< math::SO3Space > Properties
Definition: GenericJoint.hpp:62
class Joint
Definition: Joint.hpp:60
class Skeleton
Definition: Skeleton.hpp:59
Eigen::Vector3d logMap(const Eigen::Matrix3d &_R)
Log mapping.
Definition: Geometry.cpp:565
Definition: BulletCollisionDetector.cpp:65
Definition: BallJoint.hpp:52
Properties(const Base::Properties &properties=Base::Properties())
Definition: BallJoint.cpp:45