| 442 | } |
| 443 | |
| 444 | void CostmapInterface::ClearLayer(CostmapLayer *costmap_layer_ptr, double pose_x, double pose_y) { |
| 445 | std::unique_lock<Costmap2D::mutex_t> lock(*(costmap_layer_ptr->GetMutex())); |
| 446 | double reset_distance = 0.1; |
| 447 | double start_point_x = pose_x - reset_distance / 2; |
| 448 | double start_point_y = pose_y - reset_distance / 2; |
| 449 | double end_point_x = start_point_x + reset_distance; |
| 450 | double end_point_y = start_point_y + reset_distance; |
| 451 | |
| 452 | int start_x, start_y, end_x, end_y; |
| 453 | costmap_layer_ptr->World2MapNoBoundary(start_point_x, start_point_y, start_x, start_y); |
| 454 | costmap_layer_ptr->World2MapNoBoundary(end_point_x, end_point_y, end_x, end_y); |
| 455 | |
| 456 | unsigned char *grid = costmap_layer_ptr->GetCharMap(); |
| 457 | for (int x = 0; x < (int) costmap_layer_ptr->GetSizeXCell(); x++) { |
| 458 | bool xrange = x > start_x && x < end_x; |
| 459 | |
| 460 | for (int y = 0; y < (int) costmap_layer_ptr->GetSizeYCell(); y++) { |
| 461 | if (xrange && y > start_y && y < end_y) |
| 462 | continue; |
| 463 | int index = costmap_layer_ptr->GetIndex(x, y); |
| 464 | if (grid[index] != NO_INFORMATION) { |
| 465 | grid[index] = NO_INFORMATION; |
| 466 | } |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | double ox = costmap_layer_ptr->GetOriginX(), oy = costmap_layer_ptr->GetOriginY(); |
| 471 | double width = costmap_layer_ptr->GetSizeXWorld(), height = costmap_layer_ptr->GetSizeYWorld(); |
| 472 | costmap_layer_ptr->AddExtraBounds(ox, oy, ox + width, oy + height); |
| 473 | } |
| 474 | } //namespace roborts_costmap |
nothing calls this directly
no test coverage detected