ARGoS  3
A parallel, multi-engine simulator for swarm robotics
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:

List of all members.

Public Types

typedef std::vector
< CControllableEntity * > 
TVector
 A vector of controllable entities.
typedef std::map< std::string,
CControllableEntity * > 
TMap
 A map of controllable entities, indexed by id.

Public Member Functions

 ENABLE_VTABLE ()
 CControllableEntity (CComposableEntity *pc_parent)
 Class constructor.
 CControllableEntity (CComposableEntity *pc_parent, const std::string &str_id)
 Class constructor.
virtual ~CControllableEntity ()
 Class destructor.
virtual void Init (TConfigurationNode &t_tree)
 Initializes the state of the entity from the XML configuration tree.
virtual void Reset ()
 Resets the state of the entity to whatever it was after Init() or one of the standalone constructors was called.
virtual void Destroy ()
 Destroys the entity, undoing whatever was done by Init() or by the standalone constructor.
const CCI_ControllerGetController () const
 Returns a reference to the associated controller.
CCI_ControllerGetController ()
 Returns a reference to the associated controller.
void SetController (const std::string &str_controller_id)
 Creates and assigns a controller with the given id.
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.
virtual void Sense ()
 Executes the CSimulatedSensor::Update() method for all associated sensors.
void ControlStep ()
 Executes CCI_Controller::ControlStep().
virtual void Act ()
 Executes the CSimulatedActuator::Update() method for all associated actuators.
virtual std::string GetTypeDescription () const
 Returns a string label for this class.
void AddCheckedRay (bool b_obstructed, const CRay3 &c_ray)
 Adds a ray to the list of checked rays.
void AddIntersectionPoint (const CRay3 &c_ray, Real f_t_on_ray)
 Adds an intersection point to the list.
std::vector< std::pair< bool,
CRay3 > > & 
GetCheckedRays ()
 Returns the list of checked rays.
std::vector< CVector3 > & GetIntersectionPoints ()
 Returns the list of intersection points.

Protected Attributes

CCI_Controllerm_pcController
 The pointer to the associated controller.
std::map< std::string,
CSimulatedActuator * > 
m_mapActuators
 The map of actuators, indexed by actuator type (not implementation!)
std::map< std::string,
CSimulatedSensor * > 
m_mapSensors
 The map of sensors, indexed by sensor type (not implementation!)
std::vector< std::pair< bool,
CRay3 > > 
m_vecCheckedRays
 The list of checked rays.
std::vector< CVector3m_vecIntersectionPoints
 The list of intersection points.

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

typedef std::map<std::string, CControllableEntity*> argos::CControllableEntity::TMap

A map of controllable entities, indexed by id.

Reimplemented from argos::CEntity.

Definition at line 36 of file controllable_entity.h.

A vector of controllable entities.

Reimplemented from argos::CEntity.

Definition at line 33 of file controllable_entity.h.


Constructor & Destructor Documentation

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.

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.

Class destructor.

Definition at line 35 of file controllable_entity.cpp.


Member Function Documentation

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.

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.

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.

Executes CCI_Controller::ControlStep().

Exceptions:
CARGoSExceptionIf no controller has been associated.
See also:
CCI_Controller

Definition at line 217 of file controllable_entity.cpp.

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.

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.

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.

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.

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.

virtual std::string argos::CControllableEntity::GetTypeDescription ( ) const [inline, virtual]

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.

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.

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.

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.

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.

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

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

Definition at line 224 of file controllable_entity.h.

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

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

Definition at line 227 of file controllable_entity.h.

The pointer to the associated controller.

Definition at line 221 of file controllable_entity.h.

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

The list of checked rays.

Definition at line 230 of file controllable_entity.h.

The list of intersection points.

Definition at line 233 of file controllable_entity.h.


The documentation for this class was generated from the following files: