AgentManagerA.H

Go to the documentation of this file.
00001 /*!@file BeoSub/BeeBrain/AgentManagerA.H management class for agents on COM-A*/
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/AgentManagerA.H $
00035 // $Id: AgentManagerA.H 9412 2008-03-10 23:10:15Z farhan $
00036 //
00037 
00038 #ifndef BEOSUB_BEEBRAIN_AGENT_MANAGER_A_H_DEFINED
00039 #define BEOSUB_BEEBRAIN_AGENT_MANAGER_A_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 
00051 #include "BeoSub/BeeBrain/Globals.H"
00052 #include "BeoSub/BeeBrain/AgentManagerCommand.H"
00053 
00054 #include "BeoSub/BeeBrain/ForwardVision.H"
00055 #include "BeoSub/BeeBrain/PreFrontalCortex.H"
00056 #include "BeoSub/BeeBrain/PreMotorComplex.H"
00057 
00058 #include "BeoSub/BeeBrain/OceanObject.H"
00059 
00060 #include "Util/Timer.H"
00061 #include <pthread.h>
00062 
00063 class PreFrontalCortexAgent;
00064 class PreMotorComplex;
00065 class ForwardVisionAgent;
00066 
00067 class AgentManagerA : public ModelComponent
00068 {
00069 public:
00070 
00071   // ######################################################################
00072   /*! @name Constructors and Destructors */
00073   //@{
00074 
00075   //! Constructor
00076   AgentManagerA(OptionManager& mgr,
00077                 const std::string& descrName = "Agent Manager A",
00078                 const std::string& tagName = "Agent Manager A");
00079 
00080   //! Destructor
00081   virtual ~AgentManagerA();
00082 
00083   //@}
00084 
00085   // ######################################################################
00086   //! @name Access functions
00087   //@{
00088 
00089   //! set the current image to be processed
00090   void setCurrentImage(Image<PixRGB<byte> > image, uint fNum);
00091 
00092   inline void setWindow(rutz::shared_ptr<XWinManaged> win,
00093                         Image<PixRGB<byte> > ima);
00094 
00095   void pushCommand(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   //! set the current object to be processed
00106   bool updateOceanObject(rutz::shared_ptr<OceanObject> oceanObject,
00107                          DataTypes oceanObjectDataType);
00108 
00109   rutz::shared_ptr<ForwardVisionAgent> getForwardVisionAgent();
00110 
00111   rutz::shared_ptr<PreFrontalCortexAgent> getPreFrontalCortexAgent();
00112 
00113   rutz::shared_ptr<PreMotorComplex> getPreMotorComplex();
00114 
00115   uint getNumCommands();
00116 
00117   rutz::shared_ptr<AgentManagerCommand> popCommand();
00118 
00119   void drawImage(Image<PixRGB<byte> > ima, Point2D<int> point);
00120 
00121   void startRun();
00122 
00123   //@}
00124 
00125 private:
00126 
00127   // for display purposes
00128   rutz::shared_ptr<XWinManaged> itsWindow;
00129   Image<PixRGB<byte> > itsDisplayImage;
00130   pthread_mutex_t itsDisplayLock;
00131 
00132   // the current image and lock
00133   Image<PixRGB<byte> > itsCurrentImage;
00134   uint itsFrameNumber;
00135   rutz::shared_ptr<Timer> itsInputImageTimer;
00136   std::vector<uint64> itsFrameDuration;
00137   pthread_mutex_t itsCurrentImageLock;
00138 
00139   // forward vision agent
00140   rutz::shared_ptr<ForwardVisionAgent> itsForwardVisionAgent;
00141   pthread_t itsForwardVisionAgentThread;
00142 
00143   // prefrontal cortex agent: decision maker
00144   rutz::shared_ptr<PreFrontalCortexAgent> itsPreFrontalCortexAgent;
00145   pthread_t itsPreFrontalCortexAgentThread;
00146 
00147   // premotor complex agent: generate motor commands
00148   rutz::shared_ptr<PreMotorComplex> itsPreMotorComplex;
00149   pthread_t itsPreMotorComplexThread;
00150 
00151   // current motor command
00152   motorCommand itsCurrentMotorCommand;
00153   pthread_mutex_t itsCurrentMotorCommandLock;
00154 
00155   // store the ocean objects
00156   std::vector<rutz::shared_ptr<OceanObject> > itsOceanObjects;
00157   pthread_mutex_t itsOceanObjectsLock;
00158 
00159   // command cue to send to COM_B
00160   std::list<rutz::shared_ptr<AgentManagerCommand> > itsCommands;
00161   pthread_mutex_t itsCommandsLock;
00162 
00163 };
00164 
00165 // ######################################################################
00166 inline void AgentManagerA::setWindow(rutz::shared_ptr<XWinManaged> win,
00167                       Image<PixRGB<byte> > ima)
00168 {
00169   itsWindow = win;
00170   itsDisplayImage = ima;
00171 }
00172 
00173 // ######################################################################
00174 inline Image<PixRGB<byte> > AgentManagerA::getCurrentImage()
00175 {
00176   Image<PixRGB<byte> > image;
00177   pthread_mutex_lock(&itsCurrentImageLock);
00178   image = itsCurrentImage;
00179   pthread_mutex_unlock(&itsCurrentImageLock);
00180   return image;
00181 }
00182 
00183 // ######################################################################
00184 inline uint AgentManagerA::getCurrentFrameNumber()
00185 {
00186   uint fNum;
00187   pthread_mutex_lock(&itsCurrentImageLock);
00188   fNum = itsFrameNumber;
00189   pthread_mutex_unlock(&itsCurrentImageLock);
00190   return fNum;
00191 }
00192 
00193 #endif
00194 
00195 // ######################################################################
00196 /* So things look consistent in everyone's emacs... */
00197 /* Local Variables: */
00198 /* indent-tabs-mode: nil */
00199 /* End: */
Generated on Sun May 8 08:04:32 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3