Skip to content

Commit

Permalink
Return if range it too small
Browse files Browse the repository at this point in the history
CppStyleGuide
  • Loading branch information
Arjanboeve committed Jun 21, 2021
1 parent cf7af51 commit 7330a13
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/speckle_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ bool LaserScanSpeckleFilter::update(const sensor_msgs::LaserScan& input_scan, se
output_scan = input_scan;
std::vector<bool> valid_ranges(output_scan.ranges.size(), false);

/*Check if range size is big enough to set the window */
size_t maxIdx = output_scan.ranges.size();
if(maxIdx > config_.filter_window && config_.filter_window > 0) maxIdx -= (config_.filter_window-1);
/*Check if range size is big enough to use the filter window */
if(output_scan.ranges.size() <= config_.filter_window +1)
{
ROS_ERROR("Scanner range size is too small: size = %i", output_scan.ranges.size());
return false;
}

for (size_t idx = 0; idx < maxIdx; ++idx)
for (size_t idx = 0; idx < output_scan.ranges.size() - config_.filter_window + 1; ++idx)
{
bool window_valid = validator_->checkWindowValid(
output_scan, idx, config_.filter_window, config_.max_range_difference);
Expand Down

0 comments on commit 7330a13

Please sign in to comment.