00001 /** 00002 \file Robots/LoBot/control/LoTrack.H 00003 \brief A behaviour for tracking the robot. 00004 00005 This file implements a class for maintaining a list of lobot's 00006 positions within the map and visualizing this pose history as a dotted 00007 trail. Each pose update is also logged via lobot::Metrics. This 00008 behaviour does not control the robot in any way; it is only meant for 00009 data collection and visualization. 00010 */ 00011 00012 // //////////////////////////////////////////////////////////////////// // 00013 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00014 // by the University of Southern California (USC) and the iLab at USC. // 00015 // See http://iLab.usc.edu for information about this project. // 00016 // //////////////////////////////////////////////////////////////////// // 00017 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00018 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00019 // in Visual Environments, and Applications'' by Christof Koch and // 00020 // Laurent Itti, California Institute of Technology, 2001 (patent // 00021 // pending; application number 09/912,225 filed July 23, 2001; see // 00022 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00023 // //////////////////////////////////////////////////////////////////// // 00024 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00025 // // 00026 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00027 // redistribute it and/or modify it under the terms of the GNU General // 00028 // Public License as published by the Free Software Foundation; either // 00029 // version 2 of the License, or (at your option) any later version. // 00030 // // 00031 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00032 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00033 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00034 // PURPOSE. See the GNU General Public License for more details. // 00035 // // 00036 // You should have received a copy of the GNU General Public License // 00037 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00038 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00039 // Boston, MA 02111-1307 USA. // 00040 // //////////////////////////////////////////////////////////////////// // 00041 // 00042 // Primary maintainer for this file: mviswana usc edu 00043 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/control/LoTrack.H $ 00044 // $Id: LoTrack.H 13608 2010-06-23 04:27:01Z mviswana $ 00045 // 00046 00047 #ifndef LOBOT_TRACK_BEHAVIOUR_DOT_H 00048 #define LOBOT_TRACK_BEHAVIOUR_DOT_H 00049 00050 //------------------------------ HEADERS -------------------------------- 00051 00052 // lobot headers 00053 #include "Robots/LoBot/control/LoBehavior.H" 00054 #include "Robots/LoBot/slam/LoPose.H" 00055 #include "Robots/LoBot/misc/factory.hh" 00056 00057 // Standard C++ headers 00058 #include <deque> 00059 00060 //----------------------------- NAMESPACE ------------------------------- 00061 00062 namespace lobot { 00063 00064 //------------------------- CLASS DEFINITION ---------------------------- 00065 00066 /** 00067 \class lobot::Track 00068 \brief A behaviour for maintaining pose history and dumping it to a 00069 file every now and then. 00070 00071 This class implements a behaviour for tracking the robot's pose 00072 history and visualizing the recent poses as a dotted trail behind the 00073 robot's icon on the map drawing area. Each pose update is also logged 00074 to the metrics log. Additionally, the robot's current speed is also 00075 logged by this behaviour. 00076 00077 This behaviour does not control the robot in any way; it is only meant 00078 for data collection and visualization. 00079 */ 00080 class Track : public Behavior { 00081 // Prevent copy and assignment 00082 Track(const Track&) ; 00083 Track& operator=(const Track&) ; 00084 00085 // Handy type to have around in a derived class 00086 typedef Behavior base ; 00087 00088 // Boilerplate code to make the generic factory design pattern work 00089 friend class subfactory<Track, base> ; 00090 typedef register_factory<Track, base> my_factory ; 00091 static my_factory register_me ; 00092 00093 /// The track behaviour maintains a list of poses and saves them to a 00094 /// file periodically. 00095 std::deque<Pose> m_history ; 00096 00097 /// A private constructor because behaviours are instantiated with an 00098 /// object factory and not directly by clients. 00099 Track() ; 00100 00101 /// Stuff to do before regular action processing begins. 00102 void pre_run() ; 00103 00104 /// Adding pose updates to pose history and logging to metrics log. 00105 static void add_pose(const Pose&, unsigned long client_data) ; 00106 00107 /// Most of this behaviour's action takes place in add_pose() and 00108 /// render_history(). Therefore, this method is not really necessary. 00109 /// But we define it because it is required (pure virtual). And since 00110 /// there's no point in having an empty function, we put it to good 00111 /// use by logging the robot's current speed. 00112 void action() ; 00113 00114 /// Visualizing the pose history on lobot's map. 00115 static void render_history(unsigned long client_data) ; 00116 00117 /// Clean-up. 00118 ~Track() ; 00119 } ; 00120 00121 //----------------------------------------------------------------------- 00122 00123 } // end of namespace encapsulating this file's definitions 00124 00125 #endif 00126 00127 /* So things look consistent in everyone's emacs... */ 00128 /* Local Variables: */ 00129 /* indent-tabs-mode: nil */ 00130 /* End: */