DART  6.6.2
BallJoint.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018, 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 
48  friend class Skeleton;
49 
51 
53  {
55 
57 
58  virtual ~Properties() = default;
59  };
60 
62  virtual ~BallJoint();
63 
64  // Documentation inherited
65  const std::string& getType() const override;
66 
68  static const std::string& getStaticType();
69 
70  // Documentation inherited
71  bool isCyclic(std::size_t _index) const override;
72 
75 
82  template <typename RotationType>
83  static Eigen::Vector3d convertToPositions(const RotationType& _rotation)
84  {
85  return math::logMap(_rotation);
86  }
87 
89  static Eigen::Isometry3d convertToTransform(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:
103 
106 
107  // Documentation inherited
108  Joint* clone() const override;
109 
111 
112  // Documentation inherited
113  void integratePositions(double _dt) override;
114 
115  // Documentation inherited
116  void updateDegreeOfFreedomNames() override;
117 
118  // Documentation inherited
119  void updateRelativeTransform() const override;
120 
121  // Documentation inherited
122  void updateRelativeJacobian(bool _mandatory = true) const override;
123 
124  // Documentation inherited
125  void updateRelativeJacobianTimeDeriv() const override;
126 
127 protected:
128 
130  const Eigen::Isometry3d& getR() const;
131 
135  mutable Eigen::Isometry3d mR;
136 
137 public:
138  // To get byte-aligned Eigen vectors
139  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
140 };
141 
142 } // namespace dynamics
143 } // namespace dart
144 
145 #endif // DART_DYNAMICS_BALLJOINT_HPP_
146 
#define DART_DEFINE_ALIGNED_SHARED_OBJECT_CREATOR(class_name)
Definition: Memory.hpp:148
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:164
const Eigen::Isometry3d & getR() const
Access mR, which is an auto-updating variable.
Definition: BallJoint.cpp:180
void updateDegreeOfFreedomNames() override
Definition: BallJoint.cpp:142
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:83
Eigen::Isometry3d mR
Rotation matrix dependent on the generalized coordinates.
Definition: BallJoint.hpp:135
const std::string & getType() const override
Definition: BallJoint.cpp:58
void integratePositions(double _dt) override
Definition: BallJoint.cpp:133
void updateRelativeTransform() const override
Definition: BallJoint.cpp:153
void updateRelativeJacobianTimeDeriv() const override
Definition: BallJoint.cpp:174
virtual ~BallJoint()
Destructor.
Definition: BallJoint.cpp:52
Eigen::Vector3d getPositionDifferencesStatic(const Eigen::Vector3d &_q2, const Eigen::Vector3d &_q1) const override
Definition: BallJoint.cpp:123
BallJoint(const Properties &properties)
Constructor called by Skeleton class.
Definition: BallJoint.cpp:97
Joint * clone() const override
Definition: BallJoint.cpp:110
Definition: GenericJoint.hpp:49
const GenericJoint< math::SO3Space >::JacobianMatrix & getRelativeJacobianStatic() const
Fixed-size version of getRelativeJacobian()
Definition: GenericJoint.hpp:1566
detail::GenericJointProperties< math::SO3Space > Properties
Definition: GenericJoint.hpp:64
class Joint
Definition: Joint.hpp:59
class Skeleton
Definition: Skeleton.hpp:59
Eigen::Vector3d logMap(const Eigen::Matrix3d &_R)
Log mapping.
Definition: Geometry.cpp:515
Definition: BulletCollisionDetector.cpp:63
Definition: BallJoint.hpp:53
Properties(const Base::Properties &properties=Base::Properties())
Definition: BallJoint.cpp:45