argos::CControllableEntity Class Reference

An entity that contains a pointer to the user-defined controller. More...

#include <controllable_entity.h>

Inheritance diagram for argos::CControllableEntity:
Collaboration diagram for argos::CControllableEntity:

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_ControllerGetController () const
 Returns a reference to the associated controller. More...
 
CCI_ControllerGetController ()
 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...
 
const std::map< std::string, CSimulatedActuator * > & GetActuators () const
 Returns a map of actuators indexed by actuator type. More...
 
const std::map< std::string, CSimulatedSensor * > & GetSensors () const
 Returns a map of sensors indexed by sensor type. 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...
 
CEntityGetRootEntity ()
 Returns the root entity containing this entity. More...
 
const CEntityGetRootEntity () const
 Returns the root entity containing this entity. More...
 
CComposableEntityGetParent ()
 Returns this entity's parent. More...
 
const CComposableEntityGetParent () 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...
 
TConfigurationNodeGetConfigurationNode ()
 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_Controllerm_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< CVector3m_vecIntersectionPoints
 The list of intersection points. More...
 

Detailed Description

An entity that contains a pointer to the user-defined controller.

See also
CComposableEntity

Definition at line 26 of file controllable_entity.h.

Member Typedef Documentation

◆ TMap

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.

◆ TVector

A vector of controllable entities.

Definition at line 33 of file controllable_entity.h.

Constructor & Destructor Documentation

◆ CControllableEntity() [1/2]

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.

Parameters
pc_parentThe parent of this entity.

Definition at line 19 of file controllable_entity.cpp.

◆ CControllableEntity() [2/2]

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().

Parameters
pc_parentThe parent of this entity.
str_idThe id of this entity.
Exceptions
CARGoSExceptionif an error occurs in the creation of the controller
See also
SetController()

Definition at line 26 of file controllable_entity.cpp.

◆ ~CControllableEntity()

argos::CControllableEntity::~CControllableEntity ( )
virtual

Class destructor.

Definition at line 35 of file controllable_entity.cpp.

Member Function Documentation

◆ Act()

void argos::CControllableEntity::Act ( )
virtual

Executes the CSimulatedActuator::Update() method for all associated actuators.

See also
CSimulatedActuator

Definition at line 229 of file controllable_entity.cpp.

◆ AddCheckedRay()

void argos::CControllableEntity::AddCheckedRay ( bool  b_obstructed,
const CRay3 c_ray 
)
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.

Parameters
b_obstructedtrue if the ray intersects an object.
c_rayThe actual ray.
See also
CRay3
AddIntersectionPoint()

Definition at line 178 of file controllable_entity.h.

◆ AddIntersectionPoint()

void argos::CControllableEntity::AddIntersectionPoint ( const CRay3 c_ray,
Real  f_t_on_ray 
)
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.

See also
AddCheckedRay()

Definition at line 191 of file controllable_entity.h.

◆ ControlStep()

void argos::CControllableEntity::ControlStep ( )
virtual

Executes CCI_Controller::ControlStep().

Exceptions
CARGoSExceptionIf no controller has been associated.
See also
CCI_Controller

Definition at line 217 of file controllable_entity.cpp.

◆ Destroy()

void argos::CControllableEntity::Destroy ( )
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.

◆ ENABLE_VTABLE()

argos::CControllableEntity::ENABLE_VTABLE ( )

◆ GetActuators()

const std::map<std::string, CSimulatedActuator*>& argos::CControllableEntity::GetActuators ( ) const
inline

Returns a map of actuators indexed by actuator type.

Returns
a map of actuators indexed by actuator type.

Definition at line 222 of file controllable_entity.h.

◆ GetCheckedRays()

std::vector<std::pair<bool, CRay3> >& argos::CControllableEntity::GetCheckedRays ( )
inline

Returns the list of checked rays.

Returns
The list of checked rays.
See also
AddCheckedRay()
AddIntersectionPoint()

Definition at line 204 of file controllable_entity.h.

◆ GetController() [1/2]

CCI_Controller & argos::CControllableEntity::GetController ( )

Returns a reference to the associated controller.

