ci_differential_steering_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_DifferentialSteeringSensor::CreateLuaState(lua_State* pt_lua_state) {
20  CLuaUtility::OpenRobotStateTable(pt_lua_state, "wheels");
21  CLuaUtility::AddToTable(pt_lua_state, "distance_left", m_sReading.CoveredDistanceLeftWheel );
22  CLuaUtility::AddToTable(pt_lua_state, "distance_right", m_sReading.CoveredDistanceRightWheel);
23  CLuaUtility::AddToTable(pt_lua_state, "velocity_left", m_sReading.VelocityLeftWheel );
24  CLuaUtility::AddToTable(pt_lua_state, "velocity_right", m_sReading.VelocityRightWheel );
25  CLuaUtility::AddToTable(pt_lua_state, "axis_length", m_sReading.WheelAxisLength );
27  }
28 #endif
29 
30  /****************************************/
31  /****************************************/
32 
33 #ifdef ARGOS_WITH_LUA
34  void CCI_DifferentialSteeringSensor::ReadingsToLuaState(lua_State* pt_lua_state) {
35  lua_getfield (pt_lua_state, -1, "wheels" );
36  lua_pushnumber(pt_lua_state, m_sReading.CoveredDistanceLeftWheel );
37  lua_setfield (pt_lua_state, -2, "distance_left" );
38  lua_pushnumber(pt_lua_state, m_sReading.CoveredDistanceRightWheel);
39  lua_setfield (pt_lua_state, -2, "distance_right" );
40  lua_pushnumber(pt_lua_state, m_sReading.VelocityLeftWheel );
41  lua_setfield (pt_lua_state, -2, "velocity_left" );
42  lua_pushnumber(pt_lua_state, m_sReading.VelocityRightWheel );
43  lua_setfield (pt_lua_state, -2, "velocity_right" );
44  lua_pop (pt_lua_state, 1 );
45  }
46 #endif
47 
48 
49  /****************************************/
50  /****************************************/
51 
53  return m_sReading;
54  }
55 
56 }
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.
const SReading & GetReading() const
Returns the reading of the encoder sensor Returns the reading of the encoder sensor.