MRXT: The Multi-Robot eXploration Tool
Multi-Robot autonomous exploration and mapping simulator.
src/architecture/basics/explorer.cpp
00001 
00002 #include "explorer.h"
00003 
00004 #include "reactiveGauss.h"
00005 
00006 #include "HybridPlanner.h"
00007 #include "FrontierGreedyPlanner.h"
00008 #include "FSAPlanner.h"
00009 #include "CoordinatedPlanner.h"
00010 #include "IGPlanner.h"
00011 #include "MarketPlanner.h"
00012 #include "IntegratedIGPlanner.h"
00013 
00014 // Para registrar la clase en la factoria
00015 namespace robots{
00016         robot* CreateExplorer(int num, slamInterface& sp, worldModelInterface& s, const ConfigFile& conf){
00017                 return new explorer(num, sp, s, conf);
00018         };
00019         const bool registered = robotFactory::Instance().Register(EXPLORER, robotCreator(CreateExplorer));
00020 }
00021 
00022 // constructor
00023 explorer::explorer():
00024         plantype(0),
00025         reactype(0)
00026 {
00027         printf("[EXPLORER] Explorer Robot created\n");
00028 }
00029 
00030 // constructor
00031 explorer::explorer(int num, slamInterface& sp, worldModelInterface& s, const ConfigFile& conf):
00032         robot(num, sp,s,conf),
00033         plantype(conf.read<int>("PLANNER")),
00034         reactype(conf.read<int>("REACTIVE"))
00035 {
00036         printf("[EXPLORER] Explorer Robot created\n");  
00037 }
00038 
00039 // destructor
00040 explorer::~explorer(){
00041 //      printf("[EXPLORER] Explorer destroyer...\n");
00042         printf("[EXPLORER] Explorer finished\n");
00043 }
00044 
00045 // initializer
00046 void explorer::initialize(int num, slamInterface& sp, worldModelInterface& s, const ConfigFile& conf){
00047         robot::initialize(num,sp,s,conf);
00048         plantype = config->read<int>("PLANNER");
00049         reactype = config->read<int>("REACTIVE");
00050 }
00051 
00052 
00053 // initiates the exploration
00054 // this method acts as a factory for planner and reactive layers
00055 // TODO: use default factory
00056 void explorer::start(){
00057 
00058         reac = reactiveFactory::Instance().CreateObject(reactype,*config);
00059 
00060         reac->setRobot(number);
00061         reac->setRBase(*rbase);
00062         reac->setSlam(*mySlam);
00063 
00064         plan = plannerFactory::Instance().CreateObject(plantype,*config);
00065 
00066         if (strlog) plan->setLogName(strlog);
00067         plan->setRobot(number);
00068         plan->setRBase(*rbase);
00069         plan->setReactive(*reac);
00070         plan->setSlam(*mySlam);
00071 
00072         plan->run();
00073         reac->run();
00074 
00075 }
00076 
00077 // stops the exploration
00078 void explorer::stop(){
00079 //      printf("[EXPLORER] stoping...\n");
00080         if (plan) plan->stop();
00081         if (reac) reac->stop();
00082 //      printf("[EXPLORER] stoped\n");
00083 }
00084 
00085 
00086 
 All Classes Functions Variables Typedefs