Go to the documentation of this file.00001 #ifndef __TINY_SCAN_COST_ESTIMATOR
00002 #define __TINY_SCAN_COST_ESTIMATOR
00003
00004 #include "../core/grid_scan_matcher.h"
00005
00013 class TinyScanCostEstimator : public ScanCostEstimator {
00014 public:
00015
00025 virtual double estimate_scan_cost(const RobotState &pose,
00026 const TransformedLaserScan &scan,
00027 const GridMap &map,
00028 double min_cost) override {
00029 double cost = 0;
00030 for (const auto &sp : scan.points) {
00031 if (!sp.is_occupied) {
00032 continue;
00033 }
00034
00035 double x_world = pose.x + sp.range * std::cos(sp.angle+pose.theta);
00036 double y_world = pose.y + sp.range * std::sin(sp.angle+pose.theta);
00037
00038 DiscretePoint2D cell_coord = map.world_to_cell(x_world, y_world);
00039 double cell_value = map.cell_value(cell_coord);
00040 cost += 1.0 - cell_value;
00041 if (min_cost < cost) {
00042 break;
00043 }
00044 }
00045 return cost;
00046 }
00047
00048 };
00049
00050 #endif