Skip to content

Commit bc6ab9d

Browse files
committed
Merge branch 'outside_duration_threshold' into HEAD
1 parent 8d4ae5b commit bc6ab9d

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

include/spatio_temporal_voxel_layer/spatio_temporal_voxel_grid.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class SpatioTemporalVoxelGrid
129129
SpatioTemporalVoxelGrid(
130130
rclcpp::Clock::SharedPtr clock,
131131
const float & voxel_size, const double & background_value,
132-
const int & decay_model, const double & voxel_decay,
132+
const int & decay_model, const double & min_age_outside_frustum, const double & voxel_decay,
133133
const bool & pub_voxels);
134134
~SpatioTemporalVoxelGrid(void);
135135

@@ -181,7 +181,7 @@ class SpatioTemporalVoxelGrid
181181

182182
mutable openvdb::DoubleGrid::Ptr _grid;
183183
int _decay_model;
184-
double _background_value, _voxel_size, _voxel_decay;
184+
double _background_value, _voxel_size, _min_age_outside_frustum, _voxel_decay;
185185
bool _pub_voxels;
186186
std::unique_ptr<std::vector<geometry_msgs::msg::Point32>> _grid_points;
187187
std::unordered_map<occupany_cell, uint> * _cost_map;

include/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class SpatioTemporalVoxelLayer : public nav2_costmap_2d::CostmapLayer
181181
std::unique_ptr<rclcpp::Duration> _map_save_duration;
182182
rclcpp::Time _last_map_save_time;
183183
std::string _global_frame;
184-
double _voxel_size, _voxel_decay;
184+
double _voxel_size, _min_age_outside_frustum, _voxel_decay;
185185
int _mark_threshold;
186186
nav2_costmap_2d::CombinationMethod _combination_method;
187187
volume_grid::GlobalDecayModel _decay_model;

src/spatio_temporal_voxel_grid.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ namespace volume_grid
4949
SpatioTemporalVoxelGrid::SpatioTemporalVoxelGrid(
5050
rclcpp::Clock::SharedPtr clock,
5151
const float & voxel_size, const double & background_value,
52-
const int & decay_model, const double & voxel_decay, const bool & pub_voxels)
53-
: _clock(clock), _decay_model(decay_model), _background_value(background_value),
52+
const int & decay_model, const double & min_age_outside_frustum,
53+
const double & voxel_decay, const bool & pub_voxels)
54+
: _clock(clock), _decay_model(decay_model), _min_age_outside_frustum(min_age_outside_frustum),
55+
_background_value(background_value),
5456
_voxel_size(voxel_size), _voxel_decay(voxel_decay), _pub_voxels(pub_voxels),
5557
_grid_points(std::make_unique<std::vector<geometry_msgs::msg::Point32>>()),
5658
_cost_map(new std::unordered_map<occupany_cell, uint>)
@@ -199,9 +201,14 @@ void SpatioTemporalVoxelGrid::TemporalClearAndGenerateCostmap(
199201
}
200202
}
201203

202-
// if not inside any, check against nominal decay model
204+
// if not inside any, check against nominal decay model, also clearing if
205+
// too young.
206+
// Depending on min_age_outside_frustum value and cycle frequency,
207+
// a voxel too young means that it was marked without being in a frustrum
208+
// (or, edgy case, the point that marked the voxel was in a frustrum
209+
// but the center of that voxel was not), in that case : clearing
203210
if (!frustum_cycle) {
204-
if (base_duration_to_decay < 0.) {
211+
if (base_duration_to_decay < 0. || time_since_marking < _min_age_outside_frustum) {
205212
// expired by temporal clearing
206213
cleared_point = true;
207214
if (!this->ClearGridPoint(pt_index)) {

src/spatio_temporal_voxel_layer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ void SpatioTemporalVoxelLayer::onInitialize(void)
118118
declareParameter("decay_model", rclcpp::ParameterValue(0));
119119
node->get_parameter(name_ + ".decay_model", decay_model_int);
120120
_decay_model = static_cast<volume_grid::GlobalDecayModel>(decay_model_int);
121+
declareParameter("min_age_outside_frustum", rclcpp::ParameterValue(0.0));
122+
node->get_parameter(name_ + ".min_age_outside_frustum", _min_age_outside_frustum);
121123
// decay param
122124
declareParameter("voxel_decay", rclcpp::ParameterValue(-1.0));
123125
node->get_parameter(name_ + ".voxel_decay", _voxel_decay);
@@ -158,7 +160,7 @@ void SpatioTemporalVoxelLayer::onInitialize(void)
158160

159161
_voxel_grid = std::make_unique<volume_grid::SpatioTemporalVoxelGrid>(
160162
node->get_clock(), _voxel_size, static_cast<double>(default_value_), _decay_model,
161-
_voxel_decay, _publish_voxels);
163+
_min_age_outside_frustum, _voxel_decay, _publish_voxels);
162164

163165
matchSize();
164166

0 commit comments

Comments
 (0)