argos::CCI_Controller Class Reference

The basic interface for a robot controller. More...

#include <ci_controller.h>

Inheritance diagram for argos::CCI_Controller:
Collaboration diagram for argos::CCI_Controller:

Public Member Functions

virtual ~CCI_Controller ()
 Class destructor. More...
 
virtual void Init (TConfigurationNode &t_node)
 Initializes the controller. More...
 
virtual void ControlStep ()
 Executes a control step. More...
 
virtual void Reset ()
 Resets the state of the controller to what it was right after Init() was executed. More...
 
virtual void Destroy ()
 The default implementation of this method does nothing. More...
 
const std::string & GetId () const
 Returns the id of the robot associated to this controller. More...
 
void SetId (const std::string &str_id)
 Sets the id of the robot associated to this controller. More...
 
template<typename ACTUATOR_IMPL >
ACTUATOR_IMPL * GetActuator (const std::string &str_actuator_type)
 Returns a pointer to the an actuator, given its type. More...
 
template<typename SENSOR_IMPL >
SENSOR_IMPL * GetSensor (const std::string &str_sensor_type)
 Returns a pointer to the an sensor, given its type. More...
 
bool HasActuator (const std::string &str_actuator_type) const
 Returns true if an actuator with the passed type is associated to this controller. More...
 
bool HasSensor (const std::string &str_sensor_type) const
 Returns true if an sensor with the passed type is associated to this controller. More...
 
CCI_Actuator::TMapGetAllActuators ()
 Returns a map of the associated actuators. More...
 
CCI_Sensor::TMapGetAllSensors ()
 Returns a map of the associated sensors. More...
 
void AddActuator (const std::string &str_actuator_type, CCI_Actuator *pc_actuator)
 Adds an actuator to this controller. More...
 
void AddSensor (const std::string &str_sensor_type, CCI_Sensor *pc_sensor)
 Adds an sensor to this controller. More...
 
- Public Member Functions inherited from argos::CBaseConfigurableResource
virtual ~CBaseConfigurableResource ()
 Class destructor. More...
 

Protected Attributes

CCI_Actuator::TMap m_mapActuators
 A map containing all the actuators associated to this controller. More...
 
CCI_Sensor::TMap m_mapSensors
 A map containing all the sensors associated to this controller. More...
 
std::string m_strId
 The id of the robot associated to this controller
More...
 

Detailed Description

The basic interface for a robot controller.

Definition at line 30 of file ci_controller.h.

Constructor & Destructor Documentation

◆ ~CCI_Controller()

argos::CCI_Controller::~CCI_Controller ( )
virtual

Class destructor.

Definition at line 14 of file ci_controller.cpp.

Member Function Documentation

◆ AddActuator()

void argos::CCI_Controller::AddActuator ( const std::string &  str_actuator_type,
CCI_Actuator pc_actuator 
)
inline

Adds an actuator to this controller.

This method is called internally by ARGoS. You should never call it in your controllers.

Parameters
str_actuator_typeThe type of the actuator to add.
pc_actuatorA pointer to the actuator to add.
See also
CCI_Actuator

Definition at line 193 of file ci_controller.h.

◆ AddSensor()

void argos::CCI_Controller::AddSensor ( const std::string &  str_sensor_type,
CCI_Sensor pc_sensor 
)
inline

Adds an sensor to this controller.

This method is called internally by ARGoS. You should never call it in your controllers.

Parameters
str_sensor_typeThe type of the sensor to add.
pc_sensorA pointer to the sensor to add.
See also
CCI_Sensor

Definition at line 205 of file ci_controller.h.

◆ ControlStep()

virtual void argos::CCI_Controller::ControlStep ( )
inlinevirtual

Executes a control step.

The logic of your controller goes here. The default implementation does nothing.

Reimplemented in argos::CLuaController.

Definition at line 55 of file ci_controller.h.

◆ Destroy()

virtual void argos::CCI_Controller::Destroy ( )
inlinevirtual

The default implementation of this method does nothing.

See also
Init()
Reset()

Implements argos::CBaseConfigurableResource.

Reimplemented in argos::CLuaController.

Definition at line 72 of file ci_controller.h.

◆ GetActuator()

template<typename ACTUATOR_IMPL >
ACTUATOR_IMPL* argos::CCI_Controller::GetActuator ( const std::string &  str_actuator_type)
inline

Returns a pointer to the an actuator, given its type.

Internally, ARGoS creates an actuator object for each actuator listed in the <actuators> section of the XML file. This method allows you to get a pointer to a specific actuator listed in the XML. The type corresponds to the XML tag of an actuator (not its implementation attribute!).

