8#include <argos3/core/simulator/actuator.h>
9#include <argos3/core/simulator/sensor.h>
10#include <argos3/core/simulator/simulator.h>
11#include <argos3/core/simulator/entity/composable_entity.h>
12#include <argos3/core/simulator/space/space.h>
21 m_pcController(nullptr) {}
27 const std::string& str_id) :
29 m_pcController(nullptr) {
49 std::string strControllerId;
100 it->second->Destroy();
105 it->second->Destroy();
161 for(itAct = itAct.begin(&tActuators);
162 itAct != itAct.end();
168 if(pcCIAct ==
nullptr) {
169 THROW_ARGOSEXCEPTION(
"BUG: actuator \"" << itAct->Value() <<
"\" does not inherit from CCI_Actuator");
172 pcCIAct->Init(*itAct);
179 for(itSens = itSens.begin(&tSensors);
180 itSens != itSens.end();
185 auto* pcCISens =
dynamic_cast<CCI_Sensor*
>(pcSens);
186 if(pcCISens ==
nullptr) {
187 THROW_ARGOSEXCEPTION(
"BUG: sensor \"" << itSens->Value() <<
"\" does not inherit from CCI_Sensor");
190 pcCISens->Init(*itSens);
210 it->second->Update();
232 it->second->Update();
250 CSpaceOperationAddControllableEntity,
251 CControllableEntity);
253 class CSpaceOperationRemoveControllableEntity :
public CSpaceOperationRemoveEntity {
255 void ApplyTo(CSpace& c_space, CControllableEntity& c_entity) {
256 c_space.RemoveControllableEntity(c_entity);
257 c_space.RemoveEntity(c_entity);
261 CSpaceOperationRemoveControllableEntity,
262 CControllableEntity);
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
#define REGISTER_SPACE_OPERATION(ACTION, OPERATION, ENTITY)
The namespace containing all the ARGoS related code.
ticpp::Iterator< ticpp::Element > TConfigurationNodeIterator
The iterator for the ARGoS configuration XML node.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
bool NodeExists(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns true if one of its child nodes has the wanted name.
TConfigurationNode & GetNode(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns the first of its child nodes with the wanted name.
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
The basic interface for all actuators.
The basic interface for a robot controller.
virtual void Init(TConfigurationNode &t_node)
Initializes the controller.
void AddSensor(const std::string &str_sensor_type, CCI_Sensor *pc_sensor)
Adds an sensor to this controller.
virtual void ControlStep()
Executes a control step.
void SetId(const std::string &str_id)
Sets the id of the robot associated to this controller.
virtual void Destroy()
The default implementation of this method does nothing.
void AddActuator(const std::string &str_actuator_type, CCI_Actuator *pc_actuator)
Adds an actuator to this controller.
virtual void Reset()
Resets the state of the controller to what it was right after Init() was executed.
CCI_Actuator::TMap & GetAllActuators()
Returns a map of the associated actuators.
CCI_Sensor::TMap & GetAllSensors()
Returns a map of the associated sensors.
The basic interface for all sensors.
The basic interface for a simulated actuator.
virtual void SetRobot(CComposableEntity &c_entity)=0
Sets the entity associated to this actuator.
Basic class for an entity that contains other entities.
An entity that contains a pointer to the user-defined controller.
std::map< std::string, CSimulatedActuator * > m_mapActuators
The map of actuators, indexed by actuator type (not implementation!)
std::vector< std::pair< bool, CRay3 > > m_vecCheckedRays
The list of checked rays.
virtual void Destroy()
Destroys the entity, undoing whatever was done by Init() or by the standalone constructor.
virtual void Sense()
Executes the CSimulatedSensor::Update() method for all associated sensors.
void SetController(const std::string &str_controller_id)
Creates and assigns a controller with the given id.
virtual void ControlStep()
Executes CCI_Controller::ControlStep().
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or one of the standalone constructors ...
const CCI_Controller & GetController() const
Returns a reference to the associated controller.
CCI_Controller * m_pcController
The pointer to the associated controller.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
std::vector< CVector3 > m_vecIntersectionPoints
The list of intersection points.
std::map< std::string, CSimulatedSensor * > m_mapSensors
The map of sensors, indexed by sensor type (not implementation!)
virtual ~CControllableEntity()
Class destructor.
virtual void Act()
Executes the CSimulatedActuator::Update() method for all associated actuators.
CControllableEntity(CComposableEntity *pc_parent)
Class constructor.
const std::string & GetId() const
Returns the id of this entity.
CComposableEntity & GetParent()
Returns this entity's parent.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
The basic interface for a simulated sensor.
virtual void SetRobot(CComposableEntity &c_entity)=0
Sets the entity associated to this sensor.
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
TConfigurationNode & GetConfigForController(const std::string &str_id)
Returns the XML portion relative to the controller with the given ID.
void AddEntity(ENTITY &c_entity)
Adds an entity of the given type.
virtual void AddControllableEntity(CControllableEntity &c_entity)
The exception that wraps all errors in ARGoS.
static TYPE * New(const std::string &str_label)
Creates a new object of type TYPE