An entity that contains a pointer to the user-defined controller. More...
#include <controllable_entity.h>
Public Types | |
typedef std::vector< CControllableEntity * > | TVector |
A vector of controllable entities. More... | |
typedef std::map< std::string, CControllableEntity * > | TMap |
A map of controllable entities, indexed by id. More... | |
Public Types inherited from argos::CEntity | |
typedef std::vector< CEntity * > | TVector |
A vector of entities. More... | |
typedef unordered_map< std::string, CEntity * > | TMap |
A map of entities. More... | |
typedef std::multimap< std::string, CEntity * > | TMultiMap |
A multi-map of entities. More... | |
Public Member Functions | |
ENABLE_VTABLE () | |
CControllableEntity (CComposableEntity *pc_parent) | |
Class constructor. More... | |
CControllableEntity (CComposableEntity *pc_parent, const std::string &str_id) | |
Class constructor. More... | |
virtual | ~CControllableEntity () |
Class destructor. More... | |
virtual void | Init (TConfigurationNode &t_tree) |
Initializes the state of the entity from the XML configuration tree. More... | |
virtual void | Reset () |
Resets the state of the entity to whatever it was after Init() or one of the standalone constructors was called. More... | |
virtual void | Destroy () |
Destroys the entity, undoing whatever was done by Init() or by the standalone constructor. More... | |
const CCI_Controller & | GetController () const |
Returns a reference to the associated controller. More... | |
CCI_Controller & | GetController () |
Returns a reference to the associated controller. More... | |
void | SetController (const std::string &str_controller_id) |
Creates and assigns a controller with the given id. More... | |
void | SetController (const std::string &str_controller_id, TConfigurationNode &t_controller_config) |
Creates and assigns a controller with the given id and the given XML parameters. More... | |
virtual void | Sense () |
Executes the CSimulatedSensor::Update() method for all associated sensors. More... | |
virtual void | ControlStep () |
Executes CCI_Controller::ControlStep(). More... | |
virtual void | Act () |
Executes the CSimulatedActuator::Update() method for all associated actuators. More... | |
virtual std::string | GetTypeDescription () const |
Returns a string label for this class. More... | |
void | AddCheckedRay (bool b_obstructed, const CRay3 &c_ray) |
Adds a ray to the list of checked rays. More... | |
void | AddIntersectionPoint (const CRay3 &c_ray, Real f_t_on_ray) |
Adds an intersection point to the list. More... | |
std::vector< std::pair< bool, CRay3 > > & | GetCheckedRays () |
Returns the list of checked rays. More... | |
std::vector< CVector3 > & | GetIntersectionPoints () |
Returns the list of intersection points. More... | |
Public Member Functions inherited from argos::CEntity | |
ENABLE_VTABLE () | |
CEntity (CComposableEntity *pc_parent) | |
Class constructor. More... | |
CEntity (CComposableEntity *pc_parent, const std::string &str_id) | |
Class constructor. More... | |
virtual | ~CEntity () |
Class destructor. More... | |
const std::string & | GetId () const |
Returns the id of this entity. More... | |
std::string | GetContext () const |
Returns the context of this entity. More... | |
bool | HasParent () const |
Returns true if this entity has a parent. More... | |
CEntity & | GetRootEntity () |
Returns the root entity containing this entity. More... | |
const CEntity & | GetRootEntity () const |
Returns the root entity containing this entity. More... | |
CComposableEntity & | GetParent () |
Returns this entity's parent. More... | |
const CComposableEntity & | GetParent () const |
Returns this entity's parent. More... | |
void | SetParent (CComposableEntity &c_parent) |
Sets this entity's parent. More... | |
virtual void | Update () |
Updates the state of this entity. More... | |
ssize_t | GetIndex () const |
Returns the entity index. More... | |
void | SetIndex (ssize_t n_idx) |
Sets the entity index. More... | |
bool | IsEnabled () const |
Returns true if the entity is enabled. More... | |
void | Enable () |
Enables the entity. More... | |
void | Disable () |
Disables the entity. More... | |
virtual void | SetEnabled (bool b_enabled) |
Enables or disables an entity. More... | |
TConfigurationNode * | GetConfigurationNode () |
Returns a pointer to the configuration node that was used to create this entity. More... | |
Public Member Functions inherited from argos::CBaseConfigurableResource | |
virtual | ~CBaseConfigurableResource () |
Class destructor. More... | |
Public Member Functions inherited from argos::EnableVTableFor< CEntity > | |
size_t | GetTagHelper (const DERIVED *) const |
Protected Attributes | |
CCI_Controller * | m_pcController |
The pointer to the associated controller. More... | |
std::map< std::string, CSimulatedActuator * > | m_mapActuators |
The map of actuators, indexed by actuator type (not implementation!) More... | |
std::map< std::string, CSimulatedSensor * > | m_mapSensors |
The map of sensors, indexed by sensor type (not implementation!) More... | |
std::vector< std::pair< bool, CRay3 > > | m_vecCheckedRays |
The list of checked rays. More... | |
std::vector< CVector3 > | m_vecIntersectionPoints |
The list of intersection points. More... | |
An entity that contains a pointer to the user-defined controller.
Definition at line 26 of file controllable_entity.h.
typedef std::map<std::string, CControllableEntity*> argos::CControllableEntity::TMap |
A map of controllable entities, indexed by id.
Definition at line 36 of file controllable_entity.h.
typedef std::vector<CControllableEntity*> argos::CControllableEntity::TVector |
A vector of controllable entities.
Definition at line 33 of file controllable_entity.h.
argos::CControllableEntity::CControllableEntity | ( | CComposableEntity * | pc_parent | ) |
Class constructor.
This constructor is meant to be used with the Init() method. After the execution of this constructor, the controller has not been associated to this entity yet.
pc_parent | The parent of this entity. |
Definition at line 19 of file controllable_entity.cpp.
argos::CControllableEntity::CControllableEntity | ( | CComposableEntity * | pc_parent, |
const std::string & | str_id | ||
) |
Class constructor.
This constructor is meant to be standalone. You should not call Init() after using this constructor, or memory leaks are likely to happen. After the execution of this constructor, a new controller instance must be associated to this entity using SetController().
pc_parent | The parent of this entity. |
str_id | The id of this entity. |
CARGoSException | if an error occurs in the creation of the controller |
Definition at line 26 of file controllable_entity.cpp.
|
virtual |
Class destructor.
Definition at line 35 of file controllable_entity.cpp.
|
virtual |
Executes the CSimulatedActuator::Update() method for all associated actuators.
Definition at line 229 of file controllable_entity.cpp.
|
inline |
Adds a ray to the list of checked rays.
This method is typically called by sensors to show which rays were shot and whether they intersected an object or not. These rays can then be drawn by a visualization (such as the Qt-OpenGL one) or analyzed for debugging purposes.
b_obstructed | true if the ray intersects an object. |
c_ray | The actual ray. |
Definition at line 178 of file controllable_entity.h.
|
inline |
Adds an intersection point to the list.
This method is typically called by sensors to show which rays were shot, whether they intersected an object or not and where the intersection occurred. Rays and intersection points can be drawn by a visualization (such as the Qt-OpenGL one) or analyzed for debugging purposes.
Definition at line 191 of file controllable_entity.h.
|
virtual |
Executes CCI_Controller::ControlStep().
CARGoSException | If no controller has been associated. |
Definition at line 217 of file controllable_entity.cpp.
|
virtual |
Destroys the entity, undoing whatever was done by Init() or by the standalone constructor.
Reimplemented from argos::CEntity.
Definition at line 92 of file controllable_entity.cpp.
argos::CControllableEntity::ENABLE_VTABLE | ( | ) |
|
inline |
Returns the list of checked rays.
Definition at line 204 of file controllable_entity.h.
const CCI_Controller & argos::CControllableEntity::GetController | ( | ) | const |
Returns a reference to the associated controller.
CARGoSException | If no controller has been associated. |
Definition at line 115 of file controllable_entity.cpp.
CCI_Controller & argos::CControllableEntity::GetController | ( | ) |
Returns a reference to the associated controller.
CARGoSException | If no controller has been associated. |
Definition at line 127 of file controllable_entity.cpp.
|
inline |
Returns the list of intersection points.
Definition at line 214 of file controllable_entity.h.
|
inlinevirtual |
Returns a string label for this class.
Reimplemented from argos::CEntity.
Definition at line 163 of file controllable_entity.h.
|
virtual |
Initializes the state of the entity from the XML configuration tree.
After the execution of this constructor, a new controller instance is associated to this entity.
CARGoSException | if an error occurs in the creation of the controller |
Reimplemented from argos::CEntity.
Definition at line 44 of file controllable_entity.cpp.
|
virtual |
Resets the state of the entity to whatever it was after Init() or one of the standalone constructors was called.
Reimplemented from argos::CEntity.
Definition at line 71 of file controllable_entity.cpp.
|
virtual |
Executes the CSimulatedSensor::Update() method for all associated sensors.
In addition, it clears the list of rays and intersection points.
Definition at line 205 of file controllable_entity.cpp.
void argos::CControllableEntity::SetController | ( | const std::string & | str_controller_id | ) |
Creates and assigns a controller with the given id.
As part of the creation of the controller, all the sensors and actuators are also created and initialized. For each sensor and actuator, this method calls SetRobot()
and Init()
, in this order. This method passes to CCI_Controller::Init() the <params>
section found in the controller section.
str_controller_id | The id of the controller as specified in the XML configuration file |
CARGoSException | if an error occurs in the creation of the controller |
Definition at line 139 of file controllable_entity.cpp.
void argos::CControllableEntity::SetController | ( | const std::string & | str_controller_id, |
TConfigurationNode & | t_controller_config | ||
) |
Creates and assigns a controller with the given id and the given XML parameters.
As part of the creation of the controller, all the sensors and actuators are also created and initialized. For each sensor and actuator, this method calls SetRobot()
and Init()
, in this order. This method passes the given XML tree to CCI_Controller::Init() instead of that found in the controller XML section.
str_controller_id | The id of the controller as specified in the XML configuration file |
t_controller_config | An XML tree to pass to CCI_Controller::Init() |
CARGoSException | if an error occurs in the creation of the controller |
Definition at line 148 of file controllable_entity.cpp.
|
protected |
The map of actuators, indexed by actuator type (not implementation!)
Definition at line 224 of file controllable_entity.h.
|
protected |
The map of sensors, indexed by sensor type (not implementation!)
Definition at line 227 of file controllable_entity.h.
|
protected |
The pointer to the associated controller.
Definition at line 221 of file controllable_entity.h.
|
protected |
The list of checked rays.
Definition at line 230 of file controllable_entity.h.
|
protected |
The list of intersection points.
Definition at line 233 of file controllable_entity.h.