Skip to content

Commit e5a8965

Browse files
committed
Let parse costmap function consider robot radius
1 parent f694051 commit e5a8965

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/full_coverage_path_planner.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,13 @@ bool FullCoveragePathPlanner::parseCostmap(costmap_2d::Costmap2D* costmap_grid_,
193193
Point_t& scaledStart)
194194
{
195195
int ix, iy, nodeRow, nodeCol;
196-
uint32_t nodeSize = dmax(floor(toolRadius / costmap_grid_->getResolution()), 1); // Size of node in pixels/units
197-
uint32_t nRows = costmap_grid_->getSizeInCellsY(), nCols = costmap_grid_->getSizeInCellsX();
196+
int nodeSize = dmax(floor(toolRadius / costmap_grid_->getResolution()), 1); // Size of node in pixels/units
197+
int robotNodeSize = dmax(floor(robotRadius / costmap_grid_->getResolution()), 1); // RobotRadius in pixels/units
198+
int nodePaddingSize = dmax(ceil(static_cast<float>(robotNodeSize - nodeSize) / 2.0), 0);
199+
int nRows = costmap_grid_->getSizeInCellsY(), nCols = costmap_grid_->getSizeInCellsX();
198200
ROS_INFO("nRows: %u nCols: %u nodeSize: %d", nRows, nCols, nodeSize);
201+
ROS_INFO("parseCostmap -> robotNodeSize: %u nodePaddingSize: %u", robotNodeSize, nodePaddingSize);
202+
ROS_INFO("parseCostmap -> robotRadius: %f toolRadius: %f", robotRadius, toolRadius);
199203

200204
if (nRows == 0 || nCols == 0)
201205
{
@@ -225,12 +229,14 @@ bool FullCoveragePathPlanner::parseCostmap(costmap_2d::Costmap2D* costmap_grid_,
225229
for (ix = 0; ix < nCols; ix = ix + nodeSize)
226230
{
227231
bool nodeOccupied = false;
228-
for (nodeRow = 0; (nodeRow < nodeSize) && ((iy + nodeRow) < nRows) && (nodeOccupied == false); ++nodeRow)
232+
for (nodeRow = 0; (nodeRow < robotNodeSize) && ((iy - nodePaddingSize + nodeRow) < nRows) && (nodeOccupied == false); ++nodeRow)
229233
{
230-
for (nodeCol = 0; (nodeCol < nodeSize) && ((ix + nodeCol) < nCols); ++nodeCol)
234+
if ((iy - nodePaddingSize + nodeRow) < 0) {continue;}
235+
for (nodeCol = 0; (nodeCol < robotNodeSize) && ((ix - nodePaddingSize + nodeCol) < nCols); ++nodeCol)
231236
{
232-
double mx = ix + nodeCol;
233-
double my = iy + nodeRow;
237+
if ((ix - nodePaddingSize + nodeCol) < 0) {continue;}
238+
double mx = ix - nodePaddingSize + nodeCol;
239+
double my = iy - nodePaddingSize + nodeRow;
234240
if (costmap_grid_->getCost(mx, my) > costmap_2d::INSCRIBED_INFLATED_OBSTACLE)
235241
{
236242
nodeOccupied = true;

0 commit comments

Comments
 (0)