#include <lua_utility.h>
Public Types | |
enum | EARGoSType : lua_Integer { EARGoSType::CVector2, EARGoSType::CVector3, EARGoSType::CQuaternion, EARGoSType::CColor } |
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.
|
strong |
Enumerator | |
---|---|
CVector2 | |
CVector3 | |
CQuaternion | |
CColor |
Definition at line 35 of file lua_utility.h.
|
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 357 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 368 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 379 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 390 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 401 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 412 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 423 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 434 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 445 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 458 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 471 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 485 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 499 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 514 of file lua_utility.cpp.
|
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 529 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 543 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 180 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 316 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 341 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 389 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 166 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 300 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 242 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 257 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 276 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 284 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 348 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 323 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 332 of file lua_utility.cpp.