ci_positioning_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 
19  return m_sReading;
20  }
21 
22  /****************************************/
23  /****************************************/
24 
25 #ifdef ARGOS_WITH_LUA
26  void CCI_PositioningSensor::CreateLuaState(lua_State* pt_lua_state) {
27  CLuaUtility::StartTable(pt_lua_state, "positioning");
28  CLuaUtility::AddToTable(pt_lua_state, "position", m_sReading.Position);
29  CLuaUtility::AddToTable(pt_lua_state, "orientation", m_sReading.Orientation);
30  CLuaUtility::EndTable(pt_lua_state);
31  }
32 #endif
33 
34  /****************************************/
35  /****************************************/
36 
37 #ifdef ARGOS_WITH_LUA
38  void CCI_PositioningSensor::ReadingsToLuaState(lua_State* pt_lua_state) {
39  lua_getfield(pt_lua_state, -1, "positioning");
40  lua_getfield(pt_lua_state, -1, "position");
41  lua_pushnumber(pt_lua_state, m_sReading.Position.GetX());
42  lua_setfield(pt_lua_state, -2, "x");
43  lua_pushnumber(pt_lua_state, m_sReading.Position.GetY());
44  lua_setfield(pt_lua_state, -2, "y");
45  lua_pushnumber(pt_lua_state, m_sReading.Position.GetZ());
46  lua_setfield(pt_lua_state, -2, "z");
48  lua_getfield (pt_lua_state, -2, "orientation");
49  lua_pushnumber(pt_lua_state, m_cAngle.GetValue());
50  lua_setfield (pt_lua_state, -2, "angle");
51  lua_getfield (pt_lua_state, -1, "axis");
52  lua_pushnumber(pt_lua_state, m_cAxis.GetX());
53  lua_setfield (pt_lua_state, -2, "x");
54  lua_pushnumber(pt_lua_state, m_cAxis.GetY());
55  lua_setfield (pt_lua_state, -2, "y");
56  lua_pushnumber(pt_lua_state, m_cAxis.GetZ());
57  lua_setfield (pt_lua_state, -2, "z");
58  lua_pop(pt_lua_state, 4);
59  }
60 #endif
61 
62  /****************************************/
63  /****************************************/
64 
65 }
void ToAngleAxis(CRadians &c_angle, CVector3 &c_vector) const
Definition: quaternion.h:143
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...
const SReading & GetReading() const
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector3.h:93
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector3.h:109
Real GetValue() const
Returns the value in radians.
Definition: angles.h:111
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
Real GetZ() const
Returns the z coordinate of this vector.
Definition: vector3.h:125
static void EndTable(lua_State *pt_state)
Adds a table to the Lua stack.