dart
BodyNodeAspect.hpp
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_DETAIL_BODYNODEASPECT_HPP_
34 #define DART_DYNAMICS_DETAIL_BODYNODEASPECT_HPP_
35 
36 #include "dart/common/EmbeddedAspect.hpp"
37 #include "dart/common/ProxyAspect.hpp"
38 #include "dart/dynamics/Entity.hpp"
39 #include "dart/dynamics/Inertia.hpp"
40 #include "dart/dynamics/Node.hpp"
41 
42 namespace dart {
43 namespace dynamics {
44 
45 class Skeleton;
46 
47 namespace detail {
48 
49 //==============================================================================
51 {
53  Eigen::Vector6d mFext;
54 
55  BodyNodeState(const Eigen::Vector6d& Fext = Eigen::Vector6d::Zero());
56 
57  virtual ~BodyNodeState() = default;
58 
59  // To get byte-aligned Eigen vectors
60  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
61 };
62 
63 //==============================================================================
65 {
67  std::string mName;
68 
71 
74 
80 
86 
89 
94  DART_DEPRECATED(6.10)
96  const std::string& name,
97  const Inertia& _inertia,
98  bool _isCollidable,
99  double _frictionCoeff,
100  double _restitutionCoeff,
101  bool _gravityMode);
102 
105  const std::string& name = "BodyNode",
106  const Inertia& inertia = Inertia(),
107  bool isCollidable = true,
108  bool gravityMode = true);
109 
110  virtual ~BodyNodeAspectProperties() = default;
111 };
112 
113 //==============================================================================
115  = common::CloneableVector<std::unique_ptr<Node::State> >;
116 using NodeStateMap
117  = std::map<std::type_index, std::unique_ptr<NodeTypeStateVector> >;
118 using AllNodeStates = common::CloneableMap<NodeStateMap>;
119 
120 //==============================================================================
122  = common::CloneableVector<std::unique_ptr<Node::Properties> >;
123 using NodePropertiesMap
124  = std::map<std::type_index, std::unique_ptr<NodeTypePropertiesVector> >;
125 using AllNodeProperties = common::CloneableMap<NodePropertiesMap>;
126 
127 //==============================================================================
128 void setAllNodeStates(BodyNode* bodyNode, const AllNodeStates& states);
129 
130 //==============================================================================
131 AllNodeStates getAllNodeStates(const BodyNode* bodyNode);
132 
133 //==============================================================================
134 void setAllNodeProperties(
135  BodyNode* bodyNode, const AllNodeProperties& properties);
136 
137 //==============================================================================
138 AllNodeProperties getAllNodeProperties(const BodyNode* bodyNode);
139 
140 //==============================================================================
141 using NodeVectorProxyAspectState = common::ProxyCloneable<
142  common::Aspect::State,
143  BodyNode,
145  &setAllNodeStates,
146  &getAllNodeStates>;
147 
148 //==============================================================================
149 using NodeVectorProxyAspectProperties = common::ProxyCloneable<
150  common::Aspect::Properties,
151  BodyNode,
153  &setAllNodeProperties,
154  &getAllNodeProperties>;
155 
156 //==============================================================================
157 using NodeVectorProxyAspect = common::ProxyStateAndPropertiesAspect<
158  BodyNode,
161 
162 //==============================================================================
163 using BodyNodeCompositeBase = common::EmbedStateAndPropertiesOnTopOf<
164  BodyNode,
167  common::RequiresAspect<NodeVectorProxyAspect> >;
168 
169 } // namespace detail
170 } // namespace dynamics
171 } // namespace dart
172 
173 #endif // DART_DYNAMICS_DETAIL_BODYNODEASPECT_HPP_
The Node class is a base class for BodyNode and any object that attaches to a BodyNode.
Definition: Node.hpp:79
Definition: SharedLibraryManager.hpp:46
This is an alternative to EmbedStateAndProperties which allows your class to also inherit other Compo...
Definition: EmbeddedAspect.hpp:431
Definition: Inertia.hpp:43
Eigen::Vector6d mFext
External spatial force.
Definition: BodyNodeAspect.hpp:53
Definition: ProxyAspect.hpp:57
Definition: Aspect.cpp:40
Definition: Cloneable.hpp:139
bool mIsCollidable
Indicates whether this node is collidable;.
Definition: BodyNodeAspect.hpp:73
class State
Definition: State.hpp:65
Inertia mInertia
Inertia information for the BodyNode.
Definition: BodyNodeAspect.hpp:70
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:74
double mFrictionCoeff
Coefficient of friction.
Definition: BodyNodeAspect.hpp:79
MapHolder is a templated wrapper class that is used to allow maps of Aspect::State and Aspect::Proper...
Definition: Cloneable.hpp:220
std::string mName
Name of the Entity.
Definition: BodyNodeAspect.hpp:67
double mRestitutionCoeff
Coefficient of restitution.
Definition: BodyNodeAspect.hpp:85
bool mGravityMode
Gravity will be applied if true.
Definition: BodyNodeAspect.hpp:88
The CloneableVector type wraps a std::vector of an Cloneable type allowing it to be handled by an Clo...
Definition: Cloneable.hpp:287
Definition: BodyNodeAspect.hpp:50
Definition: BodyNodeAspect.hpp:64