fix(costmap_2d): draw StaticLayer-family layers correctly in rolling costmaps
In a rolling (local) costmap the StaticLayer extent is in map_frame_, so the bounds it reported did not cover the moving master window and zone layers (forbidden, preferred, unpreferred, critical) were not redrawn as the robot moved. - StaticLayer::updateBounds: when the costmap is rolling, expand the bounds to the whole master window every cycle. - StaticLayer::updateCosts: skip when disabled; the transformed path uses the master grid passed in and the same merge policy as the aligned path. - CostmapLayer::mergeCost: one merge rule for aligned and transformed grids. NO_INFORMATION in the layer keeps the master cell; CRITICAL_SPACE always wins; PREFERRED/UNPREFERRED only below INSCRIBED_INFLATED_OBSTACLE; otherwise max. updateWithMax and updateWithOverwrite keep their previous results. - CriticalLayer::updateCosts delegates to StaticLayer::updateCosts, so it is rolling-aware too. - Test: rolling_static_layer_test, 7 cases. Tests on dev: rolling_static_layer_test 7/7, test_costmap 9/9, costmap_common_root_test 4/4 (rooted and flat). directional_layer_test InvalidMaxDeviationThrows still fails: it checks directional_layer.cpp initialization, which this change does not touch.
This commit is contained in:
@@ -60,6 +60,18 @@ void CostmapLayer::useExtraBounds(double* min_x, double* min_y, double* max_x, d
|
||||
has_extra_bounds_ = false;
|
||||
}
|
||||
|
||||
unsigned char CostmapLayer::mergeCost(unsigned char master_cost, unsigned char layer_cost, bool use_maximum)
|
||||
{
|
||||
if (layer_cost == NO_INFORMATION)
|
||||
return master_cost;
|
||||
if (!use_maximum || layer_cost == CRITICAL_SPACE ||
|
||||
((layer_cost == PREFERRED_SPACE || layer_cost == UNPREFERRED_SPACE) &&
|
||||
master_cost < INSCRIBED_INFLATED_OBSTACLE) ||
|
||||
master_cost == NO_INFORMATION || master_cost < layer_cost)
|
||||
return layer_cost;
|
||||
return master_cost;
|
||||
}
|
||||
|
||||
void CostmapLayer::updateWithMax(robot_costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j)
|
||||
{
|
||||
if (!enabled_)
|
||||
@@ -73,28 +85,7 @@ void CostmapLayer::updateWithMax(robot_costmap_2d::Costmap2D& master_grid, int m
|
||||
unsigned int it = j * span + min_i;
|
||||
for (int i = min_i; i < max_i; i++)
|
||||
{
|
||||
if (costmap_[it] == NO_INFORMATION){
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
if (costmap_[it] == CRITICAL_SPACE){
|
||||
master_array[it] = costmap_[it];
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
if (costmap_[it] == PREFERRED_SPACE && master_array[it] < INSCRIBED_INFLATED_OBSTACLE ){
|
||||
master_array[it] = costmap_[it];
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
if (costmap_[it] == UNPREFERRED_SPACE && master_array[it] < INSCRIBED_INFLATED_OBSTACLE ){
|
||||
master_array[it] = costmap_[it];
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
unsigned char old_cost = master_array[it];
|
||||
if (old_cost == NO_INFORMATION || old_cost < costmap_[it])
|
||||
master_array[it] = costmap_[it];
|
||||
master_array[it] = mergeCost(master_array[it], costmap_[it], true);
|
||||
it++;
|
||||
}
|
||||
}
|
||||
@@ -131,8 +122,7 @@ void CostmapLayer::updateWithOverwrite(robot_costmap_2d::Costmap2D& master_grid,
|
||||
unsigned int it = span*j+min_i;
|
||||
for (int i = min_i; i < max_i; i++)
|
||||
{
|
||||
if (costmap_[it] != NO_INFORMATION)
|
||||
master[it] = costmap_[it];
|
||||
master[it] = mergeCost(master[it], costmap_[it], false);
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user