Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a00714_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/a00714_source.php on line 2
The ARGoS Website

ci_prototype_joints_sensor.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  void CCI_PrototypeJointsSensor::CreateLuaState(lua_State* pt_lua_state) {
20  /* CLuaUtility::OpenRobotStateTable is required since we don't know
21  whether the joint actuator has been added to the robot nor do we
22  know which joints it may have added to the robot's table in Lua */
23  CLuaUtility::OpenRobotStateTable(pt_lua_state, "joints");
24  for(SSensor* pc_sensor : m_vecSensors) {
25  CLuaUtility::OpenRobotStateTable(pt_lua_state, pc_sensor->Id);
26  CLuaUtility::AddToTable(pt_lua_state, "encoder", pc_sensor->Value);
28  }
30  }
31 #endif
32 
33  /****************************************/
34  /****************************************/
35 
36 #ifdef ARGOS_WITH_LUA
37  void CCI_PrototypeJointsSensor::ReadingsToLuaState(lua_State* pt_lua_state) {
38  lua_getfield(pt_lua_state, -1, "joints");
39  for(SSensor* pc_sensor : m_vecSensors) {
40  lua_getfield(pt_lua_state, -1, (pc_sensor->Id).c_str());
41  CLuaUtility::AddToTable(pt_lua_state, "encoder", pc_sensor->Value);
42  lua_pop(pt_lua_state, 1);
43  }
44  lua_pop(pt_lua_state, 1);
45  }
46 #endif
47 
48  /****************************************/
49  /****************************************/
50 
51 }
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.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
static void CloseRobotStateTable(lua_State *pt_state)
Closes a table in the robot state.