-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.cpp
144 lines (132 loc) · 4.25 KB
/
config.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include "config.h"
#include <fstream>
#include <sstream>
#include <iostream>
#include <glog/logging.h>
bool UgvParam::loadParam(std::string configFile)
{
std::ifstream in(configFile);
if(!in)
{
DLOG(FATAL) << "Couldn't find configuration file: " << configFile;
return false;
}
std::string line;
std::string key;
double value;
while (getline(in, line)) {
std::stringstream ss;
ss << line;
ss >> key;
if(key[0] == '#')
continue;
ss >> value;
if(key == "EulrChangeThreshold")
DivideCarTrack.EulrChangeThreshold = value;
else if(key == "DetectPoints")
DivideCarTrack.DetectPoints = value;
else if(key == "DetectDistance")
DivideCarTrack.DetectDistance = value;
else if(key == "ValidSegmentPointsNum")
DivideCarTrack.ValidSegmentPointsNum = value;
else if(key == "SimilarEulrThreshold")
LineParallel.SimilarEulrThreshold = value;
else if(key == "LateralDistanceThreshold")
SameSeg.LateralDistanceThreshold = value;
else if(key == "SameDirectionThreshold")
SameSeg.SameDirectionThreshold = value;
else if(key == "xMax")
Scale.xMax = value;
else if(key == "xMin")
Scale.xMin = value;
else if(key == "yMax")
Scale.yMax = value;
else if(key == "yMin")
Scale.yMin = value;
else if(key == "GridSize")
Scale.GridSize = value;
else if(key == "PixelPerGrid")
Scale.PixelPerGrid = value;
else if(key == "LeftDetectAngleBoundary")
ProbMap.LeftDetectAngleBoundary = value;
else if(key == "RightDetectAngleBoundary")
ProbMap.RightDetectAngleBoundary = value;
else if(key == "unitHeight")
ProbMap.unitHeight = value;
else if(key == "OccupiedThreshold")
ProbMap.OccupiedThreshold = value;
else if(key == "ClearThreshold")
ProbMap.ClearThreshold = value;
else if(key == "incrementUnit")
ProbMap.incrementUnit = value;
else if(key == "MaxGroundHeight")
ProbMap.MaxGroundHeight = value;
else if(key == "MaxAvgMidDiff")
ProbMap.MaxAvgMidDiff = value;
else if(key == "SaveNeeded"){
LocalMap.SaveNeeded.insert(value);
while(ss){
ss >> value;
LocalMap.SaveNeeded.insert(value);
}
}
else if(key == "SaveInterval")
LocalMap.SaveInterval = value;
//final case: unknown param:
else{
DLOG(FATAL) << "Error while reading configuration file: " << configFile;
DLOG(FATAL) << "Unknown paramter: " << key <<", value: " << value;
in.close();
return false;
}
update();
}
in.close();
return true;
}
void UgvParam::restoreDefault()
{
//Ugv
Ugv.CorrectionFile = "new_xml.txt";
//DivideCarTrack
DivideCarTrack.EulrChangeThreshold = 0.005;
DivideCarTrack.DetectPoints = 10;
DivideCarTrack.DetectDistance = 5;
DivideCarTrack.ValidSegmentPointsNum = 80;
//LineParallel
LineParallel.SimilarEulrThreshold = 0.01;
//SameSeg
SameSeg.LateralDistanceThreshold = 20;
SameSeg.SameDirectionThreshold = 0.01;
//Scale
Scale.xMax = 5;
Scale.xMin = -5;
Scale.yMax = 10;
Scale.yMin = 0;
Scale.GridSize = 0.08;
Scale.PixelPerGrid = 4;
//ProbMap
ProbMap.LeftDetectAngleBoundary = 34000;
ProbMap.RightDetectAngleBoundary = 2000;
ProbMap.unitHeight = 100;
ProbMap.HeightThreshold = 250;
ProbMap.incrementUnit = 0.05;
ProbMap.ClearThreshold = 0.3;
ProbMap.OccupiedThreshold = 0.7;
ProbMap.MaxGroundHeight = -1600; //-1.6 meters
ProbMap.MaxAvgMidDiff = 0.25;
//LocalMap
LocalMap.SaveInterval = 0;
update();
}
void UgvParam::update()
{
Scale.Width = (Scale.xMax - Scale.xMin)/Scale.GridSize;
Scale.xScale = 1/Scale.GridSize;
Scale.yScale = 1/Scale.GridSize;
//LocalMap
// n times of Scale.Width
LocalMap.initialHeight = 3 * Scale.Width;
LocalMap.initialWidth = 3 * Scale.Width;
LocalMap.ExpandUnit = 3 * (Scale.xMax - Scale.xMin);
}