generated from MaracatronicsRobotics/Armorial-PSEL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
79 lines (66 loc) · 2.65 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/***
* Maracatronics Robotics
* Federal University of Pernambuco (UFPE) at Recife
* http://www.maracatronics.com/
*
* This file is part of Armorial project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include <QCoreApplication>
#include <src/entities/player/player.h>
#include <src/entities/vision/vision.h>
#include <src/entities/worldmap/worldmap.h>
#include <src/entities/actuator/actuator.h>
#include <src/entities/coach/coach.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// Create Vision module
Vision *vision = new Vision();
// Create actuator module and connect it with the Vision to receive the host address
Actuator* actuator = new Actuator();
QObject::connect(vision, &Vision::sendHostAddress, actuator, &Actuator::connectToNetwork);
// Create WorldMap instance and connect it with the Vision module to receive detection packets
// from ball and field.
WorldMap *worldMap = new WorldMap(false);
QObject::connect(vision, &Vision::sendFieldDetection, worldMap, &WorldMap::updateFieldDetection);
QObject::connect(vision, &Vision::sendBallDetection, worldMap, &WorldMap::updateBallDetection);
// Create Player pointers
QMap<bool, QList<Player*>> _players;
for(int i = 0; i <= 1; i++) {
_players.insert(i, QList<Player*>());
for(int j = 0; j < 3; j++) {
_players[i].push_back(new Player(i, j));
QObject::connect(vision, &Vision::sendRobotDetection, _players[i][j], &Player::updateFromDetection);
QObject::connect(_players[i][j], &Player::sendControlPacket, actuator, &Actuator::receiveControlPacket);
}
}
// Create Coach module instance and allocate players and worldmap to it.
Coach* coach = new Coach(_players, worldMap);
// Hold exec
bool exec = a.exec();
// Delete pointers
delete coach;
delete worldMap;
for (auto& team : _players) {
for (auto& player : team) {
delete player;
}
team.clear();
}
delete actuator;
delete vision;
return exec;
}