-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
43 lines (35 loc) · 1010 Bytes
/
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
#include <HamsterAPIClientCPP/Hamster.h>
#include <iostream>
#include "Robot.h"
#include "LocalizationManager.h"
#include "Map.h"
using namespace std;
using namespace HamsterAPI;
HamsterAPI::Hamster * hamster;
int main() {
try {
hamster = new HamsterAPI::Hamster(1);
sleep(3);
Robot robot(hamster);
OccupancyGrid ogrid = hamster->getSLAMMap();
Map map(ogrid);
map.initMap();
LocalizationManager locManager(ogrid, hamster);
locManager.initParticles();
while (hamster->isConnected()) {
try {
map.showMap();
robot.robotMovement();
robot.updatePose();
locManager.updateParticles(robot.getDeltaX(), robot.getDeltaY(), robot.getDeltaYaw());
map.drawParticles(locManager.getParticles());
sleep(0.5);
} catch (const HamsterAPI::HamsterError & message_error) {
HamsterAPI::Log::i("Client", message_error.what());
}
}
} catch (const HamsterAPI::HamsterError & connection_error) {
HamsterAPI::Log::i("Client", connection_error.what());
}
return 0;
}