RobotBrainService.C
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "Component/ModelManager.H"
00039 #include "Component/ModelComponent.H"
00040 #include "Component/ModelOptionDef.H"
00041 #include "Robots/RobotBrain/PrimaryMotorCortexI.H"
00042 #include "Robots/RobotBrain/HippocampusI.H"
00043 #include "Robots/RobotBrain/PrimarySomatosensoryCortexI.H"
00044 #include "Robots/RobotBrain/SupplementaryMotorAreaI.H"
00045 #include "Robots/RobotBrain/InferotemporalCortexI.H"
00046 #include "Robots/RobotBrain/PrefrontalCortexI.H"
00047 #include "Robots/RobotBrain/LateralGeniculateNucleusI.H"
00048 #include <Ice/Ice.h>
00049 #include <Ice/Service.h>
00050 #include "Ice/RobotSimEvents.ice.H"
00051 #include "Ice/RobotBrainObjects.ice.H"
00052 #include "Ice/SimEventsUtils.H"
00053 #include "Ice/IceImageUtils.H"
00054
00055
00056 class RobotBrainServiceService : public Ice::Service {
00057 protected:
00058 virtual bool start(int, char* argv[]);
00059 virtual bool stop() {
00060 if (itsMgr)
00061 delete itsMgr;
00062 return true;
00063 }
00064
00065 private:
00066 Ice::ObjectAdapterPtr itsAdapter;
00067 ModelManager *itsMgr;
00068 };
00069
00070 bool RobotBrainServiceService::start(int argc, char* argv[])
00071 {
00072 char adapterStr[255];
00073
00074
00075 SimEventsUtils::createTopic(communicator(), "ActionMessageTopic");
00076 SimEventsUtils::createTopic(communicator(), "GPSMessageTopic");
00077 SimEventsUtils::createTopic(communicator(), "MotionMessageTopic");
00078 SimEventsUtils::createTopic(communicator(), "GoalStateMessageTopic");
00079 SimEventsUtils::createTopic(communicator(), "GoalProgressMessageTopic");
00080 SimEventsUtils::createTopic(communicator(), "AttendedRegionMessageTopic");
00081 SimEventsUtils::createTopic(communicator(), "ObjectMessageTopic");
00082 SimEventsUtils::createTopic(communicator(), "LandmarksMessageTopic");
00083
00084
00085 sprintf(adapterStr, "default -p %i", RobotBrainObjects::RobotBrainPort);
00086 itsAdapter = communicator()->createObjectAdapterWithEndpoints("RobotBrainPort",
00087 adapterStr);
00088
00089
00090 itsMgr = new ModelManager("RobotBrainService");
00091
00092 LINFO("PMC");
00093 nub::ref<PrimaryMotorCortexI> pmc(new PrimaryMotorCortexI(*itsMgr));
00094 itsMgr->addSubComponent(pmc);
00095 pmc->init(communicator(), itsAdapter);
00096
00097 LINFO("PSC");
00098 nub::ref<PrimarySomatosensoryCortexI> psc(new PrimarySomatosensoryCortexI(*itsMgr));
00099 itsMgr->addSubComponent(psc);
00100 psc->init(communicator(), itsAdapter);
00101
00102 LINFO("LGN");
00103 nub::ref<LateralGeniculateNucleusI> lgn(new LateralGeniculateNucleusI(*itsMgr));
00104 itsMgr->addSubComponent(lgn);
00105 lgn->init(communicator(), itsAdapter);
00106
00107 LINFO("Hipp");
00108 nub::ref<HippocampusI> hipp(new HippocampusI(*itsMgr));
00109 itsMgr->addSubComponent(hipp);
00110 hipp->init(communicator(), itsAdapter);
00111
00112
00113
00114
00115
00116
00117 LINFO("IT");
00118 nub::ref<InferotemporalCortexI> itc(new InferotemporalCortexI(*itsMgr));
00119 itsMgr->addSubComponent(itc);
00120 itc->init(communicator(), itsAdapter);
00121
00122
00123 LINFO("PFC");
00124 nub::ref<PrefrontalCortexI> pfc(new PrefrontalCortexI(*itsMgr));
00125 itsMgr->addSubComponent(pfc);
00126 pfc->init(communicator(), itsAdapter);
00127
00128 itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0);
00129
00130
00131 itsAdapter->activate();
00132
00133 itsMgr->start();
00134
00135 return true;
00136 }
00137
00138
00139 int main(int argc, char** argv) {
00140
00141 RobotBrainServiceService svc;
00142 return svc.main(argc, argv);
00143 }
00144
00145