RobotBrainService.C

00001 /*!@file src/Robots/RobotBrain/StartsThe primary motor cortex service.C */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00005 // by the 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: Lior Elazary
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/RobotBrain/RobotBrainService.C $
00035 // $Id: RobotBrainService.C 12281 2009-12-17 09:00:36Z itti $
00036 //
00037 
00038 #include "Component/ModelManager.H"
00039 #include "Component/ModelComponent.H"
00040 #include "Component/ModelOptionDef.H"
00041 #include "Robots/RobotBrain/PrimaryMotorCortexI.H"
00042 #include "Robots/RobotBrain/HippocampusI.H"
00043 #include "Robots/RobotBrain/PrimarySomatosensoryCortexI.H"
00044 #include "Robots/RobotBrain/SupplementaryMotorAreaI.H"
00045 #include "Robots/RobotBrain/InferotemporalCortexI.H"
00046 #include "Robots/RobotBrain/PrefrontalCortexI.H"
00047 #include "Robots/RobotBrain/LateralGeniculateNucleusI.H"
00048 #include <Ice/Ice.h>
00049 #include <Ice/Service.h>
00050 #include "Ice/RobotSimEvents.ice.H"
00051 #include "Ice/RobotBrainObjects.ice.H"
00052 #include "Ice/SimEventsUtils.H"
00053 #include "Ice/IceImageUtils.H"
00054 
00055 
00056 class RobotBrainServiceService : public Ice::Service {
00057   protected:
00058     virtual bool start(int, char* argv[]);
00059     virtual bool stop() {
00060       if (itsMgr)
00061         delete itsMgr;
00062       return true;
00063     }
00064 
00065   private:
00066     Ice::ObjectAdapterPtr itsAdapter;
00067     ModelManager *itsMgr;
00068 };
00069 
00070 bool RobotBrainServiceService::start(int argc, char* argv[])
00071 {
00072   char adapterStr[255];
00073 
00074   //Create the topics
00075   SimEventsUtils::createTopic(communicator(), "ActionMessageTopic");
00076   SimEventsUtils::createTopic(communicator(), "GPSMessageTopic");
00077   SimEventsUtils::createTopic(communicator(), "MotionMessageTopic");
00078   SimEventsUtils::createTopic(communicator(), "GoalStateMessageTopic");
00079   SimEventsUtils::createTopic(communicator(), "GoalProgressMessageTopic");
00080   SimEventsUtils::createTopic(communicator(), "AttendedRegionMessageTopic");
00081   SimEventsUtils::createTopic(communicator(), "ObjectMessageTopic");
00082   SimEventsUtils::createTopic(communicator(), "LandmarksMessageTopic");
00083 
00084   //Create the adapter
00085   sprintf(adapterStr, "default -p %i", RobotBrainObjects::RobotBrainPort);
00086         itsAdapter = communicator()->createObjectAdapterWithEndpoints("RobotBrainPort",
00087       adapterStr);
00088 
00089   //Create the manager and its objects
00090         itsMgr = new ModelManager("RobotBrainService");
00091 
00092   LINFO("PMC");
00093   nub::ref<PrimaryMotorCortexI> pmc(new PrimaryMotorCortexI(*itsMgr));
00094         itsMgr->addSubComponent(pmc);
00095   pmc->init(communicator(), itsAdapter);
00096 
00097   LINFO("PSC");
00098   nub::ref<PrimarySomatosensoryCortexI> psc(new PrimarySomatosensoryCortexI(*itsMgr));
00099         itsMgr->addSubComponent(psc);
00100   psc->init(communicator(), itsAdapter);
00101 
00102   LINFO("LGN");
00103   nub::ref<LateralGeniculateNucleusI> lgn(new LateralGeniculateNucleusI(*itsMgr));
00104         itsMgr->addSubComponent(lgn);
00105   lgn->init(communicator(), itsAdapter);
00106 
00107   LINFO("Hipp");
00108   nub::ref<HippocampusI> hipp(new HippocampusI(*itsMgr));
00109         itsMgr->addSubComponent(hipp);
00110   hipp->init(communicator(), itsAdapter);
00111 
00112   //LINFO("SMA");
00113   //nub::ref<SupplementaryMotorAreaI> sma(new SupplementaryMotorAreaI(*itsMgr));
00114         //itsMgr->addSubComponent(sma);
00115   //sma->init(communicator(), itsAdapter);
00116 
00117   LINFO("IT");
00118   nub::ref<InferotemporalCortexI> itc(new InferotemporalCortexI(*itsMgr));
00119   itsMgr->addSubComponent(itc);
00120   itc->init(communicator(), itsAdapter);
00121 
00122 
00123   LINFO("PFC");
00124   nub::ref<PrefrontalCortexI> pfc(new PrefrontalCortexI(*itsMgr));
00125   itsMgr->addSubComponent(pfc);
00126   pfc->init(communicator(), itsAdapter);
00127 
00128         itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0);
00129 
00130 
00131         itsAdapter->activate();
00132 
00133   itsMgr->start();
00134 
00135         return true;
00136 }
00137 
00138 // ######################################################################
00139 int main(int argc, char** argv) {
00140 
00141   RobotBrainServiceService svc;
00142   return svc.main(argc, argv);
00143 }
00144 
00145 
Generated on Sun May 8 08:41:32 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3