DART  6.6.2
Entity.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_ENTITY_HPP_
34 #define DART_DYNAMICS_ENTITY_HPP_
35 
36 #include <Eigen/Core>
37 #include <string>
38 #include <vector>
39 
40 #include "dart/common/Subject.hpp"
41 #include "dart/common/Signal.hpp"
43 #include "dart/dynamics/Shape.hpp"
45 
46 namespace dart {
47 namespace dynamics {
48 
49 class Frame;
50 
59 class Entity : public virtual common::Subject
60 {
61 public:
62  friend class Frame;
63 
64  using EntitySignal = common::Signal<void(const Entity*)>;
66  = common::Signal<void(const Entity*,
67  const Frame* _oldFrame,
68  const Frame* _newFrame)>;
70  = common::Signal<void(const Entity*,
71  const std::string& _oldName,
72  const std::string& _newName)>;
73 
75  explicit Entity(Frame* _refFrame, bool _quiet);
76 
78  Entity();
79 
80  Entity(const Entity&) = delete;
81 
83  virtual ~Entity();
84 
88  virtual const std::string& setName(const std::string& _name) = 0;
89 
91  virtual const std::string& getName() const = 0;
92 
95 
97  const Frame* getParentFrame() const;
98 
103  bool descendsFrom(const Frame* _someFrame) const;
104 
106  bool isFrame() const;
107 
115  bool isQuiet() const;
116 
119  DART_DEPRECATED(6.2)
120  virtual void notifyTransformUpdate();
121 
124  virtual void dirtyTransform();
125 
127  bool needsTransformUpdate() const;
128 
131  DART_DEPRECATED(6.2)
132  virtual void notifyVelocityUpdate();
133 
136  virtual void dirtyVelocity();
137 
139  bool needsVelocityUpdate() const;
140 
143  DART_DEPRECATED(6.2)
144  virtual void notifyAccelerationUpdate();
145 
148  virtual void dirtyAcceleration();
149 
151  bool needsAccelerationUpdate() const;
152 
153 protected:
154 
158 
159  explicit Entity(ConstructFrameTag);
160 
164 
165  explicit Entity(ConstructAbstractTag);
166 
168  virtual void changeParentFrame(Frame* _newParentFrame);
169 
170 protected:
171 
174 
176  mutable bool mNeedTransformUpdate;
177  // TODO(JS): Rename this to mIsTransformDirty in DART 7
178 
180  mutable bool mNeedVelocityUpdate;
181  // TODO(JS): Rename this to mIsVelocityDirty in DART 7
182 
185  // TODO(JS): Rename this to mIsAccelerationDirty in DART 7
186 
189 
192 
195 
198 
201 
202 public:
203  //----------------------------------------------------------------------------
205  //----------------------------------------------------------------------------
206 
209 
212 
215 
218 
221 
222 private:
224  const bool mAmQuiet;
225 
227  bool mAmFrame;
228 };
229 
232 class Detachable : public virtual Entity
233 {
234 public:
236  explicit Detachable(Frame* _refFrame, bool _quiet);
237 
239  virtual void setParentFrame(Frame* _newParentFrame);
240 
241 protected:
244  Detachable();
245 
246 };
247 
248 } // namespace dynamics
249 } // namespace dart
250 
251 #endif // DART_DYNAMICS_ENTITY_HPP_
#define DART_DEPRECATED(version)
Definition: Deprecated.hpp:51
SlotRegister can be used as a public member for connecting slots to a private Signal member.
Definition: Signal.hpp:214
The Subject class is a base class for any object that wants to report when it gets destroyed.
Definition: Subject.hpp:58
The Detachable class is a special case of the Entity base class.
Definition: Entity.hpp:233
Detachable()
Constructor for inheriting classes, so they do not need to fill in the arguments.
Definition: Entity.cpp:285
virtual void setParentFrame(Frame *_newParentFrame)
Allows the user to change the parent Frame of this Entity.
Definition: Entity.cpp:279
Entity class is a base class for any objects that exist in the kinematic tree structure of DART.
Definition: Entity.hpp:60
Frame * getParentFrame()
Get the parent (reference) frame of this Entity.
Definition: Entity.cpp:82
virtual void dirtyVelocity()
Notify the velocity update of this Entity that its parent Frame's velocity is needed.
Definition: Entity.cpp:160
EntitySignal mAccelerationChangedSignal
Acceleration changed signal.
Definition: Entity.hpp:200
bool isFrame() const
True iff this Entity is also a Frame.
Definition: Entity.cpp:126
virtual const std::string & setName(const std::string &_name)=0
Set name.
bool mAmFrame
Whether or not this Entity is a Frame.
Definition: Entity.hpp:227
Entity()
Default constructor, delegates to Entity(ConstructAbstract_t)
Definition: Entity.cpp:69
ConstructFrameTag
Used when constructing a Frame class, because the Frame constructor will take care of setting up the ...
Definition: Entity.hpp:157
@ ConstructFrame
Definition: Entity.hpp:157
bool descendsFrom(const Frame *_someFrame) const
True if and only if this Entity depends on (i.e.
Definition: Entity.cpp:94
FrameChangedSignal mFrameChangedSignal
Frame changed signal.
Definition: Entity.hpp:188
const bool mAmQuiet
Whether or not this Entity is set to be quiet.
Definition: Entity.hpp:224
Frame * mParentFrame
Parent frame of this Entity.
Definition: Entity.hpp:173
virtual void notifyAccelerationUpdate()
Notify the acceleration of this Entity that its parent Frame's acceleration is needed.
Definition: Entity.cpp:176
virtual void changeParentFrame(Frame *_newParentFrame)
Used by derived classes to change their parent frames.
Definition: Entity.cpp:234
EntitySignal mTransformUpdatedSignal
Transform changed signal.
Definition: Entity.hpp:194
virtual ~Entity()
Destructor.
Definition: Entity.cpp:76
bool needsAccelerationUpdate() const
Returns true iff an acceleration update is needed for this Entity.
Definition: Entity.cpp:192
common::SlotRegister< EntitySignal > onVelocityChanged
Slot register for velocity updated signal.
Definition: Entity.hpp:217
virtual void dirtyAcceleration()
Notify the acceleration of this Entity that its parent Frame's acceleration is needed.
Definition: Entity.cpp:182
virtual const std::string & getName() const =0
Return the name of this Entity.
EntitySignal mVelocityChangedSignal
Velocity changed signal.
Definition: Entity.hpp:197
common::SlotRegister< FrameChangedSignal > onFrameChanged
Slot register for frame changed signal.
Definition: Entity.hpp:208
bool mNeedAccelerationUpdate
Does this Entity need an Acceleration update.
Definition: Entity.hpp:184
bool needsVelocityUpdate() const
Returns true iff a velocity update is needed for this Entity.
Definition: Entity.cpp:170
NameChangedSignal mNameChangedSignal
Name changed signal.
Definition: Entity.hpp:191
virtual void notifyVelocityUpdate()
Notify the velocity update of this Entity that its parent Frame's velocity is needed.
Definition: Entity.cpp:154
common::SlotRegister< EntitySignal > onTransformUpdated
Slot register for transform updated signal.
Definition: Entity.hpp:214
virtual void notifyTransformUpdate()
Notify the transformation update of this Entity that its parent Frame's pose is needed.
Definition: Entity.cpp:132
ConstructAbstractTag
Used when constructing a pure abstract class, because calling the Entity constructor is just a formal...
Definition: Entity.hpp:163
@ ConstructAbstract
Definition: Entity.hpp:163
bool mNeedTransformUpdate
Does this Entity need a Transform update.
Definition: Entity.hpp:176
Entity(const Entity &)=delete
bool isQuiet() const
Returns true if this Entity is set to be quiet.
Definition: Entity.cpp:120
bool mNeedVelocityUpdate
Does this Entity need a Velocity update.
Definition: Entity.hpp:180
common::SlotRegister< NameChangedSignal > onNameChanged
Slot register for name changed signal.
Definition: Entity.hpp:211
virtual void dirtyTransform()
Notify the transformation update of this Entity that its parent Frame's pose is needed.
Definition: Entity.cpp:138
common::SlotRegister< EntitySignal > onAccelerationChanged
Slot register for acceleration updated signal.
Definition: Entity.hpp:220
bool needsTransformUpdate() const
Returns true iff a transform update is needed for this Entity.
Definition: Entity.cpp:148
The Frame class serves as the backbone of DART's kinematic tree structure.
Definition: Frame.hpp:57
Definition: BulletCollisionDetector.cpp:63