test-BasicVisionBrainComponent.C

00001 
00002 #include "Component/ModelManager.H"
00003 #include "Component/ModelComponent.H"
00004 #include "Component/ModelOptionDef.H"
00005 #include "Robots/SeaBeeIII/BasicVisionBrainComponentI.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 
00014 class RobotBrainServiceService : public Ice::Service {
00015 protected:
00016   virtual bool start(int, char* argv[]);
00017   virtual bool stop() {
00018     if (itsMgr)
00019       delete itsMgr;
00020     return true;
00021   }
00022 
00023 private:
00024   Ice::ObjectAdapterPtr itsAdapter;
00025   ModelManager *itsMgr;
00026 };
00027 
00028 bool RobotBrainServiceService::start(int argc, char* argv[])
00029 {
00030   char adapterStr[255];
00031 
00032 LINFO("Starting XBox Controller...");
00033   //Create the topics
00034  // SimEventsUtils::createTopic(communicator(), "BasicVisionBrainComponentMessageTopic");
00035 
00036   //Create the adapter
00037   int port = RobotBrainObjects::RobotBrainPort;
00038   bool connected = false;
00039 
00040   while(!connected)
00041     {
00042       try
00043         {
00044           LINFO("Trying Port:%d", port);
00045           sprintf(adapterStr, "default -p %i", port);
00046           itsAdapter = communicator()->createObjectAdapterWithEndpoints("BasicVisionBrainComponent",
00047                                                                         adapterStr);
00048           connected = true;
00049         }
00050       catch(Ice::SocketException)
00051         {
00052           port++;
00053         }
00054     }
00055 
00056   //Create the manager and its objects
00057   itsMgr = new ModelManager("BasicVisionBrainComponentService");
00058 
00059   LINFO("Starting BasicVisionBrainComponent");
00060   nub::ref<BasicVisionBrainComponentI> ret(new BasicVisionBrainComponentI(0, *itsMgr, "BasicVisionBrainComponent1", "BasicVisionBrainComponent2"));
00061   LINFO("BasicVisionBrainComponent Created");
00062   itsMgr->addSubComponent(ret);
00063   LINFO("BasicVisionBrainComponent Added As Sub Component");
00064   ret->init(communicator(), itsAdapter);
00065   LINFO("BasicVisionBrainComponent Inited");
00066 
00067   itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0);
00068 
00069   itsAdapter->activate();
00070 
00071   itsMgr->start();
00072 
00073   return true;
00074 }
00075 
00076 // ######################################################################
00077 int main(int argc, char** argv) {
00078 
00079   RobotBrainServiceService svc;
00080   return svc.main(argc, argv);
00081 }
00082 
00083 
Generated on Sun May 8 08:42:07 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3