Skip to content

Commit 0a32f24

Browse files
author
Guillaume
committed
add outside duration threshold
1 parent 14e7f5e commit 0a32f24

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

cfg/SpatioTemporalVoxelLayer.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ gen.add("mark_threshold", double_t, 0, "Over this threshold, the measurement wil
2222
gen.add("update_footprint_enabled", bool_t, 0, "Cleans where the robot's footprint is", True)
2323
gen.add("track_unknown_space", bool_t, 1, "If true, marks will be UNKNOWN (255) otherwise, FREE (0)", True)
2424
gen.add("decay_model", int_t, 1, "Decay models", 0, edit_method=decay_model_enum)
25+
gen.add("outside_duration_threshold", double_t, 1, "Seconds", 0.0, 0.0, 1.0)
2526
gen.add("voxel_decay", double_t, 1, "Seconds if linear, e^n if exponential", 10.0, -1, 200.0)
2627
gen.add("mapping_mode", bool_t, 0, "Mapping mode", False)
2728
gen.add("map_save_duration", double_t, 0, "f mapping, how often to save a map for safety", 60.0, 1.0, 2000.0)

include/spatio_temporal_voxel_layer/spatio_temporal_voxel_grid.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class SpatioTemporalVoxelGrid
124124
typedef openvdb::math::Ray<openvdb::Real>::Vec3T Vec3Type;
125125

126126
SpatioTemporalVoxelGrid(const float& voxel_size, const double& background_value,
127-
const int& decay_model, const double& voxel_decay,
127+
const int& decay_model, const double& outside_duration_threshold, const double& voxel_decay,
128128
const bool& pub_voxels);
129129
~SpatioTemporalVoxelGrid(void);
130130

@@ -169,7 +169,7 @@ class SpatioTemporalVoxelGrid
169169

170170
mutable openvdb::DoubleGrid::Ptr _grid;
171171
int _decay_model;
172-
double _background_value, _voxel_size, _voxel_decay;
172+
double _background_value, _voxel_size, _outside_duration_threshold, _voxel_decay;
173173
bool _pub_voxels;
174174
std::vector<geometry_msgs::Point32>* _grid_points;
175175
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
@@ -161,7 +161,7 @@ class SpatioTemporalVoxelLayer : public costmap_2d::CostmapLayer
161161
ros::Duration _map_save_duration;
162162
ros::Time _last_map_save_time;
163163
std::string _global_frame;
164-
double _voxel_size, _voxel_decay;
164+
double _voxel_size, _outside_duration_threshold, _voxel_decay;
165165
int _combination_method, _mark_threshold;
166166
volume_grid::GlobalDecayModel _decay_model;
167167
bool _update_footprint_enabled, _enabled;

src/spatio_temporal_voxel_grid.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ namespace volume_grid
4343
/*****************************************************************************/
4444
SpatioTemporalVoxelGrid::SpatioTemporalVoxelGrid(const float& voxel_size, \
4545
const double& background_value, const int& decay_model,\
46+
const double& outside_duration_threshold, \
4647
const double& voxel_decay, const bool& pub_voxels) :
4748
_background_value(background_value), \
4849
_voxel_size(voxel_size), \
4950
_decay_model(decay_model), \
51+
_outside_duration_threshold(outside_duration_threshold), \
5052
_voxel_decay(voxel_decay), \
5153
_pub_voxels(pub_voxels), \
5254
_grid_points(new std::vector<geometry_msgs::Point32>), \
@@ -168,6 +170,8 @@ void SpatioTemporalVoxelGrid::TemporalClearAndGenerateCostmap( \
168170
// sample time once for all clearing readings
169171
const double cur_time = ros::WallTime::now().toSec();
170172

173+
174+
171175
// check each point in the grid for inclusion in a frustum
172176
openvdb::DoubleGrid::ValueOnCIter cit_grid = _grid->cbeginValueOn();
173177
for (cit_grid; cit_grid.test(); ++cit_grid)
@@ -218,10 +222,13 @@ void SpatioTemporalVoxelGrid::TemporalClearAndGenerateCostmap( \
218222
}
219223
}
220224

221-
// if not inside any, check against nominal decay model
225+
// if not inside any, check against nominal decay model, also if
226+
// too young, it means that it was marked without being in a frustrum
227+
// (or, edgy case, the point that marked the voxel was in a frustrum
228+
// but the center of that voxel was not), in that case : clearing
222229
if(!frustum_cycle)
223230
{
224-
if (base_duration_to_decay < 0.)
231+
if (base_duration_to_decay < 0. || time_since_marking < _outside_duration_threshold)
225232
{
226233
// expired by temporal clearing
227234
if(!this->ClearGridPoint(pt_index))

src/spatio_temporal_voxel_layer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ void SpatioTemporalVoxelLayer::onInitialize(void)
9999
layered_costmap_->isTrackingUnknown());
100100
nh.param("decay_model", decay_model_int, 0);
101101
_decay_model = static_cast<volume_grid::GlobalDecayModel>(decay_model_int);
102+
// outside_duration_threshold param
103+
nh.param("outside_duration_threshold", _outside_duration_threshold, 0.05);
102104
// decay param
103105
nh.param("voxel_decay", _voxel_decay, -1.);
104106
// whether to map or navigate
@@ -130,6 +132,7 @@ void SpatioTemporalVoxelLayer::onInitialize(void)
130132
_voxel_grid = new volume_grid::SpatioTemporalVoxelGrid(_voxel_size, \
131133
(double)default_value_, \
132134
_decay_model, \
135+
_outside_duration_threshold, \
133136
_voxel_decay, \
134137
_publish_voxels);
135138
matchSize();
@@ -620,14 +623,15 @@ void SpatioTemporalVoxelLayer::DynamicReconfigureCallback( \
620623
costmap_2d::NO_INFORMATION : costmap_2d::FREE_SPACE;
621624
default_value_ = default_value;
622625
_voxel_size = config.voxel_size;
626+
_outside_duration_threshold = config.outside_duration_threshold;
623627
_voxel_decay = config.voxel_decay;
624628
_decay_model = static_cast<volume_grid::GlobalDecayModel>(config.decay_model);
625629
_publish_voxels = config.publish_voxel_map;
626630

627631
delete _voxel_grid;
628632
_voxel_grid = new volume_grid::SpatioTemporalVoxelGrid(_voxel_size, \
629633
static_cast<double>(default_value_), _decay_model, \
630-
_voxel_decay, _publish_voxels);
634+
_outside_duration_threshold, _voxel_decay, _publish_voxels);
631635
}
632636
}
633637

0 commit comments

Comments
 (0)