ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
00001 00007 #include "ci_footbot_encoder_sensor.h" 00008 00009 #ifdef ARGOS_WITH_LUA 00010 #include <argos3/core/wrappers/lua/lua_utility.h> 00011 #endif 00012 00013 namespace argos { 00014 00015 /****************************************/ 00016 /****************************************/ 00017 00018 #ifdef ARGOS_WITH_LUA 00019 void CCI_FootBotEncoderSensor::CreateLuaState(lua_State* pt_lua_state) { 00020 CLuaUtility::OpenRobotStateTable (pt_lua_state, "wheels" ); 00021 CLuaUtility::StartTable (pt_lua_state, "encoder" ); 00022 CLuaUtility::AddToTable (pt_lua_state, "distance_left", m_sReading.CoveredDistanceLeftWheel ); 00023 CLuaUtility::AddToTable (pt_lua_state, "distance_right", m_sReading.CoveredDistanceRightWheel); 00024 CLuaUtility::AddToTable (pt_lua_state, "axis_length", m_sReading.WheelAxisLength ); 00025 CLuaUtility::EndTable (pt_lua_state ); 00026 CLuaUtility::CloseRobotStateTable(pt_lua_state ); 00027 } 00028 #endif 00029 00030 /****************************************/ 00031 /****************************************/ 00032 00033 #ifdef ARGOS_WITH_LUA 00034 void CCI_FootBotEncoderSensor::ReadingsToLuaState(lua_State* pt_lua_state) { 00035 lua_getfield(pt_lua_state, -1, "wheels"); 00036 lua_getfield(pt_lua_state, -1, "encoder"); 00037 lua_pushnumber(pt_lua_state, m_sReading.CoveredDistanceLeftWheel); 00038 lua_setfield(pt_lua_state, -2, "distance_left"); 00039 lua_pushnumber(pt_lua_state, m_sReading.CoveredDistanceRightWheel); 00040 lua_setfield(pt_lua_state, -2, "distance_right"); 00041 lua_pop(pt_lua_state, 2); 00042 } 00043 #endif 00044 00045 00046 /****************************************/ 00047 /****************************************/ 00048 00049 }