ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
#include <lua_utility.h>
Public Types | |
enum | EARGoSTypes { TYPE_NORMAL = 0, TYPE_VECTOR2, TYPE_VECTOR3, TYPE_QUATERNION, TYPE_COLOR } |
Static Public Member Functions | |
static bool | LoadScript (lua_State *pt_state, const std::string &str_filename) |
Loads the given Lua script. | |
static bool | CallLuaFunction (lua_State *pt_state, const std::string &str_function) |
Calls a parameter-less function in the Lua script. | |
static void | PrintGlobals (CARGoSLog &c_log, lua_State *pt_state) |
Prints the global Lua symbols on the specified log. | |
static void | PrintStack (CARGoSLog &c_log, lua_State *pt_state) |
Prints the Lua stack on the specified log. | |
static void | RegisterLoggerWrapper (lua_State *pt_state) |
Registers LOG and LOGERR in the Lua state. | |
static void | RegisterRNG (lua_State *pt_state, CRandom::CRNG *pc_rng) |
Registers the given random number generator in the Lua state. | |
static void | OpenRobotStateTable (lua_State *pt_state, const std::string &str_key) |
Opens a table in the robot state, creating it if it does not exist. | |
static void | CloseRobotStateTable (lua_State *pt_state) |
Closes a table in the robot state. | |
static void | StartTable (lua_State *pt_state, const std::string &str_key) |
Adds a table with the given string key to the table located at the top of the stack. | |
static void | StartTable (lua_State *pt_state, int n_key) |
Adds a table with the given numeric key to the table located at the top of the stack. | |
static void | EndTable (lua_State *pt_state) |
Adds a table to the Lua stack. | |
static void | AddToTable (lua_State *pt_state, const std::string &str_key, void *pt_data) |
Adds a pointer to a chunk of data with the given string key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, const std::string &str_key, lua_CFunction pt_data) |
Adds a pointer to a C function with the given string key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, const std::string &str_key, Real f_data) |
Adds a Real with the given string key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, int n_key, Real f_data) |
Adds a Real with the given numeric key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, const std::string &str_key, const CRadians &c_data) |
Adds a CRadians with the given string key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, int n_key, const CRadians &c_data) |
Adds a CRadians with the given numeric key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, const std::string &str_key, const CVector2 &c_data) |
Adds a CVector2 the given string key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, int n_key, const CVector2 &c_data) |
Adds a CVector2 the given numeric key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, const std::string &str_key, const CVector3 &c_data) |
Adds a CVector3 the given string key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, int n_key, const CVector3 &c_data) |
Adds a CVector3 the given numeric key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, const std::string &str_key, const CQuaternion &c_data) |
Adds a CQuaternion the given string key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, int n_key, const CQuaternion &c_data) |
Adds a CQuaternion the given numeric key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, const std::string &str_key, const CColor &c_data) |
Adds a CColor the given string key to the table located at the top of the stack. | |
static void | AddToTable (lua_State *pt_state, int n_key, const CColor &c_data) |
Adds a CColor the given numeric key to the table located at the top of the stack. | |
template<class T > | |
static T * | GetDeviceInstance (lua_State *pt_state, const std::string &str_key) |
Returns a pointer to the instance to the wanted device. |
Definition at line 29 of file lua_utility.h.
Definition at line 33 of file lua_utility.h.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
const std::string & | str_key, | ||
void * | pt_data | ||
) | [static] |
Adds a pointer to a chunk of data with the given string key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
str_key | The string key for the parent table. |
pt_data | The data to add to the table. |
Definition at line 337 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
const std::string & | str_key, | ||
lua_CFunction | pt_data | ||
) | [static] |
Adds a pointer to a C function with the given string key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
str_key | The string key for the parent table. |
pt_data | The data to add to the table. |
Definition at line 348 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
const std::string & | str_key, | ||
Real | f_data | ||
) | [static] |
Adds a Real with the given string key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
str_key | The string key for the parent table. |
f_data | The data to add to the table. |
Definition at line 359 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
int | n_key, | ||
Real | f_data | ||
) | [static] |
Adds a Real with the given numeric key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
n_key | The numeric key for the parent table. |
f_data | The data to add to the table. |
Definition at line 370 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
const std::string & | str_key, | ||
const CRadians & | c_data | ||
) | [static] |
Adds a CRadians with the given string key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
str_key | The string key for the parent table. |
c_data | The data to add to the table. |
Definition at line 381 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
int | n_key, | ||
const CRadians & | c_data | ||
) | [static] |
Adds a CRadians with the given numeric key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
n_key | The numeric key for the parent table. |
c_data | The data to add to the table. |
Definition at line 392 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
const std::string & | str_key, | ||
const CVector2 & | c_data | ||
) | [static] |
Adds a CVector2 the given string key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
str_key | The string key for the parent table. |
c_data | The data to add to the table. |
Definition at line 403 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
int | n_key, | ||
const CVector2 & | c_data | ||
) | [static] |
Adds a CVector2 the given numeric key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
n_key | The numeric key for the parent table. |
c_data | The data to add to the table. |
Definition at line 416 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
const std::string & | str_key, | ||
const CVector3 & | c_data | ||
) | [static] |
Adds a CVector3 the given string key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
str_key | The string key for the parent table. |
c_data | The data to add to the table. |
Definition at line 429 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
int | n_key, | ||
const CVector3 & | c_data | ||
) | [static] |
Adds a CVector3 the given numeric key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
n_key | The numeric key for the parent table. |
c_data | The data to add to the table. |
Definition at line 443 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
const std::string & | str_key, | ||
const CQuaternion & | c_data | ||
) | [static] |
Adds a CQuaternion the given string key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
str_key | The string key for the parent table. |
c_data | The data to add to the table. |
Definition at line 457 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
int | n_key, | ||
const CQuaternion & | c_data | ||
) | [static] |
Adds a CQuaternion the given numeric key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
n_key | The numeric key for the parent table. |
c_data | The data to add to the table. |
Definition at line 473 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
const std::string & | str_key, | ||
const CColor & | c_data | ||
) | [static] |
Adds a CColor the given string key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
str_key | The string key for the parent table. |
c_data | The data to add to the table. |
Definition at line 489 of file lua_utility.cpp.
void argos::CLuaUtility::AddToTable | ( | lua_State * | pt_state, |
int | n_key, | ||
const CColor & | c_data | ||
) | [static] |
Adds a CColor the given numeric key to the table located at the top of the stack.
At the end of the execution, the stack is in the same state as it was before this function was called.
pt_state | The Lua state. |
n_key | The numeric key for the parent table. |
c_data | The data to add to the table. |
Definition at line 503 of file lua_utility.cpp.
bool argos::CLuaUtility::CallLuaFunction | ( | lua_State * | pt_state, |
const std::string & | str_function | ||
) | [static] |
Calls a parameter-less function in the Lua script.
pt_state | The Lua state. |
str_function | The function name. |
false
in case of errors, true
otherwise. Definition at line 175 of file lua_utility.cpp.
void argos::CLuaUtility::CloseRobotStateTable | ( | lua_State * | pt_state | ) | [static] |
Closes a table in the robot state.
This method expects the table itself to be at the top of the stack (-1).
pt_state | The Lua state. |
Definition at line 305 of file lua_utility.cpp.
void argos::CLuaUtility::EndTable | ( | lua_State * | pt_state | ) | [static] |
Adds a table to the Lua stack.
This method expects the table itself to be at the top of the stack (-1) and the table name to be a index -2.
pt_state | The Lua state. |
Definition at line 330 of file lua_utility.cpp.
static T* argos::CLuaUtility::GetDeviceInstance | ( | lua_State * | pt_state, |
const std::string & | str_key | ||
) | [inline, static] |
Returns a pointer to the instance to the wanted device.
The Lua state is stored in a table called robot
. Each robot device is stored as a nested table. Each nested table has an _instance
field which contains the pointer to the actual device. This function returns such pointer.
pt_state | The Lua state. |
str_key | The string key for the device table. |
Definition at line 352 of file lua_utility.h.
bool argos::CLuaUtility::LoadScript | ( | lua_State * | pt_state, |
const std::string & | str_filename | ||
) | [static] |
Loads the given Lua script.
pt_state | The Lua state. |
str_filename | The script file name. |
false
in case of errors, true
otherwise. Definition at line 161 of file lua_utility.cpp.
void argos::CLuaUtility::OpenRobotStateTable | ( | lua_State * | pt_state, |
const std::string & | str_key | ||
) | [static] |
Opens a table in the robot state, creating it if it does not exist.
This method expects the "robot" table to be at -1 in the stack, and pushes the table object on the stack. To close the table call CloseRobotStateTable().
pt_state | The Lua state. |
str_key | The string key for the robot state table. |
Definition at line 289 of file lua_utility.cpp.
void argos::CLuaUtility::PrintGlobals | ( | CARGoSLog & | c_log, |
lua_State * | pt_state | ||
) | [static] |
Prints the global Lua symbols on the specified log.
c_log | The output log. |
pt_state | The Lua state. |
Definition at line 231 of file lua_utility.cpp.
void argos::CLuaUtility::PrintStack | ( | CARGoSLog & | c_log, |
lua_State * | pt_state | ||
) | [static] |
Prints the Lua stack on the specified log.
c_log | The output log. |
pt_state | The Lua state. |
Definition at line 246 of file lua_utility.cpp.
void argos::CLuaUtility::RegisterLoggerWrapper | ( | lua_State * | pt_state | ) | [static] |
Registers LOG and LOGERR in the Lua state.
After this call, in a Lua script one can use log()
and logerr()
to print to the ARGoS logs.
pt_state | The Lua state. |
Definition at line 265 of file lua_utility.cpp.
void argos::CLuaUtility::RegisterRNG | ( | lua_State * | pt_state, |
CRandom::CRNG * | pc_rng | ||
) | [static] |
Registers the given random number generator in the Lua state.
Internally, it resets the passed RNG.
pt_state | The Lua state. |
pc_rng | The random number generator. |
Definition at line 273 of file lua_utility.cpp.
void argos::CLuaUtility::StartTable | ( | lua_State * | pt_state, |
const std::string & | str_key | ||
) | [static] |
Adds a table with the given string key to the table located at the top of the stack.
This method pushes the table key and the table itself on the stack. To close a table call EndTable().
pt_state | The Lua state. |
str_key | The string key for the parent table. |
Definition at line 312 of file lua_utility.cpp.
void argos::CLuaUtility::StartTable | ( | lua_State * | pt_state, |
int | n_key | ||
) | [static] |
Adds a table with the given numeric key to the table located at the top of the stack.
This method pushes the table key and the table itself on the stack. To close a table call EndTable().
pt_state | The Lua state. |
n_key | The numeric key for the parent table. |
Definition at line 321 of file lua_utility.cpp.