QT_Navigation.H

00001 /*!@file Robots2/Beobot2/Navigation/QT_Navigation/QT_Navigation.H Ice Module to Log data    */
00002 // //////////////////////////////////////////////////////////////////// //
00003 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00004 // University of Southern California (USC) and the iLab at USC.         //
00005 // See http://iLab.usc.edu for information about this project.          //
00006 // //////////////////////////////////////////////////////////////////// //
00007 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00008 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00009 // in Visual Environments, and Applications'' by Christof Koch and      //
00010 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00011 // pending; application number 09/912,225 filed July 23, 2001; see      //
00012 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00013 // //////////////////////////////////////////////////////////////////// //
00014 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00015 //                                                                      //
00016 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00017 // redistribute it and/or modify it under the terms of the GNU General  //
00018 // Public License as published by the Free Software Foundation; either  //
00019 // version 2 of the License, or (at your option) any later version.     //
00020 //                                                                      //
00021 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00022 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00023 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00024 // PURPOSE.  See the GNU General Public License for more details.       //
00025 //                                                                      //
00026 // You should have received a copy of the GNU General Public License    //
00027 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00028 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00029 // Boston, MA 02111-1307 USA.                                           //
00030 // //////////////////////////////////////////////////////////////////// //
00031 //
00032 // Primary maintainer for this file: Christian Siagian <siagian@usc.edu>
00033 // $HeadURL: svn://ilab.usc.edu/trunk/saliency/src/Robots/Beobot2/Navigation/QT_Navigation/QT_Navigation.H
00034 // $Id: QT_Navigation.H 12962 2010-03-06 02:13:53Z irock $
00035 //
00036 
00037 #include "Component/ModelComponent.H"
00038 #include "Component/ModelParam.H"
00039 
00040 #include "Robots/RobotBrain/RobotBrainComponent.H"
00041 #include "Util/Timer.H"
00042 
00043 #include "Ice/RobotBrainObjects.ice.H"
00044 #include "Ice/RobotSimEvents.ice.H"
00045 #include <IceUtil/Thread.h>
00046 
00047 #include "Robots/Beobot2/BeoCommon.H"
00048 
00049 #include "Media/FrameSeries.H"
00050 
00051 #include "Image/Image.H"
00052 #include "Image/Point3D.H"
00053 #include "GUI/SimpleMeter.H"
00054 
00055 #include "Neuro/GistEstimatorFFT.H"
00056 #include "Gist/FFN.H"
00057 
00058 #include <vector>
00059 #include "SIFT/Keypoint.H"
00060 #include "SIFT/VisualObject.H"
00061 #include "SIFT/VisualObjectDB.H"
00062 #include "SIFT/VisualObjectMatch.H"
00063 #include "Transport/FrameInfo.H"
00064 
00065 #ifndef QT_NAVIGATIONI_H
00066 #define QT_NAVIGATIONI_H
00067 
00068 typedef struct _RegionInformation
00069 {
00070   uint start;
00071   uint end;
00072 
00073   float minDistance;
00074   uint minIndex;
00075 }
00076 RegionInformation;
00077 
00078 class QT_Navigation : public RobotBrainComponent
00079 {
00080 public:
00081 
00082   QT_Navigation(OptionManager& mgr,
00083                 const std::string& descrName = "QT_Navigation",
00084                 const std::string& tagName = "QT_Navigation");
00085 
00086   ~QT_Navigation();
00087 
00088   virtual void evolve();
00089 
00090   //! Get a message
00091   virtual void updateMessage
00092   (const RobotSimEvents::EventMessagePtr& eMsg,
00093    const Ice::Current&);
00094 
00095   virtual void registerTopics();
00096 
00097   void start1();
00098 
00099 private:
00100   Beobot2::MotorCommand computeQT_Navigation();
00101 
00102   void navigation();
00103   void loadFrame();
00104   bool computeSIFT();//return true when match is valid
00105   double computeDirection();//return error rate of direction
00106   double computeDirection2(int teachID);//return error rate of direction
00107   void recovery();
00108   int computeEntropy();
00109   void updateKeyframe(double error);
00110 
00111   void updateMotorPID(double tran, double rot,double error);
00112   void updateMotor(double tran,double rot);
00113 
00114   void loadDB(const std::string& path);
00115   void loadReplayDB();
00116   void saveDB(int start,int end,const std::string& path);
00117   void drawState();
00118 
00119   void initFFN();
00120   void updatePosition(double turn);
00121   Image<PixRGB<byte> > drawInfoImg();
00122 
00123   Image<PixRGB<byte> > itsCurrImg;
00124   Image<PixRGB<byte> > itsProcImg;
00125   Image<float> itsNormalizedProcImg;
00126 
00127   Image<double> itsFftFeatures;
00128 
00129   IceUtil::Mutex its_Curr_Img_mutex;        //!< locking log filename
00130   IceUtil::Mutex its_Curr_Mtr_mutex;        //!< locking log filename
00131 
00132   nub::soft_ref<GistEstimatorFFT> itsFftComputer;
00133 
00134   nub::soft_ref<OutputFrameSeries> itsOfs;
00135 
00136   //! Overall Display Image
00137   Image<PixRGB<byte> > itsDispImg;
00138 
00139   //! Location Map which maintain the track of data
00140   Image<PixRGB<byte> > itsMapImg;
00141 
00142   //! Teach and Replay Images for Display
00143   Image<PixRGB<byte> > itsTeachImg;
00144   Image<PixRGB<byte> > itsReplayImg;
00145 
00146   //! Two objects for SIFT key points
00147   rutz::shared_ptr<VisualObject> itsTeachVo;
00148   rutz::shared_ptr<VisualObject> itsReplayVo;
00149 
00150   //! list of match point from two objects
00151   rutz::shared_ptr<VisualObjectMatch> itsMatchList;
00152 
00153   //! list of objects as evidence of its exitance
00154   rutz::shared_ptr<VisualObjectDB> itsVisualObjectDB;
00155   rutz::shared_ptr<VisualObjectDB> itsVisualObjectDB2;
00156 
00157   rutz::shared_ptr<FeedForwardNetwork> itsFfn;
00158   Image<double> itsPcaIcaVector;
00159   Image<double> itsFfnResults;
00160 
00161   Timer itsTimer;
00162   int itsCurrImgID;
00163   int itsPrevProcImgID;
00164   int itsTeachImgID;
00165   int itsReplayImgID;
00166   double itsRcTransSpeed;
00167   double itsRcRotSpeed;
00168   double itsTransSpeed;
00169   double itsRotSpeed;
00170   int itsRemoteMode;
00171 
00172   bool itsTrainMode;
00173   Image<double> itsNNrotCommand;
00174   Image<double> itsRCrotCommand;
00175 
00176   double itsDirVector;         // the angle of current turning
00177   int itsDir;                  // current direction
00178   double itsMilestoneErr;      // current error
00179   double itsFalseErrRate;      // mean error / std error
00180   int itsDirCount;             // current direction count since last turning
00181   Point3D<double>itsPosition;
00182   Point3D<double>itsError;
00183   OModelParam<bool>        itsRealCamera;
00184   bool itsEstop;
00185   bool itsReplayDBLoaded;
00186 
00187   double itsIState;
00188   double itsDState;
00189 
00190   double itsPGain;
00191   double itsIGain;
00192   double itsDGain;
00193 };
00194 #endif
00195 
00196 // ######################################################################
00197 /* So things look consistent in everyone's emacs... */
00198 /* Local Variables: */
00199 /* indent-tabs-mode: nil */
00200 /* End: */
Generated on Sun May 8 08:05:37 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3