00001
00002 #include <iostream>
00003
00004
00005 #include <dtGame/gamemanager.h>
00006
00007
00008 #include <controllers/almControllers.h>
00009
00010
00011 #include <controllers/fitnessFramework/evolutionComponent.h>
00012 #include <controllers/fitnessFramework/choreoFitness.h>
00013 #include <controllers/fitnessFramework/almChoreoAgent.h>
00014 #include <controllers/sensorFusion/learningVisionAgent.h>
00015
00016
00017 using namespace std;
00018
00019 using namespace srAlmende;
00020
00021 void AlmendeControllers::addComponent(const char* controllerType, const char* controllerName,
00022 dtGame::GameManager* gameManager, const char* parameters) {
00023
00024 if (strncmp(controllerType, "Almende:Evolution", strlen("Almende:Evolution")) == 0) {
00025 dtCore::RefPtr<srAlmende::EvolutionComponent> evoComp =
00026 new srAlmende::EvolutionComponent("EvolutionComponent", 4444);
00027 cout << "Add the EvolutionComponent '" << evoComp->GetName() << "' to the GameManager" << endl;
00028 gameManager->AddComponent(*evoComp, dtGame::GameManager::ComponentPriority::NORMAL);
00029 }
00030
00031 else if (strncmp(controllerType, "Almende:Fitness:Choreo", strlen("Almende:Fitness:Choreo")) == 0) {
00032 dtCore::RefPtr<srAlmende::ChoreoFitness> fitComp =
00033 new srAlmende::ChoreoFitness("ChoreoFitness");
00034 cout << "Add the FitnessComponent '" << fitComp->GetName() << "' to the GameManager" << endl;
00035 gameManager->AddComponent(*fitComp, dtGame::GameManager::ComponentPriority::NORMAL);
00036 }
00037
00038 }
00039
00040 void AlmendeControllers::addController(const char* controllerType, const char* controllerName,
00041 srCore::RobotActorBase& robotToControl, const char* parameters) {
00042 std::ostringstream msg; msg.clear(); msg.str("");
00043
00044 if (strncmp(controllerType, "Almende:Agent:Choreo", strlen("Almende:Agent:Choreo")) == 0) {
00045
00046 dtCore::RefPtr<AlmChoreoAgent> choreoAgent =
00047 new AlmChoreoAgent(controllerName, &robotToControl);
00048 msg << "Add AlmChoreoAgent " << controllerName << " to the GameManager";
00049 LOG_INFO(msg.str());
00050 robotToControl.GetGameActorProxy().GetGameManager()->AddComponent(*choreoAgent,
00051 dtGame::GameManager::ComponentPriority::NORMAL);
00052 }
00053 else if (strncmp(controllerType, LearningVisionAgent::TYPE.c_str(),
00054 strlen(LearningVisionAgent::TYPE.c_str())) == 0) {
00055
00056 dtCore::RefPtr<LearningVisionAgent> lvAgent =
00057 new LearningVisionAgent(controllerName, &robotToControl);
00058 msg << "Add LearningVisionAgent " << controllerName << " to the GameManager";
00059 LOG_INFO(msg.str());
00060 robotToControl.GetGameActorProxy().GetGameManager()->AddComponent(*lvAgent,
00061 dtGame::GameManager::ComponentPriority::NORMAL);
00062 }
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 }
00073