Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a00712_source.php on line 2

Warning: include(): Failed opening 'php/utility.php' for inclusion (include_path='.:/usr/lib64/php') in /home/argos/argos3/doc/api/embedded/a00712_source.php on line 2
The ARGoS Website

ci_prototype_joints_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 LuaSetTarget(lua_State* pt_lua_state) {
20  /* get a reference to the actuator */
21  CCI_PrototypeJointsActuator::SActuator* pc_actuator =
22  reinterpret_cast<CCI_PrototypeJointsActuator::SActuator*>(lua_touserdata(pt_lua_state, lua_upvalueindex(1)));
23  /* check number of arguments */
24  if(lua_gettop(pt_lua_state) != 1) {
25  std::string strErrMsg = "robot.joints." + pc_actuator->Id + ".set_target() requires 1 argument";
26  return luaL_error(pt_lua_state, strErrMsg.c_str());
27  }
28  luaL_checktype(pt_lua_state, 1, LUA_TNUMBER);
29  /* Perform action */
30  pc_actuator->Target = lua_tonumber(pt_lua_state, 1);
31  return 0;
32  }
33 #endif
34 
35  /****************************************/
36  /****************************************/
37 
38 #ifdef ARGOS_WITH_LUA
39  void CCI_PrototypeJointsActuator::CreateLuaState(lua_State* pt_lua_state) {
40  CLuaUtility::StartTable(pt_lua_state, "joints");
41  for(SActuator* pc_actuator : m_vecActuators) {
42  CLuaUtility::StartTable(pt_lua_state, pc_actuator->Id);
43  /* push a pointer to each actuator onto the lua stack */
44  lua_pushstring(pt_lua_state, "set_target");
45  lua_pushlightuserdata(pt_lua_state, pc_actuator);
46  lua_pushcclosure(pt_lua_state, &LuaSetTarget, 1);
47  lua_settable(pt_lua_state, -3);
48  CLuaUtility::EndTable(pt_lua_state);
49  }
50  CLuaUtility::EndTable(pt_lua_state);
51  }
52 #endif
53 
54 
55 }
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.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
static void EndTable(lua_State *pt_state)
Adds a table to the Lua stack.