test-ParticleFilter.C

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