ARGoS  3
A parallel, multi-engine simulator for swarm robotics
plugins/robots/foot-bot/control_interface/ci_footbot_distance_scanner_sensor.cpp
Go to the documentation of this file.
00001 
00007 #include "ci_footbot_distance_scanner_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_FootBotDistanceScannerSensor::CreateLuaState(lua_State* pt_lua_state) {
00020       CLuaUtility::OpenRobotStateTable (pt_lua_state, "distance_scanner");
00021       CLuaUtility::StartTable          (pt_lua_state, "short_range"     );
00022       CLuaUtility::EndTable            (pt_lua_state                    );
00023       CLuaUtility::StartTable          (pt_lua_state, "long_range"      );
00024       CLuaUtility::EndTable            (pt_lua_state                    );
00025       CLuaUtility::CloseRobotStateTable(pt_lua_state                    );
00026    }
00027 #endif
00028 
00029    /****************************************/
00030    /****************************************/
00031 
00032 #ifdef ARGOS_WITH_LUA
00033    void CCI_FootBotDistanceScannerSensor::ReadingsToLuaState(lua_State* pt_lua_state) {
00034       lua_getfield(pt_lua_state, -1, "distance_scanner");
00035       CLuaUtility::StartTable(pt_lua_state, "short_range");
00036       int nCounter = 1;
00037       for(TReadingsMap::iterator it = m_tShortReadingsMap.begin();
00038           it != m_tShortReadingsMap.end(); ++it) {
00039          CLuaUtility::StartTable(pt_lua_state, nCounter);
00040          CLuaUtility::AddToTable(pt_lua_state, "angle",    it->first);
00041          CLuaUtility::AddToTable(pt_lua_state, "distance", it->second);
00042          CLuaUtility::EndTable(pt_lua_state);
00043          ++nCounter;
00044       }
00045       CLuaUtility::EndTable(pt_lua_state);
00046       CLuaUtility::StartTable(pt_lua_state, "long_range");
00047       nCounter = 1;
00048       for(TReadingsMap::iterator it = m_tLongReadingsMap.begin();
00049           it != m_tLongReadingsMap.end(); ++it) {
00050          CLuaUtility::StartTable(pt_lua_state, nCounter);
00051          CLuaUtility::AddToTable(pt_lua_state, "angle",    it->first);
00052          CLuaUtility::AddToTable(pt_lua_state, "distance", it->second);
00053          CLuaUtility::EndTable(pt_lua_state);
00054          ++nCounter;
00055       }
00056       CLuaUtility::EndTable(pt_lua_state);
00057       lua_pop(pt_lua_state, 1);
00058    }
00059 #endif
00060 
00061 
00062    /****************************************/
00063    /****************************************/
00064 
00065 }