ci_footbot_distance_scanner_actuator.cpp
Go to the documentation of this file.
1 
8 
9 #ifdef ARGOS_WITH_LUA
10 #include <argos3/core/wrappers/lua/lua_utility.h>
11 #endif
12 
13 namespace argos {
14 
15  /****************************************/
16  /****************************************/
17 
18 #ifdef ARGOS_WITH_LUA
19  int LuaDistanceScannerEnable(lua_State* pt_lua_state) {
20  /* Check parameters */
21  if(lua_gettop(pt_lua_state) != 0) {
22  return luaL_error(pt_lua_state, "robot.distance_scanner.enable() expects no arguments");
23  }
24  /* Perform action */
25  CLuaUtility::GetDeviceInstance<CCI_FootBotDistanceScannerActuator>(pt_lua_state, "distance_scanner")->Enable();
26  return 0;
27  }
28 
29  int LuaDistanceScannerDisable(lua_State* pt_lua_state) {
30  /* Check parameters */
31  if(lua_gettop(pt_lua_state) != 0) {
32  return luaL_error(pt_lua_state, "robot.distance_scanner.disable() expects no arguments");
33  }
34  /* Perform action */
35  CLuaUtility::GetDeviceInstance<CCI_FootBotDistanceScannerActuator>(pt_lua_state, "distance_scanner")->Disable();
36  return 0;
37  }
38 
39  int LuaDistanceScannerSetAngle(lua_State* pt_lua_state) {
40  /* Check parameters */
41  if(lua_gettop(pt_lua_state) != 1) {
42  return luaL_error(pt_lua_state, "robot.distance_scanner.set_angle() expects 1 argument");
43  }
44  luaL_checktype(pt_lua_state, 1, LUA_TNUMBER);
45  /* Perform action */
46  CLuaUtility::GetDeviceInstance<CCI_FootBotDistanceScannerActuator>(pt_lua_state, "distance_scanner")->SetAngle(CRadians(lua_tonumber(pt_lua_state, 1)));
47  return 0;
48  }
49 
50  int LuaDistanceScannerSetRPM(lua_State* pt_lua_state) {
51  /* Check parameters */
52  if(lua_gettop(pt_lua_state) != 1) {
53  return luaL_error(pt_lua_state, "robot.distance_scanner.set_rpm() expects 1 argument");
54  }
55  luaL_checktype(pt_lua_state, 1, LUA_TNUMBER);
56  /* Perform action */
57  CLuaUtility::GetDeviceInstance<CCI_FootBotDistanceScannerActuator>(pt_lua_state, "distance_scanner")->SetRPM(lua_tonumber(pt_lua_state, 1));
58  return 0;
59  }
60 #endif
61 
62  /****************************************/
63  /****************************************/
64 
65 #ifdef ARGOS_WITH_LUA
66  void CCI_FootBotDistanceScannerActuator::CreateLuaState(lua_State* pt_lua_state) {
67  CLuaUtility::OpenRobotStateTable (pt_lua_state, "distance_scanner" );
68  CLuaUtility::AddToTable (pt_lua_state, "_instance", this );
69  CLuaUtility::AddToTable (pt_lua_state, "enable", &LuaDistanceScannerEnable );
70  CLuaUtility::AddToTable (pt_lua_state, "disable", &LuaDistanceScannerDisable );
71  CLuaUtility::AddToTable (pt_lua_state, "set_angle", &LuaDistanceScannerSetAngle);
72  CLuaUtility::AddToTable (pt_lua_state, "set_rpm", &LuaDistanceScannerSetRPM );
73  CLuaUtility::CloseRobotStateTable(pt_lua_state );
74  }
75 #endif
76 
77  /****************************************/
78  /****************************************/
79 
80 }
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
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.