GridMapSimpleCount.h
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
//=================================================================================================
// Copyright (c) 2011, Stefan Kohlbrecher, TU Darmstadt
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Simulation, Systems Optimization and Robotics
// group, TU Darmstadt nor the names of its contributors may be used to
// endorse or promote products derived from this software without
// specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//=================================================================================================
#ifndef __GridMapSimpleCount_h_
#define __GridMapSimpleCount_h_
/**
* Provides a (very) simple count based representation of occupancy
*/
class SimpleCountCell
{
public:
/**
* Sets the cell value to val.
* @param val The log odds value.
*/
void set(float val)
{
simpleOccVal = val;
}
/**
* Returns the value of the cell.
* @return The log odds value.
*/
float getValue() const
{
return simpleOccVal;
}
/**
* Returns wether the cell is occupied.
* @return Cell is occupied
*/
bool isOccupied() const
{
return (simpleOccVal > 0.5f);
}
bool isFree() const
{
return (simpleOccVal < 0.5f);
}
/**
* Reset Cell to prior probability.
*/
void resetGridCell()
{
simpleOccVal = 0.5f;
updateIndex = -1;
}
//protected:
public:
float simpleOccVal; ///< The log odds representation of occupancy probability.
int updateIndex;
};
/**
* Provides functions related to a log odds of occupancy probability respresentation for cells in a occupancy grid map.
*/
class GridMapSimpleCountFunctions
{
public:
/**
* Constructor, sets parameters like free and occupied log odds ratios.
*/
GridMapSimpleCountFunctions()
{
updateFreeVal = -0.10f;
updateOccVal = 0.15f;
updateFreeLimit = -updateFreeVal + updateFreeVal/100.0f;
updateOccLimit = 1.0f - (updateOccVal + updateOccVal/100.0f);
}
/**
* Update cell as occupied
* @param cell The cell.
*/
void updateSetOccupied(SimpleCountCell& cell) const
{
if (cell.simpleOccVal < updateOccLimit){
cell.simpleOccVal += updateOccVal;
}
}
/**
* Update cell as free
* @param cell The cell.
*/
void updateSetFree(SimpleCountCell& cell) const
{
if (cell.simpleOccVal > updateFreeLimit){
cell.simpleOccVal += updateFreeVal;
}
}
void updateUnsetFree(SimpleCountCell& cell) const
{
cell.simpleOccVal -= updateFreeVal;
}
/**
* Get the probability value represented by the grid cell.
* @param cell The cell.
* @return The probability
*/
float getGridProbability(const SimpleCountCell& cell) const
{
return cell.simpleOccVal;
}
protected:
float updateFreeVal;
float updateOccVal;
float updateFreeLimit;
float updateOccLimit;
};
#endif
| cs |
/**
* Provides a (very) simple count based representation of occupancy
*/
class SimpleCountCell
{
더 간단한 버전의 class라고 한다.
/**
* Sets the cell value to val.
* @param val The log odds value.
*/
void set(float val)
{
simpleOccVal = val;
}
주석 참고
/**
* Returns the value of the cell.
* @return The log odds value.
*/
float getValue() const
{
return simpleOccVal;
}
주석 참고
/**
* Returns wether the cell is occupied.
* @return Cell is occupied
*/
bool isOccupied() const
{
return (simpleOccVal > 0.5f);
}
bool isFree() const
{
return (simpleOccVal < 0.5f);
}
주석 참고
/**
* Reset Cell to prior probability.
*/
void resetGridCell()
{
simpleOccVal = 0.5f;
updateIndex = -1;
}
prior probability 는 사전확률이다. 즉, 초기의 확률로 reset하는 것이다.
//protected:
public:
float simpleOccVal; ///< The log odds representation of occupancy probability.
int updateIndex;
simpleOccVal 이란 값이 log odds 값이라고 강조하고 있다.
log odds ratio에 대해선 다음 내용을 참고하자.
https://m.blog.naver.com/PostView.nhn?blogId=sw4r&logNo=221150181217&proxyReferer=https%3A%2F%2Fwww.google.com%2F
/**
* Provides functions related to a log odds of occupancy probability respresentation for cells in a occupancy grid map.
*/
class GridMapSimpleCountFunctions
{
public:
다시 보니 log odds 사용과는 관계 없어보인다. 주석은 잘 못 써진 것으로 판단된다.
/**
* Constructor, sets parameters like free and occupied log odds ratios.
*/
GridMapSimpleCountFunctions()
{
updateFreeVal = -0.10f;
updateOccVal = 0.15f;
updateFreeLimit = -updateFreeVal + updateFreeVal/100.0f;
updateOccLimit = 1.0f - (updateOccVal + updateOccVal/100.0f);
}
생성자에서 초기 값을 setting 해준다.
모든 값은 0에서 1 사이에서 결정된다.
updateFreeVal의 값은 -0.10f 로 정해줌으로써, 해당 cell이 free하다고 판단되었을 때, 0.10f 값만큼 probability 값에서 빼주는 것이다.
updateOccVal 값은 반대로 0.15f 로 정해줌으로써, 해당 cell이 Occupied 하다고 판단되었을 때, 0.15f 만큼 probability 값에서 더해주는 것이다.
updateFreeLimit 의 경우, 초기의 값을 계산해보면
-(-0.10f)+(-0.10f)/100.0f = 0.099 이다.
updateOccLimit 의 경우, 초기의 값을 계산해보면
1.0f - (0.15f + 0.15f/100.0f) = 0.8485 이다.
log odds ratio와는 관계없이 그냥 일정한 limit을 정해준 것 같다.
기준은 0.099에서 1.0을 또 빼면 -가 되버리니 막아준 것이고,
0.8485는 0.15 가 더해졌을 때, 1이 넘어가버릴수도 있기 때문에 막아준 것으로 보인다.
/**
* Update cell as occupied
* @param cell The cell.
*/
void updateSetOccupied(SimpleCountCell& cell) const
{
if (cell.simpleOccVal < updateOccLimit){
cell.simpleOccVal += updateOccVal;
}
}
cell이 occupied하고 simpleOccVal 의 값이 updateOccLimit의 값보다 작다면 simpleOccval 값에 updateOccVal의 값을 더해준다.
/**
* Update cell as free
* @param cell The cell.
*/
void updateSetFree(SimpleCountCell& cell) const
{
if (cell.simpleOccVal > updateFreeLimit){
cell.simpleOccVal += updateFreeVal;
}
}
반대로 cell이 free하고 updateFreeLimit 보다 클 때, simpleOccVal에 updateFreeVal를 더해준다.
void updateUnsetFree(SimpleCountCell& cell) const
{
cell.simpleOccVal -= updateFreeVal;
}
이 함수 역시 어떤 상황에 쓰이는지 의문이다.
float getGridProbability(const SimpleCountCell& cell) const
{
return cell.simpleOccVal;
}
SimpleOccVal 의 값을 가져온다.
댓글 없음:
댓글 쓰기