costmap_2d/plugins/unpreferred_layer.cpp
2025-11-15 17:36:52 +07:00

33 lines
887 B
C++

#include <costmap_2d/unpreferred_layer.h>
#include <boost/dll/alias.hpp>
using costmap_2d::NO_INFORMATION;
using costmap_2d::LETHAL_OBSTACLE;
using costmap_2d::PREFERRED_SPACE;
namespace costmap_2d
{
UnPreferredLayer::UnPreferredLayer(){}
UnPreferredLayer::~UnPreferredLayer(){}
unsigned char UnPreferredLayer::interpretValue(unsigned char value)
{
// check if the static value is above the unknown or lethal thresholds
if(value == 0) return NO_INFORMATION;
else if (value >= *this->threshold_)
return UNPREFERRED_SPACE;
double scale = (double) value / *this->threshold_;
return scale * LETHAL_OBSTACLE;
}
// Export factory function
static PluginLayerPtr create_unpreferred_plugin() {
return std::make_shared<UnPreferredLayer>();
}
// Alias cho Boost.DLL (nếu muốn dùng boost::dll::import_alias)
BOOST_DLL_ALIAS(create_unpreferred_plugin, create_plugin)
}