00001 /*!@file Neuro/PrefrontalCortexService.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/NeovisionII/PrefrontalCortexService.C $ 00035 // $Id: PrefrontalCortexService.C 12962 2010-03-06 02:13:53Z irock $ 00036 // 00037 00038 #include "NeovisionII/PrefrontalCortexService.H" 00039 #include "Image/ColorOps.H" 00040 00041 PrefrontalCortexI::PrefrontalCortexI(OptionManager& mgr, 00042 const std::string& descrName, 00043 const std::string& tagName ) : 00044 ModelComponent(mgr, descrName, tagName), 00045 itsCurrentState(0), 00046 itsArmXOffset(358.76), //arm offset from camera 00047 itsArmYOffset(-372.16), 00048 itsArmZOffset(-80.00) 00049 { 00050 //Subscribe to the various topics 00051 IceStorm::TopicPrx topicPrx; 00052 itsTopicsSubscriptions.push_back(TopicInfo("RetinaTopic", topicPrx)); 00053 itsTopicsSubscriptions.push_back(TopicInfo("SaliencyMapTopic", topicPrx)); 00054 itsTopicsSubscriptions.push_back(TopicInfo("VisualTrackerTopic", topicPrx)); 00055 itsTopicsSubscriptions.push_back(TopicInfo("SegmenterTopic", topicPrx)); 00056 itsTopicsSubscriptions.push_back(TopicInfo("CameraCtrlTopic", topicPrx)); 00057 itsTopicsSubscriptions.push_back(TopicInfo("InferotemporalCortexTopic", topicPrx)); 00058 itsTopicsSubscriptions.push_back(TopicInfo("HippocampusTopic", topicPrx)); 00059 itsTopicsSubscriptions.push_back(TopicInfo("GUITopic", topicPrx)); 00060 00061 assignStates(); 00062 } 00063 00064 PrefrontalCortexI::~PrefrontalCortexI() 00065 { 00066 unsubscribeSimEvents(); 00067 } 00068 00069 void PrefrontalCortexI::init() 00070 { 00071 SimEvents::GUIInputMessagePtr ggMsg = new SimEvents::GUIInputMessage; 00072 ggMsg->msg = "Please place my pieces and yours on the table and press enter."; 00073 ggMsg->rollDice = false; 00074 itsEventsPub->evolve(ggMsg); 00075 //itsCurrentState = WAIT_FOR_GAME_START; 00076 itsCurrentState = INIT_PTZ; 00077 00078 getUserInput = true; 00079 } 00080 00081 void PrefrontalCortexI::initSimEvents(Ice::CommunicatorPtr icPtr, Ice::ObjectPrx objectPrx) 00082 { 00083 //Get the IceStorm object 00084 Ice::ObjectPrx obj = icPtr->stringToProxy("SimEvents/TopicManager:tcp -p 11111"); 00085 IceStorm::TopicManagerPrx topicManager = 00086 IceStorm::TopicManagerPrx::checkedCast(obj); 00087 00088 //Create a PrefrontalCortex Topic 00089 IceStorm::TopicPrx topic; 00090 try { 00091 topic = topicManager->retrieve("PrefrontalCortexTopic"); //check if the Retina topic exists 00092 } catch (const IceStorm::NoSuchTopic&) { 00093 topic = topicManager->create("PrefrontalCortexTopic"); //The retina topic does not exists, create 00094 } 00095 //Make a one way visualCortex message publisher for efficency 00096 Ice::ObjectPrx pub = topic->getPublisher()->ice_oneway(); 00097 itsEventsPub = SimEvents::EventsPrx::uncheckedCast(pub); 00098 00099 //Subscribe the SimulationViewer to theTopics 00100 itsObjectPrx = objectPrx; 00101 //subscribe to the topics 00102 for(uint i=0; i<itsTopicsSubscriptions.size(); i++) 00103 { 00104 try { 00105 IceStorm::QoS qos; 00106 itsTopicsSubscriptions[i].topicPrx = 00107 topicManager->retrieve(itsTopicsSubscriptions[i].name.c_str()); //Get the 00108 itsTopicsSubscriptions[i].topicPrx->subscribeAndGetPublisher(qos, itsObjectPrx); //Subscribe to the retina topic 00109 } catch (const IceStorm::NoSuchTopic&) { 00110 LINFO("Error! No %s topic found!", itsTopicsSubscriptions[i].name.c_str()); 00111 } catch (const char* msg) { 00112 LINFO("Error %s", msg); 00113 } catch (const Ice::Exception& e) { 00114 cerr << e << endl; 00115 } 00116 } 00117 } 00118 00119 void PrefrontalCortexI::unsubscribeSimEvents() 00120 { 00121 //Unsubscribe from all the topics we are registerd to 00122 for(uint i=0; i<itsTopicsSubscriptions.size(); i++) 00123 { 00124 itsTopicsSubscriptions[i].topicPrx->unsubscribe(itsObjectPrx); 00125 } 00126 } 00127 00128 00129 void PrefrontalCortexI::evolve(const SimEvents::EventMessagePtr& eMsg, 00130 const Ice::Current&) 00131 { 00132 00133 if(eMsg->ice_isA("::SimEvents::RetinaMessage")){ 00134 SimEvents::RetinaMessagePtr msg = SimEvents::RetinaMessagePtr::dynamicCast(eMsg); 00135 itsCurrentRetinaImg = Ice2Image<PixRGB<byte> >(msg->img); 00136 } 00137 00138 int nextState = processState(itsCurrentState, eMsg); 00139 setCurrentState(nextState); 00140 } 00141 00142 void PrefrontalCortexI::setSalientTrackLoc(const SimEvents::SaliencyMapMessagePtr& msg) 00143 { 00144 //Assign tracker to the most salient locations 00145 SimEvents::VisualTrackerBiasMessagePtr bMsg = new SimEvents::VisualTrackerBiasMessage; 00146 for(uint i=0; i<msg->nMostSalientLoc.size(); i++) 00147 { 00148 SimEvents::LocInfo locInfo = msg->nMostSalientLoc[i]; 00149 LINFO("Assigning the most salient location to a track point: %ix%i", 00150 locInfo.fullresMaxpos.i, locInfo.fullresMaxpos.j); 00151 SimEvents::TrackInfo trackInfo; 00152 trackInfo.pos.i = locInfo.fullresMaxpos.i; 00153 trackInfo.pos.j = locInfo.fullresMaxpos.j; 00154 trackInfo.err = 0; 00155 bMsg->locToTrack.push_back(trackInfo); 00156 00157 //Send a message to the hippocampus that we are going to rec this location 00158 SimEvents::HippocampusBiasMessagePtr hMsg = new SimEvents::HippocampusBiasMessage; 00159 hMsg->loc = trackInfo.pos; 00160 hMsg->objectName = "MODE:rec"; 00161 hMsg->img = Image2Ice(itsCurrentRetinaImg); 00162 itsEventsPub->evolve(hMsg); 00163 00164 break; //For now track the most salient location 00165 } 00166 itsEventsPub->evolve(bMsg); 00167 } 00168 00169 void PrefrontalCortexI::setTrackLoc(Point2D<int> loc) 00170 { 00171 //Assign tracker to the most salient locations 00172 SimEvents::VisualTrackerBiasMessagePtr bMsg = new SimEvents::VisualTrackerBiasMessage; 00173 LINFO("Assigning the location to a track point: %ix%i", loc.i, loc.j); 00174 SimEvents::TrackInfo trackInfo; 00175 trackInfo.pos.i = loc.i; 00176 trackInfo.pos.j = loc.j; 00177 trackInfo.err = 0; 00178 bMsg->locToTrack.push_back(trackInfo); 00179 00180 //Send a message to the hippocampus that we are going to rec this location 00181 SimEvents::HippocampusBiasMessagePtr hMsg = new SimEvents::HippocampusBiasMessage; 00182 hMsg->loc = trackInfo.pos; 00183 hMsg->objectName = "MODE:rec"; 00184 hMsg->img = Image2Ice(itsCurrentRetinaImg); 00185 itsEventsPub->evolve(hMsg); 00186 itsEventsPub->evolve(bMsg); 00187 00188 } 00189 00190 void PrefrontalCortexI::setTrackSegLoc(const SimEvents::VisualTrackerMessagePtr& msg) 00191 { 00192 SimEvents::SegmenterBiasMessagePtr sMsg = new SimEvents::SegmenterBiasMessage; 00193 for(uint i=0; i<msg->trackLocs.size(); i++) 00194 { 00195 SimEvents::TrackInfo trackInfo = msg->trackLocs[i]; 00196 //LINFO("Assigning the tracker location to a segment point: %ix%i", 00197 // trackInfo.pos.i, trackInfo.pos.j); 00198 SimEvents::SegInfo segInfo; 00199 segInfo.loc.i = trackInfo.pos.i; 00200 segInfo.loc.j = trackInfo.pos.j; 00201 sMsg->regionsToSeg.push_back(segInfo); 00202 break; //For now seg only one location 00203 } 00204 itsEventsPub->evolve(sMsg); 00205 } 00206 00207 void PrefrontalCortexI::setPTZoomIn() 00208 { 00209 //Send a message that we want to ptz 00210 SimEvents::CameraCtrlBiasMessagePtr ptzMsg = new SimEvents::CameraCtrlBiasMessage; 00211 ptzMsg->zoomIn = true; 00212 LINFO("Sending Zooming in"); 00213 itsEventsPub->evolve(ptzMsg); 00214 } 00215 00216 int PrefrontalCortexI::processState(int state, const SimEvents::EventMessagePtr& eMsg) 00217 { 00218 if ((uint)state > itsStates.size()) 00219 { 00220 LINFO("invalid state %i", state); 00221 return -1; 00222 } 00223 00224 switch(state) 00225 { 00226 case WAIT_FOR_GAME_START: 00227 if (eMsg->ice_isA("::SimEvents::GUIOutputMessage")){ 00228 SimEvents::GUIOutputMessagePtr msg = SimEvents::GUIOutputMessagePtr::dynamicCast(eMsg); 00229 LINFO("Key %i", msg->key); 00230 00231 if (msg->key == 36) 00232 { 00233 SimEvents::GUIInputMessagePtr ggMsg = new SimEvents::GUIInputMessage; 00234 ggMsg->msg = "Please wait while I figure where the pieces are."; 00235 ggMsg->rollDice = false; 00236 itsEventsPub->evolve(ggMsg); 00237 return itsStates[state].nextState; 00238 } 00239 } 00240 return WAIT_FOR_GAME_START; 00241 00242 00243 // Get the game state 00244 case INIT_PTZ: 00245 { 00246 LINFO("INIT PTZ"); 00247 //Init the ptz 00248 SimEvents::CameraCtrlBiasMessagePtr ptzMsg = new SimEvents::CameraCtrlBiasMessage; 00249 ptzMsg->initPtz = true; 00250 ptzMsg->zoomIn = false; 00251 ptzMsg->zoomOut = false; 00252 itsEventsPub->evolve(ptzMsg); 00253 return itsStates[state].nextState; 00254 } 00255 case INIT_PTZ_DONE: //Check for ptz init done 00256 //check if we finished initlizing the ptz 00257 if (eMsg->ice_isA("::SimEvents::CameraCtrlMessage")){ 00258 SimEvents::CameraCtrlMessagePtr msg = SimEvents::CameraCtrlMessagePtr::dynamicCast(eMsg); 00259 if (msg->initPtzDone) 00260 { 00261 //Send the image to hippocampus to check if anything has changed 00262 return itsStates[state].nextState; 00263 } 00264 } 00265 return INIT_PTZ_DONE; 00266 case SET_TRACKING: //Set tracking 00267 if (!getUserInput) 00268 { 00269 if (eMsg->ice_isA("::SimEvents::SaliencyMapMessage")){ 00270 SimEvents::SaliencyMapMessagePtr msg = SimEvents::SaliencyMapMessagePtr::dynamicCast(eMsg); 00271 setSalientTrackLoc(msg); 00272 setPTZoomIn(); 00273 getUserInput = true; 00274 return itsStates[state].nextState; 00275 } 00276 } else { 00277 00278 if (eMsg->ice_isA("::SimEvents::GUIOutputMessage")){ 00279 SimEvents::GUIOutputMessagePtr msg = SimEvents::GUIOutputMessagePtr::dynamicCast(eMsg); 00280 if (msg->loc.i > 0 && msg->loc.j > 0) 00281 { 00282 setTrackLoc(Point2D<int>(msg->loc.i, msg->loc.j)); 00283 setPTZoomIn(); 00284 //getUserInput = false; 00285 return itsStates[state].nextState; 00286 } 00287 } 00288 } 00289 00290 return SET_TRACKING; 00291 case TRACKING: //Tracking wait for done 00292 { 00293 if (eMsg->ice_isA("::SimEvents::CameraCtrlMessage")){ 00294 SimEvents::CameraCtrlMessagePtr msg = SimEvents::CameraCtrlMessagePtr::dynamicCast(eMsg); 00295 if (msg->zoomDone) 00296 { 00297 itsPan = msg->pan; 00298 itsTilt = msg->tilt; 00299 return itsStates[state].nextState; 00300 } 00301 } 00302 } 00303 return TRACKING; 00304 case SET_SEG_LOC: 00305 if (eMsg->ice_isA("::SimEvents::VisualTrackerMessage")){ 00306 SimEvents::VisualTrackerMessagePtr msg = SimEvents::VisualTrackerMessagePtr::dynamicCast(eMsg); 00307 if (msg->trackLocs.size()) //we have a tracking point, continue tracking 00308 { 00309 setTrackSegLoc(msg); 00310 itsCount=0; 00311 return itsStates[state].nextState; 00312 } 00313 } 00314 return SET_SEG_LOC; 00315 00316 case GET_SEG_IMG: //Wait for an img to recognize 00317 if(eMsg->ice_isA("::SimEvents::SegmenterMessage")){ 00318 SimEvents::SegmenterMessagePtr msg = SimEvents::SegmenterMessagePtr::dynamicCast(eMsg); 00319 00320 SimEvents::InfrotemporalCortexBiasMessagePtr sMsg = new SimEvents::InfrotemporalCortexBiasMessage; 00321 for(uint i=0; i<msg->segLocs.size(); i++) 00322 { 00323 SimEvents::SegInfo segInfo = msg->segLocs[i]; 00324 sMsg->img = segInfo.img; 00325 } 00326 LINFO("Send img to SIFT"); 00327 00328 itsEventsPub->evolve(sMsg); 00329 return itsStates[state].nextState; 00330 } 00331 return GET_SEG_IMG; 00332 00333 case GET_OBJ_INFO: //Done 00334 //Wait for rec. message 00335 if(eMsg->ice_isA("::SimEvents::InfrotemporalCortexMessage")){ 00336 SimEvents::InfrotemporalCortexMessagePtr msg = SimEvents::InfrotemporalCortexMessagePtr::dynamicCast(eMsg); 00337 LINFO("Got message"); 00338 00339 SimEvents::HippocampusBiasMessagePtr hMsg = new SimEvents::HippocampusBiasMessage; 00340 hMsg->loc.i = -2; hMsg->loc.j = -2; 00341 hMsg->pan = itsPan; 00342 hMsg->tilt = itsTilt; 00343 hMsg->rotation = msg->rotation; 00344 00345 hMsg->objectName = msg->objectName; 00346 hMsg->img.width=0; hMsg->img.height=0; 00347 00348 itsEventsPub->evolve(hMsg); 00349 00350 LINFO("Got object %s with score %f", 00351 msg->objectName.c_str(), msg->confidence); 00352 if (msg->objectName == "nomatch" && itsCount < 3) 00353 { 00354 itsCount++; 00355 return GET_SEG_IMG; 00356 } 00357 else 00358 return itsStates[state].nextState; 00359 } 00360 return GET_OBJ_INFO; 00361 00362 case GET_OBJ_STATE: 00363 if(eMsg->ice_isA("::SimEvents::HippocampusMessage")){ 00364 SimEvents::HippocampusMessagePtr hMsg = SimEvents::HippocampusMessagePtr::dynamicCast(eMsg); 00365 00366 //Show the objects we got so far 00367 for(uint i=0; i<hMsg->objectsState.size(); i++) 00368 { 00369 SimEvents::ObjectState objectState = hMsg->objectsState[i]; 00370 LINFO("Got object %s at %ix%i (%f,%f,%f) inDanger=%i", 00371 objectState.objectName.c_str(), 00372 objectState.loc.i, objectState.loc.j, 00373 objectState.pos.x, objectState.pos.y, objectState.pos.z, 00374 objectState.inDanger); 00375 00376 //if (objectState.inDanger) 00377 { 00378 //Move object out of the way 00379 LINFO("Moving object %s", objectState.objectName.c_str()); 00380 SimEvents::PrimaryMotorCortexBiasMessagePtr msg = new SimEvents::PrimaryMotorCortexBiasMessage; 00381 msg->moveArm = true; 00382 msg->armPos.x = objectState.pos.x + itsArmXOffset; 00383 msg->armPos.y = objectState.pos.y + itsArmYOffset; 00384 msg->armPos.z = itsArmZOffset; 00385 msg->armPos.rot = 0; 00386 msg->armPos.roll = 0; 00387 msg->armPos.gripper = 0; 00388 00389 itsEventsPub->evolve(msg); 00390 } 00391 } 00392 00393 //Check if we got all the objects 00394 if (hMsg->objectsState.size() == 4) 00395 return ZOOM_OUT; //play the game 00396 else 00397 return itsStates[state].nextState; 00398 } 00399 return GET_OBJ_STATE; 00400 00401 00402 case ZOOM_OUT: 00403 { 00404 //Init the ptz 00405 SimEvents::CameraCtrlBiasMessagePtr ptzMsg = new SimEvents::CameraCtrlBiasMessage; 00406 ptzMsg->initPtz = true; 00407 ptzMsg->zoomIn = false; 00408 ptzMsg->zoomOut = false; 00409 itsEventsPub->evolve(ptzMsg); 00410 return itsStates[state].nextState; 00411 } 00412 case ZOOM_OUT_DONE: 00413 //check if we finished initlizing the ptz 00414 if (eMsg->ice_isA("::SimEvents::CameraCtrlMessage")){ 00415 SimEvents::CameraCtrlMessagePtr msg = SimEvents::CameraCtrlMessagePtr::dynamicCast(eMsg); 00416 if (msg->initPtzDone) 00417 { 00418 //Send the image to hippocampus to check if anything has changed 00419 00420 return itsStates[state].nextState; 00421 } 00422 } 00423 return ZOOM_OUT_DONE; 00424 00425 case GAMEPLAY_PLAYERMOVE: 00426 { 00427 SimEvents::GUIInputMessagePtr ggMsg = new SimEvents::GUIInputMessage; 00428 ggMsg->msg = "Please move your pieces and press enter."; 00429 ggMsg->rollDice = false; 00430 itsEventsPub->evolve(ggMsg); 00431 } 00432 return itsStates[state].nextState; 00433 00434 case GAMEPLAY_PLAYERMOVE_DONE: 00435 if (eMsg->ice_isA("::SimEvents::GUIOutputMessage")){ 00436 SimEvents::GUIOutputMessagePtr msg = SimEvents::GUIOutputMessagePtr::dynamicCast(eMsg); 00437 00438 if (msg->key == 36) 00439 { 00440 SimEvents::GUIInputMessagePtr ggMsg = new SimEvents::GUIInputMessage; 00441 ggMsg->msg = "Please wait while I figure where the pieces are."; 00442 ggMsg->rollDice = false; 00443 itsEventsPub->evolve(ggMsg); 00444 return itsStates[state].nextState; 00445 } 00446 } 00447 return GAMEPLAY_PLAYERMOVE_DONE; 00448 } 00449 00450 00451 return -1; //Return an invalid state 00452 } 00453 00454 00455 00456 void PrefrontalCortexI::assignStates() 00457 { 00458 itsStates.push_back(StateInfo(START_OF_GAME_MSG, "Wait for Game to start", 00459 WAIT_FOR_GAME_START)); 00460 itsStates.push_back(StateInfo(WAIT_FOR_GAME_START, "Start the Game", INIT_PTZ)); 00461 itsStates.push_back(StateInfo(INIT_PTZ, "Init PTZ", INIT_PTZ_DONE)); 00462 itsStates.push_back(StateInfo(INIT_PTZ_DONE, "Check PTZ Init Done", SET_TRACKING)); 00463 itsStates.push_back(StateInfo(SET_TRACKING, "SetTracking", TRACKING)); 00464 itsStates.push_back(StateInfo(TRACKING, "Tracking", SET_SEG_LOC)); 00465 itsStates.push_back(StateInfo(SET_SEG_LOC, "Set SEgmantation location", GET_SEG_IMG)); 00466 itsStates.push_back(StateInfo(GET_SEG_IMG, "Get Image to Recognize", GET_OBJ_INFO)); 00467 itsStates.push_back(StateInfo(GET_OBJ_INFO, "Recognize Image", GET_OBJ_STATE)); 00468 itsStates.push_back(StateInfo(GET_OBJ_STATE, "Get Game State", INIT_PTZ)); 00469 itsStates.push_back(StateInfo(ZOOM_OUT, "Observe the game", ZOOM_OUT_DONE)); 00470 itsStates.push_back(StateInfo(ZOOM_OUT_DONE, "Observe the game Done", GAMEPLAY_PLAYERMOVE)); 00471 itsStates.push_back(StateInfo(GAMEPLAY_PLAYERMOVE, "Player move", GAMEPLAY_PLAYERMOVE_DONE)); 00472 itsStates.push_back(StateInfo(GAMEPLAY_PLAYERMOVE_DONE, "Player move done", GAMEPLAY_PLAYERMOVE_DONE)); 00473 00474 setCurrentState(0); 00475 } 00476 00477 void PrefrontalCortexI::setCurrentState(int s) 00478 { 00479 if (s == -1) return; 00480 if ((uint)s > itsStates.size()) 00481 { 00482 LINFO("Entering an invalid state %i", s); 00483 return; 00484 } 00485 if (itsCurrentState != s) 00486 { 00487 itsLastState = s; 00488 LINFO("Entering state: %i:%s", s, itsStates[s].name.c_str()); 00489 itsCurrentState = s; 00490 00491 } 00492 } 00493 00494 00495 /////////////////////////// The VC Service to init the retina and start as a deamon /////////////// 00496 class PrefrontalCortexService : public Ice::Service { 00497 protected: 00498 virtual bool start(int, char* argv[]); 00499 virtual bool stop() { 00500 if (itsMgr) 00501 delete itsMgr; 00502 return true; 00503 } 00504 00505 private: 00506 Ice::ObjectAdapterPtr itsAdapter; 00507 ModelManager *itsMgr; 00508 }; 00509 00510 bool PrefrontalCortexService::start(int argc, char* argv[]) 00511 { 00512 00513 itsMgr = new ModelManager("PrefrontalCortexService"); 00514 00515 nub::ref<PrefrontalCortexI> pc(new PrefrontalCortexI(*itsMgr)); 00516 itsMgr->addSubComponent(pc); 00517 00518 itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0); 00519 00520 char adapterStr[255]; 00521 sprintf(adapterStr, "default -p %i", BrainObjects::PrefrontalCortexPort); 00522 itsAdapter = communicator()->createObjectAdapterWithEndpoints("PrefrontalCortexAdapter", 00523 adapterStr); 00524 00525 Ice::ObjectPtr object = pc.get(); 00526 Ice::ObjectPrx objectPrx = itsAdapter->add(object, communicator()->stringToIdentity("PrefrontalCortex")); 00527 pc->initSimEvents(communicator(), objectPrx); 00528 itsAdapter->activate(); 00529 itsMgr->start(); 00530 00531 pc->init(); 00532 00533 return true; 00534 } 00535 00536 // ###################################################################### 00537 int main(int argc, char** argv) { 00538 00539 PrefrontalCortexService svc; 00540 return svc.main(argc, argv); 00541 } 00542 00543