Parameters
str_actuator_typeThe wanted actuator type.
Returns
A pointer to the wanted actuator.
Exceptions
CARGoSExceptionif the actuator type was not found among those listed in the XML, or if the actual actuator object cannot be cast to the target class
See also
HasActuator()
GetSensor()

Definition at line 106 of file ci_controller.h.

◆ GetAllActuators()

CCI_Actuator::TMap& argos::CCI_Controller::GetAllActuators ( )
inline

Returns a map of the associated actuators.

Returns
A map of the associated actuators.

Definition at line 174 of file ci_controller.h.

◆ GetAllSensors()

CCI_Sensor::TMap& argos::CCI_Controller::GetAllSensors ( )
inline

Returns a map of the associated sensors.

Returns
A map of the associated sensors.

Definition at line 182 of file ci_controller.h.

◆ GetId()

const std::string& argos::CCI_Controller::GetId ( ) const
inline

Returns the id of the robot associated to this controller.

Returns
The id of the robot associated to this controller.

Definition at line 78 of file ci_controller.h.

◆ GetSensor()

template<typename SENSOR_IMPL >
SENSOR_IMPL* argos::CCI_Controller::GetSensor ( const std::string &  str_sensor_type)
inline

Returns a pointer to the an sensor, given its type.

Internally, ARGoS creates an sensor object for each sensor listed in the <sensors> section of the XML file. This method allows you to get a pointer to a specific sensor listed in the XML. The type corresponds to the XML tag of an sensor (not its implementation attribute!).

Parameters
str_sensor_typeThe wanted sensor type.
Returns
A pointer to the wanted sensor.
Exceptions
CARGoSExceptionif the sensor type was not found among those listed in the XML, or if the actual sensor object cannot be cast to the target class
See also
HasSensor()
GetActuator()

Definition at line 137 of file ci_controller.h.

◆ HasActuator()

bool argos::CCI_Controller::HasActuator ( const std::string &  str_actuator_type) const

Returns true if an actuator with the passed type is associated to this controller.

Parameters
str_actuator_typeThe type of the wanted actuator.
Returns
true if an actuator with the passed type is associated to this controller.
See also
GetActuator()

Definition at line 35 of file ci_controller.cpp.

◆ HasSensor()

bool argos::CCI_Controller::HasSensor ( const std::string &  str_sensor_type) const

Returns true if an sensor with the passed type is associated to this controller.

Parameters
str_sensor_typeThe type of the wanted sensor.
Returns
true if an sensor with the passed type is associated to this controller.
See also
GetSensor()

Definition at line 43 of file ci_controller.cpp.

◆ Init()

virtual void argos::CCI_Controller::Init ( TConfigurationNode t_node)
inlinevirtual

Initializes the controller.

You should always perform all your memory allocation and configuration in this method, and not in the constructor. The default implementation of this method does nothing.

Parameters
t_nodeThe <params> XML tree associated to this controller.
See also
Reset()
Destroy()

Implements argos::CBaseConfigurableResource.

Reimplemented in argos::CLuaController.

Definition at line 48 of file ci_controller.h.

◆ Reset()

virtual void argos::CCI_Controller::Reset ( )
inlinevirtual

Resets the state of the controller to what it was right after Init() was executed.

Note that the state of the robot, as well as the state of sensors and actuators is automatically reset by ARGoS outside this class. The default implementation of this method does nothing.

See also
Init()
Destroy()

Implements argos::CBaseConfigurableResource.

Reimplemented in argos::CLuaController.

Definition at line 65 of file ci_controller.h.

◆ SetId()

void argos::CCI_Controller::SetId ( const std::string &  str_id)
inline

Sets the id of the robot associated to this controller.

It is used internally by ARGoS to set the robot id. You should never use this function inside your controller.

Parameters
str_idThe new robot id.

Definition at line 88 of file ci_controller.h.

Member Data Documentation

◆ m_mapActuators

CCI_Actuator::TMap argos::CCI_Controller::m_mapActuators
protected

A map containing all the actuators associated to this controller.

Definition at line 213 of file ci_controller.h.

◆ m_mapSensors

CCI_Sensor::TMap argos::CCI_Controller::m_mapSensors
protected

A map containing all the sensors associated to this controller.

Definition at line 216 of file ci_controller.h.

◆ m_strId

std::string argos::CCI_Controller::m_strId
protected

The id of the robot associated to this controller

Definition at line 219 of file ci_controller.h.