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.
38 lines
993 B
C++
38 lines
993 B
C++
#include <robot_costmap_2d/critical_layer.h>
|
|
#include <boost/dll/alias.hpp>
|
|
|
|
using robot_costmap_2d::NO_INFORMATION;
|
|
using robot_costmap_2d::LETHAL_OBSTACLE;
|
|
using robot_costmap_2d::CRITICAL_SPACE;
|
|
|
|
namespace robot_costmap_2d
|
|
{
|
|
|
|
CriticalLayer::CriticalLayer(){}
|
|
CriticalLayer::~CriticalLayer(){}
|
|
|
|
unsigned char CriticalLayer::interpretValue(unsigned char value)
|
|
{
|
|
// check if the static value is above the unknown or lethal thresholds
|
|
if(value >= *this->threshold_)
|
|
return CRITICAL_SPACE;
|
|
else
|
|
return NO_INFORMATION;
|
|
}
|
|
|
|
void CriticalLayer::updateCosts(robot_costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j)
|
|
{
|
|
StaticLayer::updateCosts(master_grid, min_i, min_j, max_i, max_j);
|
|
}
|
|
|
|
// Export factory function
|
|
static boost::shared_ptr<Layer> create_critical_plugin() {
|
|
return boost::make_shared<CriticalLayer>();
|
|
}
|
|
|
|
// Alias cho Boost.DLL (nếu muốn dùng boost::dll::import_alias)
|
|
BOOST_DLL_ALIAS(create_critical_plugin, CriticalLayer)
|
|
|
|
|
|
}
|