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
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
00054 itsMgr = new ModelManager("ParticleFilterService");
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 LINFO("Starting ParticleFilter");
00066 nub::ref<ParticleFilter> bbc(new ParticleFilter(0, *itsMgr, NULL ,
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