#include <lua_utility.h>
Static Public Member Functions | |
static bool | LoadScript (lua_State *pt_state, const std::string &str_filename) |
Loads the given Lua script. More... | |
static bool | CallLuaFunction (lua_State *pt_state, const std::string &str_function) |
Calls a parameter-less function in the Lua script. More... | |
static void | PrintGlobals (CARGoSLog &c_log, lua_State *pt_state) |
Prints the global Lua symbols on the specified log. More... | |
static void | PrintStack (CARGoSLog &c_log, lua_State *pt_state) |
Prints the Lua stack on the specified log. More... | |
static void | RegisterLoggerWrapper (lua_State *pt_state) |
Registers LOG and LOGERR in the Lua state. More... | |
static void | RegisterRNG (lua_State *pt_state, CRandom::CRNG *pc_rng) |
Registers the given random number generator in the Lua state. More... | |
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. More... | |
static void | CloseRobotStateTable (lua_State *pt_state) |
Closes a table in the robot state. More... | |
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. More... | |
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. More... | |
static void | EndTable (lua_State *pt_state) |
Adds a table to the Lua stack. More... | |
static void | SetMetatable (lua_State *pt_state, const std::string &str_key) |
Sets the metatable with the given string key to the table located at the top of the stack. More... | |
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. More... | |
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. More... | |
static void | AddToTable (lua_State *pt_state, const std::string &str_key, const std::string &str_data) |
Adds a string with the given string key to the table located at the top of the stack. More... | |
static void | AddToTable (lua_State *pt_state, int n_key, const std::string &str_data) |
Adds a string with the given string key to the table located at the top of the stack. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
Definition at line 31 of file lua_utility.h.
|
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 538 of file lua_utility.cpp.
|
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 516 of file lua_utility.cpp.
|
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 449 of file lua_utility.cpp.
|
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 471 of file lua_utility.cpp.
|
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 493 of file lua_utility.cpp.
|
static |
Adds a string 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. |
str_data | The data to add to the table. |
Definition at line 405 of file lua_utility.cpp.
|
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 394 of file lua_utility.cpp.
|
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 427 of file lua_utility.cpp.
|
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 383 of file lua_utility.cpp.
|
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 551 of file lua_utility.cpp.
|
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 527 of file lua_utility.cpp.
|
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 460 of file lua_utility.cpp.
|
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 482 of file lua_utility.cpp.
|
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 504 of file lua_utility.cpp.
|
static |
Adds a string 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. |
n_key | The numeric key for the parent table. |
str_data | The data to add to the table. |
Definition at line 416 of file lua_utility.cpp.
|
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 438 of file lua_utility.cpp.
|
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 201 of file lua_utility.cpp.
|
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 342 of file lua_utility.cpp.
|
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 367 of file lua_utility.cpp.
|
inlinestatic |
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 380 of file lua_utility.h.
|
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 181 of file lua_utility.cpp.
|
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 326 of file lua_utility.cpp.
|
static |
Prints the global Lua symbols on the specified log.
c_log | The output log. |
pt_state | The Lua state. |
Definition at line 267 of file lua_utility.cpp.
|
static |
Prints the Lua stack on the specified log.
c_log | The output log. |
pt_state | The Lua state. |
Definition at line 282 of file lua_utility.cpp.
|
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 301 of file lua_utility.cpp.
|
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 309 of file lua_utility.cpp.
|
static |
Sets the metatable 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 metatable. |
Definition at line 374 of file lua_utility.cpp.
|
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 349 of file lua_utility.cpp.
|
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 358 of file lua_utility.cpp.