10 #include <argos3/core/wrappers/lua/lua_utility.h>
25 int LuaSetAbsolutePosition(lua_State* pt_lua_state) {
27 if(lua_gettop(pt_lua_state) != 3) {
28 return luaL_error(pt_lua_state,
"robot.quadrotor.set_absolute_position() expects 3 arguments");
30 luaL_checktype(pt_lua_state, 1, LUA_TNUMBER);
31 luaL_checktype(pt_lua_state, 2, LUA_TNUMBER);
32 luaL_checktype(pt_lua_state, 3, LUA_TNUMBER);
34 CLuaUtility::GetDeviceInstance<CCI_QuadRotorPositionActuator>(pt_lua_state,
"quadrotor")->
35 SetAbsolutePosition(CVector3(lua_tonumber(pt_lua_state, 1),
36 lua_tonumber(pt_lua_state, 2),
37 lua_tonumber(pt_lua_state, 3)));
52 int LuaSetRelativePosition(lua_State* pt_lua_state) {
54 if(lua_gettop(pt_lua_state) != 3) {
55 return luaL_error(pt_lua_state,
"robot.quadrotor.set_relative_position() expects 3 arguments");
57 luaL_checktype(pt_lua_state, 1, LUA_TNUMBER);
58 luaL_checktype(pt_lua_state, 2, LUA_TNUMBER);
59 luaL_checktype(pt_lua_state, 3, LUA_TNUMBER);
61 CLuaUtility::GetDeviceInstance<CCI_QuadRotorPositionActuator>(pt_lua_state,
"quadrotor")->
62 SetRelativePosition(CVector3(lua_tonumber(pt_lua_state, 1),
63 lua_tonumber(pt_lua_state, 2),
64 lua_tonumber(pt_lua_state, 3)));
77 int LuaSetAbsoluteYaw(lua_State* pt_lua_state) {
79 if(lua_gettop(pt_lua_state) != 1) {
80 return luaL_error(pt_lua_state,
"robot.quadrotor.set_absolute_yaw() expects 1 argument");
82 luaL_checktype(pt_lua_state, 1, LUA_TNUMBER);
84 CLuaUtility::GetDeviceInstance<CCI_QuadRotorPositionActuator>(pt_lua_state,
"quadrotor")->
85 SetAbsoluteYaw(CRadians(lua_tonumber(pt_lua_state, 1) / 180.0f *
CRadians::PI));
98 int LuaSetRelativeYaw(lua_State* pt_lua_state) {
100 if(lua_gettop(pt_lua_state) != 1) {
101 return luaL_error(pt_lua_state,
"robot.quadrotor.set_relative_yaw() expects 1 argument");
103 luaL_checktype(pt_lua_state, 1, LUA_TNUMBER);
105 CLuaUtility::GetDeviceInstance<CCI_QuadRotorPositionActuator>(pt_lua_state,
"quadrotor")->
106 SetRelativeYaw(CRadians(lua_tonumber(pt_lua_state, 1) / 180.0f *
CRadians::PI));
114 #ifdef ARGOS_WITH_LUA
115 void CCI_QuadRotorPositionActuator::CreateLuaState(lua_State* pt_lua_state) {
The namespace containing all the ARGoS related code.
static const CRadians PI
The PI constant.
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.