Returns
A reference to the associated controller.
Exceptions
CARGoSExceptionIf no controller has been associated.
See also
CCI_Controller

Definition at line 127 of file controllable_entity.cpp.

◆ GetController() [2/2]

const CCI_Controller & argos::CControllableEntity::GetController ( ) const

Returns a reference to the associated controller.

Returns
A reference to the associated controller.
Exceptions
CARGoSExceptionIf no controller has been associated.
See also
CCI_Controller

Definition at line 115 of file controllable_entity.cpp.

◆ GetIntersectionPoints()

std::vector<CVector3>& argos::CControllableEntity::GetIntersectionPoints ( )
inline

Returns the list of intersection points.

Returns
The list of intersection points.
See also
AddCheckedRay()
AddIntersectionPoint()

Definition at line 214 of file controllable_entity.h.

◆ GetSensors()

const std::map<std::string, CSimulatedSensor*>& argos::CControllableEntity::GetSensors ( ) const
inline

Returns a map of sensors indexed by sensor type.

Returns
a map of sensors indexed by sensor type.

Definition at line 230 of file controllable_entity.h.

◆ GetTypeDescription()

virtual std::string argos::CControllableEntity::GetTypeDescription ( ) const
inlinevirtual

Returns a string label for this class.

Returns
A string label for this class.

Reimplemented from argos::CEntity.

Definition at line 163 of file controllable_entity.h.

◆ Init()

void argos::CControllableEntity::Init ( TConfigurationNode t_tree)
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.

Exceptions
CARGoSExceptionif an error occurs in the creation of the controller
See also
CCI_Controller
SetController()

Reimplemented from argos::CEntity.

Definition at line 44 of file controllable_entity.cpp.

◆ Reset()

void argos::CControllableEntity::Reset ( )
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.

◆ Sense()

void argos::CControllableEntity::Sense ( )
virtual

Executes the CSimulatedSensor::Update() method for all associated sensors.

In addition, it clears the list of rays and intersection points.

See also
CSimulatedSensor
m_vecCheckedRays;
m_vecIntersectionPoints;

Definition at line 205 of file controllable_entity.cpp.

◆ SetController() [1/2]

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.

Parameters
str_controller_idThe id of the controller as specified in the XML configuration file
Exceptions
CARGoSExceptionif an error occurs in the creation of the controller
See also
CCI_Controller::Init()
CSimulatedSensor::SetRobot()
CSimulatedActuator::SetRobot()
CCI_Sensor::Init()
CCI_Actuator::Init()

Definition at line 139 of file controllable_entity.cpp.

◆ SetController() [2/2]

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.

Parameters
str_controller_idThe id of the controller as specified in the XML configuration file
t_controller_configAn XML tree to pass to CCI_Controller::Init()
Exceptions
CARGoSExceptionif an error occurs in the creation of the controller
See also
CCI_Controller::Init()
CSimulatedSensor::SetRobot()
CSimulatedActuator::SetRobot()
CCI_Sensor::Init()
CCI_Actuator::Init()

Definition at line 148 of file controllable_entity.cpp.

Member Data Documentation

◆ m_mapActuators

std::map<std::string, CSimulatedActuator*> argos::CControllableEntity::m_mapActuators
protected

The map of actuators, indexed by actuator type (not implementation!)

Definition at line 240 of file controllable_entity.h.

◆ m_mapSensors

std::map<std::string, CSimulatedSensor*> argos::CControllableEntity::m_mapSensors
protected

The map of sensors, indexed by sensor type (not implementation!)

Definition at line 243 of file controllable_entity.h.

◆ m_pcController

CCI_Controller* argos::CControllableEntity::m_pcController
protected

The pointer to the associated controller.

Definition at line 237 of file controllable_entity.h.

◆ m_vecCheckedRays

std::vector<std::pair<bool, CRay3> > argos::CControllableEntity::m_vecCheckedRays
protected

The list of checked rays.

Definition at line 246 of file controllable_entity.h.

◆ m_vecIntersectionPoints

std::vector<CVector3> argos::CControllableEntity::m_vecIntersectionPoints
protected

The list of intersection points.

Definition at line 249 of file controllable_entity.h.