-
Notifications
You must be signed in to change notification settings - Fork 6
/
mission.cpp
90 lines (77 loc) · 2.17 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
84
85
86
87
88
89
#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::getLocalMap()
{
return localmap.GetLocalMap(map, map.start, config.SearchParams[CN_SP_RA]);
}
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::createEnvironmentOptions()
{
options = EnvironmentOptions(config.SearchParams[CN_SP_AS], config.SearchParams[CN_SP_AD],
config.SearchParams[CN_SP_CC], config.SearchParams[CN_SP_MT],
config.SearchParams[CN_SP_JU]);
//map.algorithm_info = options;
}
void Mission::createSearch()
{
dlitesearch = Dlite(config.SearchParams[CN_SP_RA], config.SearchParams[CN_SP_HW]);
}
void Mission::startSearch()
{
sr = dlitesearch.FindThePath(localmap, map, options);
}
void Mission::printSearchResultsToConsole()
{
std::cout << "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.CellSize << std::endl;
}
std::cout << "time=" << sr.time << std::endl;
}
void Mission::saveSearchResultsToLog()
{
logger->writeToLogSummary(sr.numberofsteps, sr.nodescreated, sr.pathlength, sr.time, map.CellSize);
if (sr.pathfound) {
logger->writeToLogPath(*sr.lppath);
logger->writeToLogHPpath(*sr.hppath);
logger->writeToLogMap(localmap, *sr.lppath, true);
} else {
logger->writeToLogNotFound();
}
logger->saveLog();
}