00001 00002 #include "Component/ModelManager.H" 00003 #include "Component/ModelComponent.H" 00004 #include "Component/ModelOptionDef.H" 00005 #include "Robots/RobotBrain/RetinaI.H" 00006 #include <Ice/Ice.h> 00007 #include <Ice/Service.h> 00008 #include "Ice/RobotSimEvents.ice.H" 00009 #include "Ice/RobotBrainObjects.ice.H" 00010 #include "Ice/SimEventsUtils.H" 00011 #include "Ice/IceImageUtils.H" 00012 00013 // My stuff 00014 #include "Robots/SeaBeeIII/Localization.H" 00015 00016 00017 00018 class RobotBrainServiceService : public Ice::Service { 00019 protected: 00020 virtual bool start(int, char* argv[]); 00021 virtual bool stop() { 00022 if (itsMgr) 00023 delete itsMgr; 00024 return true; 00025 } 00026 00027 private: 00028 Ice::ObjectAdapterPtr itsAdapter; 00029 ModelManager *itsMgr; 00030 }; 00031 00032 bool RobotBrainServiceService::start(int argc, char* argv[]) 00033 { 00034 char adapterStr[255]; 00035 00036 //Create the topics 00037 SimEventsUtils::createTopic(communicator(), "RetinaMessageTopic"); 00038 00039 //Create the adapter 00040 int port = RobotBrainObjects::RobotBrainPort; 00041 bool connected = false; 00042 00043 while(!connected) 00044 { 00045 try 00046 { 00047 LINFO("Trying Port:%d", port); 00048 sprintf(adapterStr, "default -p %i", port); 00049 itsAdapter = communicator()->createObjectAdapterWithEndpoints("Retina", 00050 adapterStr); 00051 connected = true; 00052 } 00053 catch(Ice::SocketException) 00054 { 00055 port++; 00056 } 00057 } 00058 00059 //Create the manager and its objects 00060 itsMgr = new ModelManager("LocalizationService"); 00061 00062 LINFO("Starting Retina"); 00063 nub::ref<Localization> ret(new Localization(0, *itsMgr)); 00064 LINFO("Localization Created"); 00065 itsMgr->addSubComponent(ret); 00066 LINFO("Localization Added As Sub Component"); 00067 ret->init(communicator(), itsAdapter); 00068 LINFO("Localization Inited"); 00069 00070 itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0); 00071 00072 itsAdapter->activate(); 00073 00074 itsMgr->start(); 00075 00076 return true; 00077 } 00078 00079 // ###################################################################### 00080 00081 int main(int argc, char** argv) { 00082 00083 RobotBrainServiceService svc; 00084 00085 return svc.main(argc, argv); 00086 } 00087 00088