argos::CLuaController Class Reference

#include <lua_controller.h>

Inheritance diagram for argos::CLuaController:
Collaboration diagram for argos::CLuaController:

Public Member Functions

 CLuaController ()
 
virtual ~CLuaController ()
 
virtual void Init (TConfigurationNode &t_tree)
 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...
 
lua_State * GetLuaState ()
 
virtual void SetLuaScript (const std::string &str_script, TConfigurationNode &t_tree)
 
virtual void SetLuaScript (const std::string &str_script)
 
virtual void CreateLuaState ()
 
virtual void SensorReadingsToLuaState ()
 
virtual void ParametersToLuaState (TConfigurationNode &t_tree)
 
bool IsOK () const
 
std::string GetErrorMessage ()
 
- Public Member Functions inherited from argos::CCI_Controller
virtual ~CCI_Controller ()
 Class destructor. 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...
 

Additional Inherited Members

- Protected Attributes inherited from argos::CCI_Controller
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

Definition at line 16 of file lua_controller.h.

Constructor & Destructor Documentation

◆ CLuaController()

argos::CLuaController::CLuaController ( )

Definition at line 20 of file lua_controller.cpp.

◆ ~CLuaController()

argos::CLuaController::~CLuaController ( )
virtual

Definition at line 30 of file lua_controller.cpp.

Member Function Documentation

◆ ControlStep()

void argos::CLuaController::ControlStep ( )
virtual

Executes a control step.

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

Reimplemented from argos::CCI_Controller.

Definition at line 67 of file lua_controller.cpp.

◆ CreateLuaState()

void argos::CLuaController::CreateLuaState ( )
virtual

Definition at line 162 of file lua_controller.cpp.

◆ Destroy()

void argos::CLuaController::Destroy ( )
virtual

The default implementation of this method does nothing.

See also
Init()
Reset()

Reimplemented from argos::CCI_Controller.

Definition at line 95 of file lua_controller.cpp.

◆ GetErrorMessage()

std::string argos::CLuaController::GetErrorMessage ( )

Definition at line 232 of file lua_controller.cpp.

◆ GetLuaState()

lua_State* argos::CLuaController::GetLuaState ( )
inline

Definition at line 32 of file lua_controller.h.

◆ Init()

void argos::CLuaController::Init ( TConfigurationNode t_node)
virtual

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

Reimplemented from argos::CCI_Controller.

Definition at line 36 of file lua_controller.cpp.

◆ IsOK()

bool argos::CLuaController::IsOK ( ) const
inline

Definition at line 47 of file lua_controller.h.

◆ ParametersToLuaState()

void argos::CLuaController::ParametersToLuaState ( TConfigurationNode t_tree)
virtual

Definition at line 211 of file lua_controller.cpp.

◆ Reset()

void argos::CLuaController::Reset ( )
virtual

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

Reimplemented from argos::CCI_Controller.

Definition at line 81 of file lua_controller.cpp.

◆ SensorReadingsToLuaState()

void argos::CLuaController::SensorReadingsToLuaState ( )
virtual

Definition at line 195 of file lua_controller.cpp.

◆ SetLuaScript() [1/2]

void argos::CLuaController::SetLuaScript ( const std::string &  str_script)
virtual

Definition at line 154 of file lua_controller.cpp.

◆ SetLuaScript() [2/2]

void argos::CLuaController::SetLuaScript ( const std::string &  str_script,
TConfigurationNode t_tree 
)
virtual

Definition at line 107 of file lua_controller.cpp.