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_SCREWJOINT_HPP_
34 #define DART_DYNAMICS_SCREWJOINT_HPP_
35 
36 #include "dart/dynamics/detail/ScrewJointAspect.hpp"
37 
38 namespace dart {
39 namespace dynamics {
40 
41 /// class ScrewJoint
42 class ScrewJoint : public detail::ScrewJointBase
43 {
44 public:
45   friend class Skeleton;
46   using UniqueProperties = detail::ScrewJointUniqueProperties;
47   using Properties = detail::ScrewJointProperties;
48   using Base = detail::ScrewJointBase;
49 
50   DART_BAKE_SPECIALIZED_ASPECT_IRREGULAR(Aspect, ScrewJointAspect)
51 
52   ScrewJoint(const ScrewJoint&) = delete;
53 
54   /// Destructor
55   virtual ~ScrewJoint();
56 
57   /// Set the Properties of this ScrewJoint
58   void setProperties(const Properties& _properties);
59 
60   /// Set the Properties of this ScrewJoint
61   void setProperties(const UniqueProperties& _properties);
62 
63   /// Set the AspectProperties of this ScrewJoint
64   void setAspectProperties(const AspectProperties& properties);
65 
66   /// Get the Properties of this ScrewJoint
67   Properties getScrewJointProperties() const;
68 
69   /// Copy the Properties of another ScrewJoint
70   void copy(const ScrewJoint& _otherJoint);
71 
72   /// Copy the Properties of another ScrewJoint
73   void copy(const ScrewJoint* _otherJoint);
74 
75   /// Copy the Properties of another ScrewJoint
76   ScrewJoint& operator=(const ScrewJoint& _otherJoint);
77 
78   // Documentation inherited
79   const std::string& getType() const override;
80 
81   /// Get joint type for this class
82   static const std::string& getStaticType();
83 
84   // Documentation inherited
85   bool isCyclic(std::size_t _index) const override;
86 
87   ///
88   void setAxis(const Eigen::Vector3d& _axis);
89 
90   ///
91   const Eigen::Vector3d& getAxis() const;
92 
93   ///
94   void setPitch(double _pitch);
95 
96   ///
97   double getPitch() const;
98 
99   // Documentation inherited
100   GenericJoint<math::R1Space>::JacobianMatrix getRelativeJacobianStatic(
101       const GenericJoint<math::R1Space>::Vector& positions) const override;
102 
103 protected:
104   /// Constructor called by Skeleton class
105   ScrewJoint(const Properties& properties);
106 
107   // Documentation inherited
108   Joint* clone() const override;
109 
110   // Documentation inherited
111   void updateDegreeOfFreedomNames() override;
112 
113   // Documentation inherited
114   void updateRelativeTransform() const override;
115 
116   // Documentation inherited
117   void updateRelativeJacobian(bool _mandatory = true) const override;
118 
119   // Documentation inherited
120   void updateRelativeJacobianTimeDeriv() const override;
121 };
122 
123 } // namespace dynamics
124 } // namespace dart
125 
126 #endif // DART_DYNAMICS_SCREWJOINT_HPP_
127