00001 /*!@file Robots2/Beobot2/Navigation/ND_Navigation/ND_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/ND_Navigation/ND_Navigation.H 00034 // $Id: ND_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 00053 #include <vector> 00054 00055 #ifndef ND_NAVIGATIONI_H 00056 #define ND_NAVIGATIONI_H 00057 00058 typedef struct _RegionInformation 00059 { 00060 uint start; 00061 uint end; 00062 00063 float minDistance; 00064 uint minIndex; 00065 } 00066 RegionInformation; 00067 00068 class ND_Navigation : public RobotBrainComponent 00069 { 00070 public: 00071 00072 ND_Navigation(OptionManager& mgr, 00073 const std::string& descrName = "ND_Navigation", 00074 const std::string& tagName = "ND_Navigation"); 00075 00076 ~ND_Navigation(); 00077 00078 virtual void evolve(); 00079 00080 //! Get a message 00081 virtual void updateMessage 00082 (const RobotSimEvents::EventMessagePtr& eMsg, 00083 const Ice::Current&); 00084 00085 virtual void registerTopics(); 00086 00087 void start1(); 00088 00089 private: 00090 Beobot2::MotorCommand computeND_Navigation(); 00091 void updateMotor(double tran,double rot); 00092 00093 void findGapsAndRegions(); 00094 00095 void setMinimumDistances(); 00096 00097 void findGoalRegion(); 00098 00099 void biasForSafety(); 00100 00101 void drawSituation(); 00102 00103 void drawRangeLine(float dist, int angle, PixRGB<byte> c); 00104 00105 bool isNavigableRegion(uint index); 00106 00107 std::string itsLogFilename; 00108 IceUtil::Mutex its_logFilename_mutex; //!< locking log filename 00109 00110 00111 std::vector<double> itsDistances; 00112 std::vector<double> itsAngles; 00113 00114 float itsMinDistance; 00115 float itsMaxDistance; 00116 uint itsGoalSector; 00117 uint itsGoalRegion; 00118 00119 uint itsNextDirection; 00120 uint itsPrevDirection; 00121 uint itsLeftEnd; 00122 uint itsRightEnd; 00123 00124 uint itsBigJumpCount; 00125 00126 std::vector<uint> itsGaps; 00127 std::vector<RegionInformation > itsRegions; 00128 00129 nub::soft_ref<OutputFrameSeries> itsOfs; 00130 Image<PixRGB<byte> > itsDispImg; 00131 00132 Timer itsTimer; 00133 int itsCurrMessageID; 00134 00135 }; 00136 00137 #endif 00138 00139 00140 // ###################################################################### 00141 /* So things look consistent in everyone's emacs... */ 00142 /* Local Variables: */ 00143 /* indent-tabs-mode: nil */ 00144 /* End: */