ARGoS  3
A parallel, multi-engine simulator for swarm robotics
controllable_entity.h
Go to the documentation of this file.
1 
7 #ifndef CONTROLLABLE_ENTITY_H
8 #define CONTROLLABLE_ENTITY_H
9 
10 namespace argos {
11  class CControllableEntity;
12  class CSimulatedActuator;
13  class CSimulatedSensor;
14 }
15 
16 #include <argos3/core/simulator/entity/entity.h>
17 #include <argos3/core/control_interface/ci_controller.h>
18 #include <argos3/core/utility/math/ray3.h>
19 
20 namespace argos {
21 
26  class CControllableEntity : public CEntity {
27 
28  public:
29 
30  ENABLE_VTABLE();
31 
33  typedef std::vector<CControllableEntity*> TVector;
34 
36  typedef std::map<std::string, CControllableEntity*> TMap;
37 
38  public:
39 
48 
62  const std::string& str_id);
63 
67  virtual ~CControllableEntity();
68 
77  virtual void Init(TConfigurationNode& t_tree);
78 
82  virtual void Reset();
83 
87  virtual void Destroy();
88 
95  const CCI_Controller& GetController() const;
96 
104 
120  void SetController(const std::string& str_controller_id);
121 
138  void SetController(const std::string& str_controller_id,
139  TConfigurationNode& t_controller_config);
140 
148  virtual void Sense();
149 
155  virtual void ControlStep();
156 
161  virtual void Act();
162 
163  virtual std::string GetTypeDescription() const {
164  return "controller";
165  }
166 
178  inline void AddCheckedRay(bool b_obstructed,
179  const CRay3& c_ray) {
180  m_vecCheckedRays.push_back(std::make_pair(b_obstructed, c_ray));
181  }
182 
191  inline void AddIntersectionPoint(const CRay3& c_ray,
192  Real f_t_on_ray) {
193  CVector3 cPoint;
194  c_ray.GetPoint(cPoint, f_t_on_ray);
195  m_vecIntersectionPoints.push_back(cPoint);
196  }
197 
204  inline std::vector<std::pair<bool, CRay3> >& GetCheckedRays() {
205  return m_vecCheckedRays;
206  }
207 
214  inline std::vector<CVector3>& GetIntersectionPoints() {
216  }
217 
218  protected:
219 
222 
224  std::map<std::string, CSimulatedActuator*> m_mapActuators;
225 
227  std::map<std::string, CSimulatedSensor*> m_mapSensors;
228 
230  std::vector<std::pair<bool, CRay3> > m_vecCheckedRays;
231 
233  std::vector<CVector3> m_vecIntersectionPoints;
234 
235  };
236 
237 }
238 
239 #endif
argos::CRay3::GetPoint
void GetPoint(CVector3 &c_point, Real f_t) const
Definition: ray3.h:109
argos::CControllableEntity::ControlStep
virtual void ControlStep()
Executes CCI_Controller::ControlStep().
Definition: controllable_entity.cpp:217
argos::CControllableEntity::AddIntersectionPoint
void AddIntersectionPoint(const CRay3 &c_ray, Real f_t_on_ray)
Adds an intersection point to the list.
Definition: controllable_entity.h:191
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CVector3
A 3D vector class.
Definition: vector3.h:29
argos::CControllableEntity::GetCheckedRays
std::vector< std::pair< bool, CRay3 > > & GetCheckedRays()
Returns the list of checked rays.
Definition: controllable_entity.h:204
argos::CComposableEntity
Basic class for an entity that contains other entities.
Definition: composable_entity.h:32
argos::CControllableEntity::m_mapActuators
std::map< std::string, CSimulatedActuator * > m_mapActuators
The map of actuators, indexed by actuator type (not implementation!)
Definition: controllable_entity.h:224
argos::CRay3
Definition: ray3.h:19
argos::CControllableEntity::GetTypeDescription
virtual std::string GetTypeDescription() const
Returns a string label for this class.
Definition: controllable_entity.h:163
argos::CControllableEntity::m_pcController
CCI_Controller * m_pcController
The pointer to the associated controller.
Definition: controllable_entity.h:221
argos::TConfigurationNode
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Definition: argos_configuration.h:27
argos::CControllableEntity::AddCheckedRay
void AddCheckedRay(bool b_obstructed, const CRay3 &c_ray)
Adds a ray to the list of checked rays.
Definition: controllable_entity.h:178
argos::CControllableEntity::Init
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
Definition: controllable_entity.cpp:44
argos::CControllableEntity::m_vecIntersectionPoints
std::vector< CVector3 > m_vecIntersectionPoints
The list of intersection points.
Definition: controllable_entity.h:233
argos::CControllableEntity::Act
virtual void Act()
Executes the CSimulatedActuator::Update() method for all associated actuators.
Definition: controllable_entity.cpp:229
argos::CControllableEntity::~CControllableEntity
virtual ~CControllableEntity()
Class destructor.
Definition: controllable_entity.cpp:35
argos::CControllableEntity::m_mapSensors
std::map< std::string, CSimulatedSensor * > m_mapSensors
The map of sensors, indexed by sensor type (not implementation!)
Definition: controllable_entity.h:227
argos::CControllableEntity::Reset
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or one of the standalone constructors ...
Definition: controllable_entity.cpp:71
argos::CControllableEntity::SetController
void SetController(const std::string &str_controller_id)
Creates and assigns a controller with the given id.
Definition: controllable_entity.cpp:139
argos::CControllableEntity::GetController
const CCI_Controller & GetController() const
Returns a reference to the associated controller.
Definition: controllable_entity.cpp:115
argos::CEntity
The basic entity type.
Definition: entity.h:89
argos::CControllableEntity::m_vecCheckedRays
std::vector< std::pair< bool, CRay3 > > m_vecCheckedRays
The list of checked rays.
Definition: controllable_entity.h:230
argos::CControllableEntity::ENABLE_VTABLE
ENABLE_VTABLE()
argos::CControllableEntity::CControllableEntity
CControllableEntity(CComposableEntity *pc_parent)
Class constructor.
Definition: controllable_entity.cpp:19
argos::CControllableEntity::Sense
virtual void Sense()
Executes the CSimulatedSensor::Update() method for all associated sensors.
Definition: controllable_entity.cpp:205
argos::CControllableEntity::GetIntersectionPoints
std::vector< CVector3 > & GetIntersectionPoints()
Returns the list of intersection points.
Definition: controllable_entity.h:214
argos::CControllableEntity
An entity that contains a pointer to the user-defined controller.
Definition: controllable_entity.h:26
Real
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
argos::CControllableEntity::TMap
std::map< std::string, CControllableEntity * > TMap
A map of controllable entities, indexed by id.
Definition: controllable_entity.h:36
argos::CControllableEntity::Destroy
virtual void Destroy()
Destroys the entity, undoing whatever was done by Init() or by the standalone constructor.
Definition: controllable_entity.cpp:92
argos::CCI_Controller
The basic interface for a robot controller.
Definition: ci_controller.h:30
argos::CControllableEntity::TVector
std::vector< CControllableEntity * > TVector
A vector of controllable entities.
Definition: controllable_entity.h:33