@@ -193,9 +193,13 @@ bool FullCoveragePathPlanner::parseCostmap(costmap_2d::Costmap2D* costmap_grid_,
193
193
Point_t& scaledStart)
194
194
{
195
195
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 ();
198
200
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);
199
203
200
204
if (nRows == 0 || nCols == 0 )
201
205
{
@@ -225,12 +229,14 @@ bool FullCoveragePathPlanner::parseCostmap(costmap_2d::Costmap2D* costmap_grid_,
225
229
for (ix = 0 ; ix < nCols; ix = ix + nodeSize)
226
230
{
227
231
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)
229
233
{
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)
231
236
{
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;
234
240
if (costmap_grid_->getCost (mx, my) > costmap_2d::INSCRIBED_INFLATED_OBSTACLE)
235
241
{
236
242
nodeOccupied = true ;
0 commit comments