00001 /** 00002 \file Robots/LoBot/control/LoTestScanMatching.C 00003 \brief This file defines the non-inline member functions of the 00004 lobot::TestScanMatching class. 00005 */ 00006 00007 // //////////////////////////////////////////////////////////////////// // 00008 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00009 // by the University of Southern California (USC) and the iLab at USC. // 00010 // See http://iLab.usc.edu for information about this project. // 00011 // //////////////////////////////////////////////////////////////////// // 00012 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00013 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00014 // in Visual Environments, and Applications'' by Christof Koch and // 00015 // Laurent Itti, California Institute of Technology, 2001 (patent // 00016 // pending; application number 09/912,225 filed July 23, 2001; see // 00017 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00018 // //////////////////////////////////////////////////////////////////// // 00019 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00020 // // 00021 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00022 // redistribute it and/or modify it under the terms of the GNU General // 00023 // Public License as published by the Free Software Foundation; either // 00024 // version 2 of the License, or (at your option) any later version. // 00025 // // 00026 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00027 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00028 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00029 // PURPOSE. See the GNU General Public License for more details. // 00030 // // 00031 // You should have received a copy of the GNU General Public License // 00032 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00033 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00034 // Boston, MA 02111-1307 USA. // 00035 // //////////////////////////////////////////////////////////////////// // 00036 // 00037 // Primary maintainer for this file: mviswana usc edu 00038 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/control/LoTestScanMatching.C $ 00039 // $Id: LoTestScanMatching.C 13570 2010-06-16 15:56:00Z mviswana $ 00040 // 00041 00042 //------------------------------ HEADERS -------------------------------- 00043 00044 // lobot headers 00045 #include "Robots/LoBot/control/LoTestScanMatching.H" 00046 #include "Robots/LoBot/slam/LoScanMatch.H" 00047 #include "Robots/LoBot/config/LoConfigHelpers.H" 00048 #include "Robots/LoBot/thread/LoShutdown.H" 00049 #include "Robots/LoBot/misc/LoRegistry.H" 00050 00051 // Standard C++ headers 00052 #include <fstream> 00053 #include <sstream> 00054 #include <string> 00055 #include <vector> 00056 #include <algorithm> 00057 #include <iterator> 00058 00059 //----------------------------- NAMESPACE ------------------------------- 00060 00061 namespace lobot { 00062 00063 //--------------------------- LOCAL HELPERS ----------------------------- 00064 00065 // Retrieve settings from test_idc section of config file 00066 template<typename T> 00067 static inline T conf(const std::string& key, const T& default_value) 00068 { 00069 return get_conf<T>(LOBE_TEST_SCAN_MATCHING, key, default_value) ; 00070 } 00071 00072 // Retrieve a line from the given input stream 00073 static std::string getline(std::istream& is) 00074 { 00075 std::string line ; 00076 std::getline(is, line) ; 00077 return line ; 00078 } 00079 00080 // Convert a line read from the scan data file to a Scan object 00081 static Scan to_scan(const std::string& line) 00082 { 00083 std::istringstream str(line) ; 00084 00085 float x, y, theta ; 00086 str >> x >> y >> theta ; 00087 00088 Pose P(x, y, theta) ; 00089 std::vector<float> R = 00090 std::vector<float>(std::istream_iterator<float>(str), 00091 std::istream_iterator<float>()) ; 00092 00093 return Scan(P, R) ; 00094 } 00095 00096 //-------------------------- INITIALIZATION ----------------------------- 00097 00098 TestScanMatching::TestScanMatching() 00099 : base(clamp(conf("update_delay", 500), 1, 1500)) 00100 { 00101 start(LOBE_TEST_SCAN_MATCHING) ; 00102 } 00103 00104 void TestScanMatching::pre_run() 00105 { 00106 std::string file_name = 00107 conf<std::string>("test_data", "/tmp/lobot-scan-matching.dat") ; 00108 std::ifstream scan_file(file_name.c_str()) ; 00109 00110 Scan prev(to_scan(getline(scan_file))) ; 00111 Scan curr(to_scan(getline(scan_file))) ; 00112 00113 match_scans(curr, prev) ; 00114 } 00115 00116 //---------------------- THE BEHAVIOUR'S ACTION ------------------------- 00117 00118 // All the processing takes place in pre_run()... 00119 void TestScanMatching::action() 00120 { 00121 Shutdown::signal() ; 00122 } 00123 00124 //----------------------------- CLEAN-UP -------------------------------- 00125 00126 TestScanMatching::~TestScanMatching(){} 00127 00128 //----------------------------------------------------------------------- 00129 00130 } // end of namespace encapsulating this file's definitions 00131 00132 /* So things look consistent in everyone's emacs... */ 00133 /* Local Variables: */ 00134 /* indent-tabs-mode: nil */ 00135 /* End: */