10 #include <argos3/core/wrappers/lua/lua_utility.h>
24 int LuaTagSetSinglePayload(lua_State* pt_lua_state) {
26 if(lua_gettop(pt_lua_state) != 2) {
27 return luaL_error(pt_lua_state,
"robot.tags.set_single_payload() expects 2 arguments");
29 luaL_checktype(pt_lua_state, 1, LUA_TNUMBER);
30 size_t unIdx = lua_tonumber(pt_lua_state, 1);
32 CCI_TagsActuator* pcTagActuator =
33 CLuaUtility::GetDeviceInstance<CCI_TagsActuator>(pt_lua_state,
"tags");
34 if(unIdx < 1 || unIdx > pcTagActuator->GetNumTags()) {
35 return luaL_error(pt_lua_state,
36 "passed index %d out of bounds [1,%d]",
37 unIdx, pcTagActuator->GetNumTags());
39 luaL_checktype(pt_lua_state, 2, LUA_TSTRING);
41 pcTagActuator->SetSinglePayload(unIdx - 1, lua_tostring(pt_lua_state, 2));
49 int LuaTagSetAllPayloads(lua_State* pt_lua_state) {
51 if(lua_gettop(pt_lua_state) != 1) {
52 return luaL_error(pt_lua_state,
"robot.tags.set_all_payloads() expects 1 argument");
54 luaL_checktype(pt_lua_state, 1, LUA_TSTRING);
56 CCI_TagsActuator* pcTagActuator =
57 CLuaUtility::GetDeviceInstance<CCI_TagsActuator>(pt_lua_state,
"tags");
59 pcTagActuator->SetAllPayloads(lua_tostring(pt_lua_state, 1));
75 const std::string& str_payload) {
92 void CCI_TagsActuator::CreateLuaState(lua_State* pt_lua_state) {
unsigned int UInt32
32-bit unsigned integer.
The namespace containing all the ARGoS related code.
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 st...
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.
size_t GetNumTags() const
Returns the number of tags.
virtual void SetSinglePayload(UInt32 un_tag_number, const std::string &str_payload)
Sets the payload of a single tag.
virtual void SetAllPayloads(const std::string &str_payload)
Sets all the tags with the same payload.