1 #include <gtest/gtest.h> 3 #include "../../../src/core/maps/grid_map_scan_adders.h" 7 #include "../mock_grid_cell.h" 8 #include "../../../src/core/maps/const_occupancy_estimator.h" 9 #include "../../../src/core/maps/plain_grid_map.h" 10 #include "../../../src/core/math_utils.h" 11 #include "../../../src/utils/data_generation/grid_map_patcher.h" 12 #include "../../../src/utils/data_generation/laser_scan_generator.h" 13 #include "../../../src/utils/data_generation/map_primitives.h" 38 auto oe = std::make_shared<ConstOccupancyEstimator>(
Occup,
Empty);
40 return builder.set_occupancy_estimator(oe)
45 auto unknown_prob =
static_cast<double>(*cell_proto);
48 for (raw_coord.x = 0; raw_coord.x < map.
width(); ++raw_coord.x) {
49 for (raw_coord.y = 0; raw_coord.y < map.
width(); ++raw_coord.y) {
51 if (!
are_equal(unknown_prob, map[coord])) {
60 auto unknown_prob =
static_cast<double>(*cell_proto);
67 for (raw_coord.x = 0; raw_coord.x < inner.
width(); ++raw_coord.x) {
68 for (raw_coord.y = 0; raw_coord.y < inner.
width(); ++raw_coord.y) {
70 if (
are_equal(unknown_prob, inner[coord])) {
continue; }
71 if (!
are_equal(inner[coord], outer[coord])) {
return false; }
78 for (
auto &sp : scan.
points()) {
81 if (!
are_equal(1.0, map[coord])) {
return false; }
106 scan.trig_provider->set_base_angle(
pose.
theta);
121 :
cell_proto{std::make_shared<MockGridCell>()}
126 std::shared_ptr<GridMapScanAdder>
adder(
double blurring_width)
const {
127 auto oe = std::make_shared<ConstOccupancyEstimator>(
Occup,
Empty);
129 return builder.set_occupancy_estimator(oe)
130 .set_blur_distance(blurring_width)
152 constexpr
double Blur_Distance = 3;
153 adder(Blur_Distance)->append_scan(
dst_map,
pose, scan, 1.0, 0);
156 scan.trig_provider->set_base_angle(
pose.
theta);
159 double prev_prob = 0;
161 unsigned occupied_cells = 0;
162 while (beam_coord.x <= Obstacle_Coord.x) {
163 if (prev_prob == 0) {
164 ASSERT_TRUE(0 <=
dst_map[beam_coord]);
166 ASSERT_TRUE(prev_prob <
dst_map[beam_coord]);
168 prev_prob =
dst_map[beam_coord];
169 occupied_cells += 0 < prev_prob ? 1 : 0;
172 ASSERT_TRUE(1 < occupied_cells);
177 int main (
int argc,
char *argv[]) {
178 ::testing::InitGoogleTest(&argc, argv);
179 return RUN_ALL_TESTS();
static constexpr auto to_lsp(double max_dist, double fow_deg, unsigned pts_nm)
Coord world_to_cell(const Point2D &pt) const
CONSTEXPR bool are_equal(const T &a, const T &b, const T &eps)
int main(int argc, char *argv[])
void update(const Coord &area_id, const AreaOccupancyObservation &aoo) override
Updates area with a given observation.
bool map_includes(const GridMap &outer, const GridMap &inner) const
bool map_was_modified(const GridMap &map) const
UnboundedPlainGridMap src_map
DistanceBasedWallBlurringTest()
bool map_contains_scan(const GridMap &map, const LaserScan2D &scan)
virtual DiscretePoint2D origin() const
static WallDistanceBlurringScanAdderBuilder builder()
constexpr Occupancy Occup
std::shared_ptr< GridMapScanAdder > plain_adder() const
static constexpr int MAP_WIDTH
static constexpr int MAP_HEIGHT
std::shared_ptr< GridMapScanAdder > adder(double blurring_width) const
UnboundedPlainGridMap dst_map
void apply_text_raster(MapType &dst_map, std::istream &src_raster, const DiscretePoint2D &dst_offset, int w_zoom=1, int h_zoom=1)
Coord internal2external(const Coord &coord) const
UnboundedPlainGridMap src_map
const Points & points() const
LaserScan2D laser_scan_2D(const GridMap &map, const RobotPose &pose, double occ_threshold=1)
std::shared_ptr< GridCell > cell_proto
std::shared_ptr< TrigonometryProvider > trig_provider
static constexpr double MAP_SCALE
PlainScanIntegrationTest()
virtual int height() const
constexpr double deg2rad(double angle_deg)
constexpr Occupancy Empty
TEST_F(PlainScanIntegrationTest, smokeScanAdditionTest)
virtual double scale() const
virtual int width() const
std::shared_ptr< GridCell > cell_proto