Robot Devastation
RobotDevastation.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __ROBOT_DEVASTATION_HPP__
6 #define __ROBOT_DEVASTATION_HPP__
7 
8 #include <cstdio>
9 #include <string>
10 #include <sstream>
11 #include <iostream>
12 #include <vector>
13 
14 #include <yarp/os/RFModule.h>
15 #include <yarp/os/ResourceFinder.h>
16 
17 #include <yarp/dev/PolyDriver.h>
18 
19 #include "SDLAudioManager.hpp"
20 #include "MentalMap.hpp"
21 #include "InputManager.hpp"
22 #include "SDLInputManager.hpp"
23 #include "InputEventListener.hpp"
24 #include "YarpNetworkManager.hpp"
25 #include "IRobotManager.hpp"
26 #include "StateMachine.hpp"
27 #include "ImageManager.hpp"
28 #include "YarpImageManager.hpp"
29 #include "YarpLocalImageManager.hpp"
30 #include "MockImageManager.hpp"
31 #include "ProcessorImageEventListener.hpp"
32 #include "SDLScreenManager.hpp"
33 
34 //-- Game FSM
35 #include "StateMachine.hpp"
36 #include "StateMachineBuilder.hpp"
37 #include "InitState.hpp"
38 #include "GameState.hpp"
39 #include "DeadState.hpp"
40 
41 namespace rd
42 {
43 
48 class RobotDevastation : public yarp::os::RFModule
49 {
50  public:
52  virtual bool configure(yarp::os::ResourceFinder &rf);
53 
54  private:
55 
56  template<typename T> void getInfoFromUser(const std::string& question, T& info, const bool& no_empty=false)
57  {
58 
59  std::string answer;
60  do {
61  std::printf("%s?>",question.c_str());
62  std::getline(std::cin, answer);
63  } while(no_empty && answer.empty());
64 
65  if (!answer.empty())
66  {
67  std::stringstream ss(answer);
68  ss >> info;
69  }
70  }
71 
72  FiniteStateMachine * gameFSM;
73 
74  InputManager * inputManager;
75  AudioManager * audioManager;
76  MentalMap * mentalMap;
77  NetworkManager * networkManager;
78  asrob::IRobotManager * robotManager;
79  ImageManager * imageManager;
80  ScreenManager * screenManager;
81 
82  yarp::dev::PolyDriver robotDevice;
83 
84  bool interruptModule();
85  double getPeriod();
86  bool updateModule();
87 
88  bool initPlayerInfo(yarp::os::ResourceFinder &rf);
89  bool initSound(yarp::os::ResourceFinder &rf);
90  bool initGameFSM();
91  bool cleanup();
92 
93  //-- Player data
94  int id;
95  std::string name;
96  int team;
97  std::string robotName;
98 };
99 
100 } // namespace rd
101 
102 #endif // __ROBOT_DEVASTATION_HPP__
rd::MentalMap
Mental map is a repository for information about the players, targets and weapons.
Definition: MentalMap.hpp:38
rd::AudioManager
Music and sound effects manager.
Definition: AudioManager.hpp:28
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::FiniteStateMachine
Class implementing a finite state machine.
Definition: StateMachine.hpp:19
rd::RobotDevastation::configure
virtual bool configure(yarp::os::ResourceFinder &rf)
Definition: RobotDevastation.cpp:18
rd::InputManager
User input manager (keyboard, mouse, joysticks, etc)
Definition: InputManager.hpp:35
rd::RobotDevastation
The parent Robot Devastation class of the robotDevastation program.
Definition: RobotDevastation.hpp:48
rd::ScreenManager
Manage game screens.
Definition: ScreenManager.hpp:35
rd::NetworkManager
Manages the communications between the user and the RobotDevastation network.
Definition: NetworkManager.hpp:37
rd::ImageManager
Generic image input manager.
Definition: ImageManager.hpp:39