6 #include <scene/dynamic/DynObject.h>
7 #include <scene/dynamic/DynMotion.h>
8 #include <rigidmotion/RigidMotionEngine.h>
9 #include <scene/dynamic/DynMotionEngine.h>
10 #include <adt/grove/KDGroveSubject.h>
11 #include <sim/tools/VoidStepLoop.h>
13 using std::shared_ptr;
14 using std::make_shared;
43 friend class boost::serialization::access;
50 template <
typename Archive>
51 void serialize(Archive &ar,
const unsigned int version){
52 boost::serialization::split_member(ar, *
this, version);
59 template <
typename Archive>
60 void save(Archive &ar,
const unsigned int version)
const{
61 boost::serialization::void_cast_register<DynMovingObject, DynObject>();
62 ar &boost::serialization::base_object<DynObject>(*
this);
73 template <
typename Archive>
74 void load(Archive &ar,
const unsigned int version) {
75 boost::serialization::void_cast_register<DynMovingObject, DynObject>();
76 ar &boost::serialization::base_object<DynObject>(*
this);
150 kdGroveObserver(nullptr),
151 observerStepLoop(1, [&] () -> void {doObserverUpdate();})
158 kdGroveObserver(nullptr),
159 observerStepLoop(1, [&] () -> void {doObserverUpdate();})
166 kdGroveObserver(nullptr),
167 observerStepLoop(1, [&] () -> void {doObserverUpdate();})
174 kdGroveObserver(nullptr),
175 observerStepLoop(1, [&] () -> void {doObserverUpdate();})
211 virtual bool doSimStep();
221 virtual void doObserverUpdate();
240 bool applyDynMotionQueue(
241 std::function<arma::mat()> matrixFromPrimitives,
242 std::function<
void(arma::mat
const &X)> matrixToPrimitives,
243 std::function<
bool()> queueHasNext,
244 std::function<shared_ptr<DynMotion>()> queueNext
255 {positionMotionQueue.push_back(dm);}
264 {
return _next(positionMotionQueue);}
269 {positionMotionQueue.clear();}
276 {
return !positionMotionQueue.empty();}
282 {normalMotionQueue.push_back(dm);}
291 {
return _next(normalMotionQueue);}
296 {normalMotionQueue.clear();}
303 {
return !normalMotionQueue.empty();}
315 shared_ptr<DynMotion> _next(deque<shared_ptr<DynMotion>> &deck);
325 void registerObserverGrove(shared_ptr<KDGrove> kdGroveObserver)
override;
330 void unregisterObserverGrove()
override;
334 void setGroveSubjectId(std::size_t
const id)
override;
338 std::size_t getGroveSubjectId()
override;
Adapter which wraps a rigid motion engine to make it fit the dynamic Helios context.
Definition: DynMotionEngine.h:23
Implementation of a dynamic object which supports dynamic motions (extended rigid motions)
Definition: DynMovingObject.h:39
virtual void doObserverUpdate()
Handle update notifications to the subscribed observer. It is, notify the observer that it has been u...
Definition: DynMovingObject.cpp:66
deque< shared_ptr< DynMotion > > positionMotionQueue
Queue of motions to be applied to the position of each primitive.
Definition: DynMovingObject.h:95
DynMovingObject(string const id, vector< Primitive * > const &primitives)
Definition: DynMovingObject.h:172
bool normalMotionQueueHasNext() const
Check if normal motion queue has a next dynamic motion or not.
Definition: DynMovingObject.h:302
deque< shared_ptr< DynMotion > > normalMotionQueue
Queue of motions to be applied to the normal vector of each primitive.
Definition: DynMovingObject.h:105
DynMotionEngine dme
The dynamic motion engine to apply dynamic motions.
Definition: DynMovingObject.h:111
VoidStepLoop observerStepLoop
Handle how many consecutive updates must elapse so the observer is notified.
Definition: DynMovingObject.h:133
shared_ptr< DynMotion > nextPositionMotion()
Retrieve the first dynamic motion in the position motion queue.
Definition: DynMovingObject.h:263
void setObserverStepInterval(int const stepInterval)
Set the step interval between consecutive observer update notifications.
Definition: DynMovingObject.h:356
void load(Archive &ar, const unsigned int version)
Load a serialized dynamic moving object from a stream of bytes.
Definition: DynMovingObject.h:74
DynMovingObject()
Definition: DynMovingObject.h:141
size_t groveSubjectId
The identifier of the dynamic moving object as subject of a KDGrove.
Definition: DynMovingObject.h:124
shared_ptr< DynMotion > nextNormalMotion()
Retrieve the first dynamic motion in the normal motion queue.
Definition: DynMovingObject.h:290
void pushNormalMotion(shared_ptr< DynMotion > const dm)
Push given dynamic motion to the normal motion queue.
Definition: DynMovingObject.h:281
void clearNormalMotionQueue()
Remove all dynamic motions from the normal motion queue.
Definition: DynMovingObject.h:295
void clearPositionMotionQueue()
Remove all dynamic motions from the position motion queue.
Definition: DynMovingObject.h:268
void serialize(Archive &ar, const unsigned int version)
Serialize a dynamic moving object to a stream of bytes.
Definition: DynMovingObject.h:51
void save(Archive &ar, const unsigned int version) const
Save a serialized dynamic moving object to a stream of bytes.
Definition: DynMovingObject.h:60
int getObserverStepInterval() const
Get the step interval between consecutive observer update notifications.
Definition: DynMovingObject.h:368
void pushPositionMotion(shared_ptr< DynMotion > const dm)
Push given dynamic motion to the position motion queue.
Definition: DynMovingObject.h:254
bool positionMotionQueueHasNext() const
Check if position motion queue has a next dynamic motion or not.
Definition: DynMovingObject.h:275
std::shared_ptr< KDGrove > kdGroveObserver
The observer grove to which the dynamic moving object is registered.
Definition: DynMovingObject.h:118
DynMovingObject(string const id)
Definition: DynMovingObject.h:156
DynMovingObject(vector< Primitive * > const &primitives)
Definition: DynMovingObject.h:164
DynMovingObject(ScenePart const &sp, bool const shallowPrimitives=false)
Definition: DynMovingObject.h:148
ObjectType getType() const override
Definition: DynMovingObject.h:345
Dynamic object base implementation.
Definition: DynObject.h:23
Interface defining the behaviors that must be supported by any object that can notify to a KDGrove.
Definition: KDGroveSubject.h:20
Grove of KDTrees. It supports both static and dynamic KDTrees, handling each accordingly.
Definition: KDGrove.h:20
Class representing a scene part.
Definition: ScenePart.h:20
ObjectType
Specify the type of scene part / object. By default, the ScenePart is a static object.
Definition: ScenePart.h:53
virtual int getStepInterval() const
Obtain the step interval.
Definition: StepLoop.h:108
virtual void setStepInterval(int const stepInterval)
Set the step interval.
Definition: StepLoop.h:114
Class extending StepLoop to support functions with no return.
Definition: VoidStepLoop.h:15
Class to handle operations with rigid motions.
Definition: RigidMotionEngine.h:19