-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmission.cpp
83 lines (71 loc) · 2.01 KB
/
mission.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
80
81
82
83
#include "mission.h"
#include "xmllogger.h"
#include "gl_const.h"
Mission::Mission()
{
logger = nullptr;
fileName = nullptr;
}
Mission::Mission(const char *FileName)
{
fileName = FileName;
logger = nullptr;
}
Mission::~Mission()
{
if (logger)
delete logger;
}
bool Mission::getMap()
{
return map.GetMap(fileName);
}
bool Mission::getConfig()
{
return config.getConfig(fileName);
}
bool Mission::createLog()
{
if (logger != NULL) delete logger;
logger = new XmlLogger(config.LogParams[CN_LP_LEVEL]);
return logger->getLog(fileName, config.LogParams);
}
void Mission::createSearch()
{
dliansearch = LPLian((double)config.SearchParams[CN_SP_AL], (int)config.SearchParams[CN_SP_DI], (float)config.SearchParams[CN_SP_HW],
(bool)config.SearchParams[CN_SP_PS], (double)config.SearchParams[CN_SP_OP]);
}
void Mission::startSearch()
{
sr = dliansearch.FindThePath(map);
if (sr.pathfound) {
std::cout << "DLIAN has found the path\n";
}
}
void Mission::printSearchResultsToConsole()
{
std::cout << "LPLian path ";
if (!sr.pathfound)
std::cout << "NOT ";
std::cout << "found!" << std::endl;
std::cout << "numberofsteps: " << sr.numberofsteps << std::endl;
std::cout << "nodescreated: " << sr.nodescreated << std::endl;
if (sr.pathfound) {
std::cout << "pathlength: " << sr.pathlength << std::endl;
std::cout << "pathlength_scaled: " << sr.pathlength * map.get_cellsize() << std::endl;
}
std::cout << "time: " << sr.time << std::endl;
}
void Mission::saveSearchResultsToLog()
{
logger->writeToLogSummary(sr.numberofsteps, sr.nodescreated, sr.pathlength, sr.time, sr.max_angle, map.get_cellsize());
if (sr.pathfound) {
logger->writeToLogPath(sr.lppath);
logger->writeToLogHPpath(sr.hppath);
logger->writeToLogMap(map, sr.lppath, true);
} else {
logger->writeToLogMap(map, sr.lppath, false);
logger->writeToLogNotFound();
}
logger->saveLog();
}