Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a00439_source.php on line 2

Warning: include(): Failed opening 'php/utility.php' for inclusion (include_path='.:/usr/lib64/php') in /home/argos/argos3/doc/api/embedded/a00439_source.php on line 2
The ARGoS Website

physics_model.cpp
Go to the documentation of this file.
1 #include "physics_model.h"
2 #include <argos3/core/simulator/entity/embodied_entity.h>
3 #include <argos3/core/simulator/entity/composable_entity.h>
4 
5 namespace argos {
6 
7  /****************************************/
8  /****************************************/
9 
11  const std::string& str_id,
12  UInt32 un_index,
13  const CVector3& c_offset_position,
14  const CQuaternion& c_offset_orientation,
15  const CVector3& c_position,
16  const CQuaternion& c_orientation) :
17  Body(c_body),
18  Id(str_id),
19  Index(un_index),
20  OffsetPosition(c_offset_position),
21  OffsetOrientation(c_offset_orientation),
22  Position(c_position),
23  Orientation(c_orientation),
24  InUseCount(0) {
25  }
26 
27  /****************************************/
28  /****************************************/
29 
30  void SAnchor::Enable() {
32  }
33 
34  /****************************************/
35  /****************************************/
36 
39  }
40 
41  /****************************************/
42  /****************************************/
43 
45  CEmbodiedEntity& c_entity) :
46  m_cEngine(c_engine),
47  m_cEmbodiedEntity(c_entity),
48  m_sBoundingBox(),
49  m_vecAnchorMethodHolders(c_entity.GetAnchors().size(), NULL),
50  m_vecThunks(c_entity.GetAnchors().size(), NULL) {}
51 
52  /****************************************/
53  /****************************************/
54 
58  /*
59  * Update entity components
60  */
61  /* Get a reference to the root entity */
62  /* NOTE: here the cast is static because we know that an embodied entity MUST have a parent
63  * which, by definition, is a composable entity */
64  CComposableEntity& cRoot = static_cast<CComposableEntity&>(m_cEmbodiedEntity.GetRootEntity());
65  /* Update its components */
66  cRoot.UpdateComponents();
67  /*
68  * Check whether a transfer is necessary
69  */
70  if(!m_cEngine.IsPointContained(GetEmbodiedEntity().GetOriginAnchor().Position))
71  m_cEngine.ScheduleEntityForTransfer(m_cEmbodiedEntity);
72  }
73 
74  /****************************************/
75  /****************************************/
76 
78  std::vector<SAnchor*>& vecAnchors = m_cEmbodiedEntity.GetEnabledAnchors();
79  for(size_t i = 0; i < vecAnchors.size(); ++i) {
80  if(m_vecThunks[vecAnchors[i]->Index] != NULL) {
81  TThunk tThunk = m_vecThunks[vecAnchors[i]->Index];
82  (this->*tThunk)(*vecAnchors[i]);
83  }
84  }
85  }
86 
87  /****************************************/
88  /****************************************/
89 
90 }
A 3D vector class.
Definition: vector3.h:29
CPhysicsModel(CPhysicsEngine &c_engine, CEmbodiedEntity &c_entity)
virtual bool IsPointContained(const CVector3 &c_point)
Returns true if the given point is contained in this physics engine.
virtual void CalculateBoundingBox()=0
Calculates the axis-aligned box that contains the entire physics model.
CEmbodiedEntity & Body
The embodied entity that owns this anchor.
Definition: physics_model.h:40
This entity is a link to a body in the physics engine.
CEntity & GetRootEntity()
Returns the root entity containing this entity.
Definition: entity.cpp:115
std::vector< SAnchor * > & GetEnabledAnchors()
Returns a vector of enabled anchors for fast looping.
void Enable()
Enables this anchor.
virtual void UpdateEntityStatus()
Updates the status of the associated entity.
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
std::string Id
The id of the anchor.
Definition: physics_model.h:42
Basic class for an entity that contains other entities.
CEmbodiedEntity & GetEmbodiedEntity()
Returns the embodied entity associated to this physics model.
void Disable()
Disables this anchor.
virtual void CalculateAnchors()
Calculates the anchors associated to this model.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
virtual void ScheduleEntityForTransfer(CEmbodiedEntity &c_entity)
Schedules an entity of transfer.
void DisableAnchor(const std::string &str_id)
Disables an anchor.
SAnchor(CEmbodiedEntity &c_body, const std::string &str_id, UInt32 un_index, const CVector3 &c_offset_position, const CQuaternion &c_offset_orientation, const CVector3 &c_position, const CQuaternion &c_orientation)
Struct constructor.
void EnableAnchor(const std::string &str_id)
Enables an anchor.
virtual void UpdateComponents()
Calls the Update() method on all the components.