DART  6.10.1
Entity.hpp
Go to the documentation of this file.
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_ENTITY_HPP_
34 #define DART_DYNAMICS_ENTITY_HPP_
35 
36 #include <string>
37 #include <vector>
38 #include <Eigen/Core>
39 
41 #include "dart/common/Signal.hpp"
42 #include "dart/common/Subject.hpp"
43 #include "dart/dynamics/Shape.hpp"
45 
46 namespace dart {
47 namespace dynamics {
48 
49 class Frame;
50 
60 class Entity : public virtual common::Subject
61 {
62 public:
63  friend class Frame;
64 
65  using EntitySignal = common::Signal<void(const Entity*)>;
67  const Entity*, const Frame* _oldFrame, const Frame* _newFrame)>;
69  const Entity*, const std::string& _oldName, const std::string& _newName)>;
70 
72  explicit Entity(Frame* _refFrame, bool _quiet);
73 
75  Entity();
76 
77  Entity(const Entity&) = delete;
78 
80  virtual ~Entity();
81 
85  virtual const std::string& setName(const std::string& _name) = 0;
86 
88  virtual const std::string& getName() const = 0;
89 
92 
94  const Frame* getParentFrame() const;
95 
102  bool descendsFrom(const Frame* _someFrame) const;
103 
105  bool isFrame() const;
106 
114  bool isQuiet() const;
115 
118  DART_DEPRECATED(6.2)
119  virtual void notifyTransformUpdate();
120 
123  virtual void dirtyTransform();
124 
126  bool needsTransformUpdate() const;
127 
130  DART_DEPRECATED(6.2)
131  virtual void notifyVelocityUpdate();
132 
135  virtual void dirtyVelocity();
136 
138  bool needsVelocityUpdate() const;
139 
142  DART_DEPRECATED(6.2)
143  virtual void notifyAccelerationUpdate();
144 
147  virtual void dirtyAcceleration();
148 
150  bool needsAccelerationUpdate() const;
151 
152 protected:
156  {
158  };
159 
160  explicit Entity(ConstructFrameTag);
161 
165  {
167  };
168 
169  explicit Entity(ConstructAbstractTag);
170 
172  virtual void changeParentFrame(Frame* _newParentFrame);
173 
174 protected:
177 
179  mutable bool mNeedTransformUpdate;
180  // TODO(JS): Rename this to mIsTransformDirty in DART 7
181 
183  mutable bool mNeedVelocityUpdate;
184  // TODO(JS): Rename this to mIsVelocityDirty in DART 7
185 
188  // TODO(JS): Rename this to mIsAccelerationDirty in DART 7
189 
192 
195 
198 
201 
204 
205 public:
206  //----------------------------------------------------------------------------
208  //----------------------------------------------------------------------------
209 
212 
215 
218 
221 
224 
225 private:
227  const bool mAmQuiet;
228 
230  bool mAmFrame;
231 };
233 
237 class Detachable : public virtual Entity
238 {
239 public:
241  explicit Detachable(Frame* _refFrame, bool _quiet);
242 
244  virtual void setParentFrame(Frame* _newParentFrame);
245 
246 protected:
249  Detachable();
250 };
252 
253 } // namespace dynamics
254 } // namespace dart
255 
256 #endif // DART_DYNAMICS_ENTITY_HPP_
#define DART_DECLARE_CLASS_WITH_VIRTUAL_BASE_END
Definition: ClassWithVirtualBase.hpp:44
#define DART_DECLARE_CLASS_WITH_VIRTUAL_BASE_BEGIN
Definition: ClassWithVirtualBase.hpp:43
#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:229
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:238
Detachable()
Constructor for inheriting classes, so they do not need to fill in the arguments.
Definition: Entity.cpp:284
virtual void setParentFrame(Frame *_newParentFrame)
Allows the user to change the parent Frame of this Entity.
Definition: Entity.cpp:278
Entity class is a base class for any objects that exist in the kinematic tree structure of DART.
Definition: Entity.hpp:61
Frame * getParentFrame()
Get the parent (reference) frame of this Entity.
Definition: Entity.cpp:81
virtual void dirtyVelocity()
Notify the velocity update of this Entity that its parent Frame's velocity is needed.
Definition: Entity.cpp:159
EntitySignal mAccelerationChangedSignal
Acceleration changed signal.
Definition: Entity.hpp:203
bool isFrame() const
True iff this Entity is also a Frame.
Definition: Entity.cpp:125
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:230
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:156
@ ConstructFrame
Definition: Entity.hpp:157
bool descendsFrom(const Frame *_someFrame) const
Returns true if and only if this Entity is itself (i.e.
Definition: Entity.cpp:93
FrameChangedSignal mFrameChangedSignal
Frame changed signal.
Definition: Entity.hpp:191
const bool mAmQuiet
Whether or not this Entity is set to be quiet.
Definition: Entity.hpp:227
Frame * mParentFrame
Parent frame of this Entity.
Definition: Entity.hpp:176
virtual void notifyAccelerationUpdate()
Notify the acceleration of this Entity that its parent Frame's acceleration is needed.
Definition: Entity.cpp:175
virtual void changeParentFrame(Frame *_newParentFrame)
Used by derived classes to change their parent frames.
Definition: Entity.cpp:233
EntitySignal mTransformUpdatedSignal
Transform changed signal.
Definition: Entity.hpp:197
virtual ~Entity()
Destructor.
Definition: Entity.cpp:75
bool needsAccelerationUpdate() const
Returns true iff an acceleration update is needed for this Entity.
Definition: Entity.cpp:191
common::SlotRegister< EntitySignal > onVelocityChanged
Slot register for velocity updated signal.
Definition: Entity.hpp:220
virtual void dirtyAcceleration()
Notify the acceleration of this Entity that its parent Frame's acceleration is needed.
Definition: Entity.cpp:181
virtual const std::string & getName() const =0
Return the name of this Entity.
EntitySignal mVelocityChangedSignal
Velocity changed signal.
Definition: Entity.hpp:200
common::SlotRegister< FrameChangedSignal > onFrameChanged
Slot register for frame changed signal.
Definition: Entity.hpp:211
bool mNeedAccelerationUpdate
Does this Entity need an Acceleration update.
Definition: Entity.hpp:187
bool needsVelocityUpdate() const
Returns true iff a velocity update is needed for this Entity.
Definition: Entity.cpp:169
NameChangedSignal mNameChangedSignal
Name changed signal.
Definition: Entity.hpp:194
virtual void notifyVelocityUpdate()
Notify the velocity update of this Entity that its parent Frame's velocity is needed.
Definition: Entity.cpp:153
common::SlotRegister< EntitySignal > onTransformUpdated
Slot register for transform updated signal.
Definition: Entity.hpp:217
virtual void notifyTransformUpdate()
Notify the transformation update of this Entity that its parent Frame's pose is needed.
Definition: Entity.cpp:131
ConstructAbstractTag
Used when constructing a pure abstract class, because calling the Entity constructor is just a formal...
Definition: Entity.hpp:165
@ ConstructAbstract
Definition: Entity.hpp:166
bool mNeedTransformUpdate
Does this Entity need a Transform update.
Definition: Entity.hpp:179
Entity(const Entity &)=delete
bool isQuiet() const
Returns true if this Entity is set to be quiet.
Definition: Entity.cpp:119
bool mNeedVelocityUpdate
Does this Entity need a Velocity update.
Definition: Entity.hpp:183
common::SlotRegister< NameChangedSignal > onNameChanged
Slot register for name changed signal.
Definition: Entity.hpp:214
virtual void dirtyTransform()
Notify the transformation update of this Entity that its parent Frame's pose is needed.
Definition: Entity.cpp:137
common::SlotRegister< EntitySignal > onAccelerationChanged
Slot register for acceleration updated signal.
Definition: Entity.hpp:223
bool needsTransformUpdate() const
Returns true iff a transform update is needed for this Entity.
Definition: Entity.cpp:147
The Frame class serves as the backbone of DART's kinematic tree structure.
Definition: Frame.hpp:58
Definition: BulletCollisionDetector.cpp:65