AgentManagerB.H

Go to the documentation of this file.
00001 /*!@file BeoSub/BeeBrain/AgentManagerB.H management class for agents on COM-B*/
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00005 // University of Southern California (USC) and the iLab at USC.         //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: Michael Montalbo <montalbo@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/BeoSub/BeeBrain/AgentManagerB.H $
00035 // $Id: AgentManagerB.H 9412 2008-03-10 23:10:15Z farhan $
00036 //
00037 
00038 #ifndef BEOSUB_BEEBRAIN_AGENT_MANAGER_B_H_DEFINED
00039 #define BEOSUB_BEEBRAIN_AGENT_MANAGER_B_H_DEFINED
00040 
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelParam.H"
00043 
00044 #include "Raster/Raster.H"
00045 #include "Image/Image.H"
00046 #include "Image/Pixels.H"
00047 #include "Image/CutPaste.H"
00048 
00049 #include "GUI/XWinManaged.H"
00050 #include "BeoSub/BeeBrain/Globals.H"
00051 
00052 #include "BeoSub/BeeBrain/DownwardVision.H"
00053 #include "BeoSub/BeeBrain/SonarListen.H"
00054 
00055 #include "BeoSub/BeeBrain/AgentManagerCommand.H"
00056 
00057 #include "Util/Timer.H"
00058 
00059 #include <pthread.h>
00060 
00061 class DownwardVisionAgent;
00062 class SonarListenAgent;
00063 
00064 class AgentManagerB : public ModelComponent
00065 {
00066 public:
00067 
00068   // ######################################################################
00069   /*! @name Constructors and Destructors */
00070   //@{
00071 
00072   //! Constructor
00073   AgentManagerB(OptionManager& mgr,
00074                 const std::string& descrName = "Agent Manager B",
00075                 const std::string& tagName = "Agent Manager B");
00076 
00077   //! Destructor
00078   virtual ~AgentManagerB();
00079 
00080   //@}
00081 
00082   // ######################################################################
00083   //! @name Access functions
00084   //@{
00085 
00086   //! set the current image to be processed
00087   void setCurrentImage(Image<PixRGB<byte> > image, uint fNum);
00088   void setCurrentImageB(Image<PixRGB<byte> > image, uint fNum);
00089 
00090   inline void setWindow(rutz::shared_ptr<XWinManaged> win,
00091                         Image<PixRGB<byte> > ima);
00092   inline void setWindowB(rutz::shared_ptr<XWinManaged> win,
00093                          Image<PixRGB<byte> > ima);
00094 
00095   void pushResult(CommandType cmdType,
00096                   DataTypes dataType,
00097                   rutz::shared_ptr<OceanObject> oceanObject);
00098 
00099   //! get the current image to be processed
00100   inline Image<PixRGB<byte> > getCurrentImage();
00101 
00102   //! get the current frame number
00103   inline uint getCurrentFrameNumber();
00104 
00105   rutz::shared_ptr<DownwardVisionAgent> getDownwardVisionAgent();
00106 
00107   rutz::shared_ptr<SonarListenAgent> getSonarListenAgent();
00108 
00109   uint getNumResults();
00110 
00111   std::pair<rutz::shared_ptr<AgentManagerCommand>,
00112             rutz::shared_ptr<OceanObject> >
00113    popResult();
00114 
00115   void drawImage(Image<PixRGB<byte> > ima, Point2D<int> point);
00116   void drawImageB(Image<PixRGB<byte> > ima, Point2D<int> point);
00117 
00118   //@}
00119 
00120   // ######################################################################
00121   //! @name member functions
00122   //@{
00123 
00124   //@}
00125 
00126 private:
00127 
00128   // for display purposes
00129   rutz::shared_ptr<XWinManaged> itsWindow;
00130   Image<PixRGB<byte> > itsDisplayImage;
00131   pthread_mutex_t itsDisplayLock;
00132 
00133   // the current image and lock
00134   Image<PixRGB<byte> > itsCurrentImage;
00135   uint itsFrameNumber;
00136   rutz::shared_ptr<Timer> itsInputImageTimer;
00137   std::vector<uint64> itsFrameDuration;
00138   pthread_mutex_t itsCurrentImageLock;
00139 
00140   // for display purposes B
00141   rutz::shared_ptr<XWinManaged> itsWindowB;
00142   Image<PixRGB<byte> > itsDisplayImageB;
00143   pthread_mutex_t itsDisplayLockB;
00144 
00145   // the current image and lock B
00146   Image<PixRGB<byte> > itsCurrentImageB;
00147   uint itsFrameNumberB;
00148   rutz::shared_ptr<Timer> itsInputImageTimerB;
00149   std::vector<uint64> itsFrameDurationB;
00150   pthread_mutex_t itsCurrentImageLockB;
00151 
00152   // forward vision agent
00153   rutz::shared_ptr<DownwardVisionAgent> itsDownwardVisionAgent;
00154   pthread_t itsDownwardVisionAgentThread;
00155 
00156   // prefrontal cortex agent: decision maker
00157   rutz::shared_ptr<SonarListenAgent> itsSonarListenAgent;
00158   pthread_t itsSonarListenAgentThread;
00159 
00160   // the results of the commands processed
00161   std::list<std::pair<rutz::shared_ptr<AgentManagerCommand>,
00162                       rutz::shared_ptr<OceanObject> > > itsResults;
00163   pthread_mutex_t itsResultsLock;
00164 
00165 };
00166 
00167 // ######################################################################
00168 inline void AgentManagerB::setWindow(rutz::shared_ptr<XWinManaged> win,
00169                       Image<PixRGB<byte> > ima)
00170 {
00171   itsWindow = win;
00172   itsDisplayImage = ima;
00173 }
00174 
00175 
00176 // ######################################################################
00177 inline void AgentManagerB::setWindowB(rutz::shared_ptr<XWinManaged> win,
00178                       Image<PixRGB<byte> > ima)
00179 {
00180   itsWindowB = win;
00181   itsDisplayImageB = ima;
00182 }
00183 
00184 // ######################################################################
00185 inline Image<PixRGB<byte> > AgentManagerB::getCurrentImage()
00186 {
00187   Image<PixRGB<byte> > image;
00188   pthread_mutex_lock(&itsCurrentImageLock);
00189   image = itsCurrentImage;
00190   pthread_mutex_unlock(&itsCurrentImageLock);
00191   return image;
00192 }
00193 
00194 // ######################################################################
00195 inline uint AgentManagerB::getCurrentFrameNumber()
00196 {
00197   uint fNum;
00198   pthread_mutex_lock(&itsCurrentImageLock);
00199   fNum = itsFrameNumber;
00200   pthread_mutex_unlock(&itsCurrentImageLock);
00201   return fNum;
00202 }
00203 
00204 #endif
00205 
00206 // ######################################################################
00207 /* So things look consistent in everyone's emacs... */
00208 /* Local Variables: */
00209 /* indent-tabs-mode: nil */
00210 /* End: */
Generated on Sun May 8 08:04:32 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3