ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
Go to the documentation of this file.
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(NULL) {}
27 const std::string& str_id) :
29 m_pcController(NULL) {
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 == NULL) {
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();
186 if(pcCISens == NULL) {
187 THROW_ARGOSEXCEPTION(
"BUG: sensor \"" << itSens->Value() <<
"\" does not inherit from CCI_Sensor");
190 pcCISens->
Init(*itSens);
208 for(std::map<std::string, CSimulatedSensor*>::iterator it =
m_mapSensors.begin();
210 it->second->Update();
230 for(std::map<std::string, CSimulatedActuator*>::iterator it =
m_mapActuators.begin();
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);
virtual void ControlStep()
Executes CCI_Controller::ControlStep().
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
const std::string & GetId() const
Returns the id of this entity.
void AddSensor(const std::string &str_sensor_type, CCI_Sensor *pc_sensor)
Adds an sensor to this controller.
The namespace containing all the ARGoS related code.
virtual void Init(TConfigurationNode &t_node)
Initializes the controller.
REGISTER_SPACE_OPERATION(CSpaceOperationAddEntity, CSpaceOperationAddCFloorEntity, CFloorEntity)
CCI_Actuator::TMap & GetAllActuators()
Returns a map of the associated actuators.
Basic class for an entity that contains other entities.
std::map< std::string, CSimulatedActuator * > m_mapActuators
The map of actuators, indexed by actuator type (not implementation!)
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.
The exception that wraps all errors in ARGoS.
virtual void SetRobot(CComposableEntity &c_entity)=0
Sets the entity associated to this actuator.
The basic interface for a simulated actuator.
CCI_Controller * m_pcController
The pointer to the associated controller.
void AddActuator(const std::string &str_actuator_type, CCI_Actuator *pc_actuator)
Adds an actuator to this controller.
virtual void Destroy()
The default implementation of this method does nothing.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
TConfigurationNode & GetConfigForController(const std::string &str_id)
Returns the XML portion relative to the controller with the given ID.
The basic interface for all sensors.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
static TYPE * New(const std::string &str_label)
Creates a new object of type TYPE
CCI_Sensor::TMap & GetAllSensors()
Returns a map of the associated sensors.
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
std::vector< CVector3 > m_vecIntersectionPoints
The list of intersection points.
void AddEntity(ENTITY &c_entity)
Adds an entity of the given type.
ticpp::Iterator< ticpp::Element > TConfigurationNodeIterator
The iterator for the ARGoS configuration XML node.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
virtual void Act()
Executes the CSimulatedActuator::Update() method for all associated actuators.
virtual void AddControllableEntity(CControllableEntity &c_entity)
virtual ~CControllableEntity()
Class destructor.
The basic interface for all actuators.
std::map< std::string, CSimulatedSensor * > m_mapSensors
The map of sensors, indexed by sensor type (not implementation!)
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or one of the standalone constructors ...
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.
void SetController(const std::string &str_controller_id)
Creates and assigns a controller with the given id.
virtual void ControlStep()
Executes a control step.
const CCI_Controller & GetController() const
Returns a reference to the associated controller.
CComposableEntity & GetParent()
Returns this entity's parent.
std::vector< std::pair< bool, CRay3 > > m_vecCheckedRays
The list of checked rays.
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
CControllableEntity(CComposableEntity *pc_parent)
Class constructor.
virtual void Reset()
Resets the state of the controller to what it was right after Init() was executed.
virtual void Sense()
Executes the CSimulatedSensor::Update() method for all associated sensors.
void SetId(const std::string &str_id)
Sets the id of the robot associated to this controller.
The basic interface for a simulated sensor.
An entity that contains a pointer to the user-defined controller.
virtual void Init(TConfigurationNode &t_node)
Initializes the sensor from the XML configuration tree.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
virtual void Destroy()
Destroys the entity, undoing whatever was done by Init() or by the standalone constructor.
The basic interface for a robot controller.
virtual void Init(TConfigurationNode &t_node)
Initializes the actuator from the XML configuration tree.
virtual void SetRobot(CComposableEntity &c_entity)=0
Sets the entity associated to this sensor.