Skip to content
Merged
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
10 changes: 10 additions & 0 deletions nav2_smac_planner/include/nav2_smac_planner/collision_checker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ class GridCollisionChecker
return angles_;
}

private:
/**
* @brief Check if value outside the range
* @param min Minimum value of the range
* @param max Maximum value of the range
* @param value the value to check if it is within the range
* @return boolean if in range or not
*/
bool outsideRange(const unsigned int & max, const float & value);

protected:
std::vector<nav2_costmap_2d::Footprint> oriented_footprints_;
nav2_costmap_2d::Footprint unoriented_footprint_;
Expand Down
12 changes: 12 additions & 0 deletions nav2_smac_planner/src/collision_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ bool GridCollisionChecker::inCollision(
const float & angle_bin,
const bool & traverse_unknown)
{
// Check to make sure cell is inside the map
if (outsideRange(costmap_->getSizeInCellsX(), x) ||
outsideRange(costmap_->getSizeInCellsY(), y))
{
return false;
}

// Assumes setFootprint already set
double wx, wy;
costmap_->mapToWorld(static_cast<double>(x), static_cast<double>(y), wx, wy);
Expand Down Expand Up @@ -164,4 +171,9 @@ float GridCollisionChecker::getCost()
return static_cast<float>(footprint_cost_);
}

bool GridCollisionChecker::outsideRange(const unsigned int & max, const float & value)
{
return value < 0.0f || value > max;
}

} // namespace nav2_smac_planner