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_ENDEFFECTOR_HPP_ 34 #define DART_DYNAMICS_ENDEFFECTOR_HPP_ 35 36 #include "dart/common/Aspect.hpp" 37 #include "dart/common/AspectWithVersion.hpp" 38 #include "dart/common/SpecializedForAspect.hpp" 39 #include "dart/dynamics/CompositeNode.hpp" 40 #include "dart/dynamics/FixedJacobianNode.hpp" 41 #include "dart/dynamics/detail/EndEffectorAspect.hpp" 42 43 namespace dart { 44 namespace dynamics { 45 46 class BodyNode; 47 class Skeleton; 48 class EndEffector; 49 50 //============================================================================== 51 class Support final : public common::AspectWithStateAndVersionedProperties< 52 Support, 53 detail::SupportStateData, 54 detail::SupportPropertiesData, 55 EndEffector, 56 &detail::SupportUpdate> 57 { 58 public: 59 DART_COMMON_ASPECT_STATE_PROPERTY_CONSTRUCTORS(Support) 60 61 /// Set/Get the support geometry for this EndEffector. The SupportGeometry 62 /// represents points in the EndEffector frame that can be used for contact 63 /// when solving balancing or manipulation constraints. 64 DART_COMMON_SET_GET_ASPECT_PROPERTY(math::SupportGeometry, Geometry) 65 // void setGeometry(const math::SupportGeometry&); 66 // const math::SupportGeometry& getGeometry() const; 67 68 /// Pass in true if this EndEffector should be used to support the robot, like 69 /// a foot 70 void setActive(bool _supporting = true); 71 72 /// Get whether this EndEffector is currently being used for support 73 bool isActive() const; 74 }; 75 76 //============================================================================== 77 class EndEffector final : public common::EmbedPropertiesOnTopOf< 78 EndEffector, 79 detail::EndEffectorProperties, 80 detail::EndEffectorCompositeBase> 81 { 82 public: 83 friend class Skeleton; 84 friend class BodyNode; 85 86 using UniqueProperties = detail::EndEffectorProperties; 87 88 using BasicProperties 89 = common::Composite::MakeProperties<NameAspect, FixedFrame, EndEffector>; 90 91 using Properties = common::Composite::Properties; 92 93 /// Destructor 94 virtual ~EndEffector() = default; 95 96 //---------------------------------------------------------------------------- 97 /// \{ \name Structural Properties 98 //---------------------------------------------------------------------------- 99 100 /// Set the Properties of this EndEffector. If _useNow is true, the current 101 /// Transform will be set to the new default transform. 102 void setProperties(const BasicProperties& _properties); 103 104 /// Set the Properties of this EndEffector. If _useNow is true, the current 105 /// Transform will be set to the new default transform. 106 void setProperties(const UniqueProperties& properties, bool useNow = false); 107 108 /// Set the AspectProperties of this EndEffector 109 void setAspectProperties(const AspectProperties& properties); 110 111 /// Get the Properties of this EndEffector 112 Properties getEndEffectorProperties() const; 113 114 /// Copy the State and Properties of another EndEffector 115 void copy(const EndEffector& _otherEndEffector); 116 117 /// Copy the State and Properties of another EndEffector 118 void copy(const EndEffector* _otherEndEffector); 119 120 /// Copy the State and Properties of another EndEffector 121 EndEffector& operator=(const EndEffector& _otherEndEffector); 122 123 /// Set the default relative transform of this EndEffector. The relative 124 /// transform of this EndEffector will be set to _newDefaultTf the next time 125 /// resetRelativeTransform() is called. If _useNow is set to true, then 126 /// resetRelativeTransform() will be called at the end of this function. 127 void setDefaultRelativeTransform( 128 const Eigen::Isometry3d& _newDefaultTf, bool _useNow = false); 129 130 /// Set the current relative transform of this EndEffector to the default 131 /// relative transform of this EndEffector. The default relative transform can 132 /// be set with setDefaultRelativeTransform() 133 void resetRelativeTransform(); 134 135 DART_BAKE_SPECIALIZED_ASPECT(Support) 136 137 //---------------------------------------------------------------------------- 138 /// \{ \name Notifications 139 //---------------------------------------------------------------------------- 140 141 // Documentation inherited 142 void dirtyTransform() override; 143 144 /// \} 145 146 protected: 147 /// Constructor used by the Skeleton class 148 explicit EndEffector(BodyNode* parent, const BasicProperties& properties); 149 150 // Documentation inherited 151 Node* cloneNode(BodyNode* _parent) const override; 152 }; 153 154 } // namespace dynamics 155 } // namespace dart 156 157 #endif // DART_DYNAMICS_ENDEFFECTOR_HPP_ 158