Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measurement buffer does not remove old observations if no observations are retrieved anymore #2

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spatio_temporal_voxel_layer/src/measurement_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void MeasurementBuffer::RemoveStaleObservations(void)
}

for (it = _observation_list.begin(); it != _observation_list.end(); ++it) {
const rclcpp::Duration time_diff = _last_updated - it->_cloud->header.stamp;
const rclcpp::Duration time_diff = clock_->now() - it->_cloud->header.stamp;

if (time_diff > _observation_keep_time) {
_observation_list.erase(it, _observation_list.end());
Expand Down
20 changes: 11 additions & 9 deletions spatio_temporal_voxel_layer/src/spatio_temporal_voxel_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,8 @@ void SpatioTemporalVoxelLayer::reset(void)
current_ = false;
was_reset_ = true;

observation_buffers_iter it = _observation_buffers.begin();
for (; it != _observation_buffers.end(); ++it) {
(*it)->ResetLastUpdatedTime();
}
// @kin-changes (costmap-clearance-issue): Reseting the _last_updated (ResetLastUpdatedTime) of the individual observation buffers was removed,
// since the buffers are not reset in this process either.
}

/*****************************************************************************/
Expand Down Expand Up @@ -675,10 +673,10 @@ void SpatioTemporalVoxelLayer::updateCosts(
return;
}

// if not current due to reset, set current now after clearing
// set was_reset to false again
if (!current_ && was_reset_) {
was_reset_ = false;
current_ = true;
// @kin-changes (costmap-clearance-issue): don't force current_ to be true here
}

if (_update_footprint_enabled) {
Expand Down Expand Up @@ -771,6 +769,13 @@ void SpatioTemporalVoxelLayer::updateBounds(
if (_map_save_duration) {
should_save = node->now() - _last_map_save_time > *_map_save_duration;
}

// mark observations
// @kin-changes (costmap-clearance-issue): this was moved before the call to ClearFrustums, to include the
// new markings within one update cycle
_voxel_grid->Mark(marking_observations);

// save map or clear frustrums and populate costmap
if (!_mapping_mode) {
_voxel_grid->ClearFrustums(clearing_observations, cleared_cells);
} else if (should_save) {
Expand All @@ -790,9 +795,6 @@ void SpatioTemporalVoxelLayer::updateBounds(
SaveGridCallback(nullptr, request, response);
}

// mark observations
_voxel_grid->Mark(marking_observations);

// update the ROS Layered Costmap
UpdateROSCostmap(min_x, min_y, max_x, max_y, cleared_cells);

Expand Down