@@ -94,7 +94,8 @@ void SpatioTemporalVoxelGrid::InitializeGrid(void)
94
94
95
95
/* ****************************************************************************/
96
96
void SpatioTemporalVoxelGrid::ClearFrustums (
97
- const std::vector<observation::MeasurementReading> & clearing_readings)
97
+ const std::vector<observation::MeasurementReading> & clearing_readings,
98
+ std::unordered_set<occupany_cell> & cleared_cells)
98
99
/* ****************************************************************************/
99
100
{
100
101
boost::unique_lock<boost::mutex> lock (_grid_lock);
@@ -110,7 +111,7 @@ void SpatioTemporalVoxelGrid::ClearFrustums(
110
111
std::vector<frustum_model> obs_frustums;
111
112
112
113
if (clearing_readings.size () == 0 ) {
113
- TemporalClearAndGenerateCostmap (obs_frustums);
114
+ TemporalClearAndGenerateCostmap (obs_frustums, cleared_cells );
114
115
return ;
115
116
}
116
117
@@ -139,12 +140,13 @@ void SpatioTemporalVoxelGrid::ClearFrustums(
139
140
frustum->TransformModel ();
140
141
obs_frustums.emplace_back (frustum, it->_decay_acceleration );
141
142
}
142
- TemporalClearAndGenerateCostmap (obs_frustums);
143
+ TemporalClearAndGenerateCostmap (obs_frustums, cleared_cells );
143
144
}
144
145
145
146
/* ****************************************************************************/
146
147
void SpatioTemporalVoxelGrid::TemporalClearAndGenerateCostmap (
147
- std::vector<frustum_model> & frustums)
148
+ std::vector<frustum_model> & frustums,
149
+ std::unordered_set<occupany_cell> & cleared_cells)
148
150
/* ****************************************************************************/
149
151
{
150
152
// sample time once for all clearing readings
@@ -154,9 +156,11 @@ void SpatioTemporalVoxelGrid::TemporalClearAndGenerateCostmap(
154
156
openvdb::DoubleGrid::ValueOnCIter cit_grid = _grid->cbeginValueOn ();
155
157
for (; cit_grid.test (); ++cit_grid) {
156
158
const openvdb::Coord pt_index (cit_grid.getCoord ());
159
+ const openvdb::Vec3d pose_world = this ->IndexToWorld (pt_index);
157
160
158
161
std::vector<frustum_model>::iterator frustum_it = frustums.begin ();
159
162
bool frustum_cycle = false ;
163
+ bool cleared_point = false ;
160
164
161
165
const double time_since_marking = cur_time - cit_grid.getValue ();
162
166
const double base_duration_to_decay = GetTemporalClearingDuration (
@@ -167,7 +171,7 @@ void SpatioTemporalVoxelGrid::TemporalClearAndGenerateCostmap(
167
171
continue ;
168
172
}
169
173
170
- if (frustum_it->frustum ->IsInside (this -> IndexToWorld (pt_index) ) ) {
174
+ if (frustum_it->frustum ->IsInside (pose_world ) ) {
171
175
frustum_cycle = true ;
172
176
173
177
const double frustum_acceleration = GetFrustumAcceleration (
@@ -177,9 +181,11 @@ void SpatioTemporalVoxelGrid::TemporalClearAndGenerateCostmap(
177
181
frustum_acceleration;
178
182
if (time_until_decay < 0 .) {
179
183
// expired by acceleration
184
+ cleared_point = true ;
180
185
if (!this ->ClearGridPoint (pt_index)) {
181
186
std::cout << " Failed to clear point." << std::endl;
182
187
}
188
+ break ;
183
189
} else {
184
190
const double updated_mark = cit_grid.getValue () -
185
191
frustum_acceleration;
@@ -195,14 +201,22 @@ void SpatioTemporalVoxelGrid::TemporalClearAndGenerateCostmap(
195
201
if (!frustum_cycle) {
196
202
if (base_duration_to_decay < 0 .) {
197
203
// expired by temporal clearing
204
+ cleared_point = true ;
198
205
if (!this ->ClearGridPoint (pt_index)) {
199
206
std::cout << " Failed to clear point." << std::endl;
200
207
}
201
- continue ;
202
208
}
203
209
}
204
- // if here, we can add to costmap and PC2
205
- PopulateCostmapAndPointcloud (pt_index);
210
+
211
+ if (cleared_point)
212
+ {
213
+ cleared_cells.insert (occupany_cell (pose_world[0 ], pose_world[1 ]));
214
+ }
215
+ else
216
+ {
217
+ // if here, we can add to costmap and PC2
218
+ PopulateCostmapAndPointcloud (pt_index);
219
+ }
206
220
}
207
221
}
208
222
0 commit comments