1 #ifndef SLAM_CTOR_TESTS_SCAN_MATCHER_TEST_UTILS_H_INCLUDED 2 #define SLAM_CTOR_TESTS_SCAN_MATCHER_TEST_UTILS_H_INCLUDED 6 #include <gtest/gtest.h> 8 #include "../mock_grid_cell.h" 9 #include "../../../src/utils/data_generation/map_primitives.h" 10 #include "../../../src/utils/data_generation/grid_map_patcher.h" 11 #include "../../../src/utils/data_generation/laser_scan_generator.h" 13 #include "../../../src/core/scan_matchers/grid_scan_matcher.h" 14 #include "../../../src/core/scan_matchers/weighted_mean_point_probability_spe.h" 17 template<
typename MapType>
23 std::numeric_limits<double>::epsilon(),
24 std::numeric_limits<double>::epsilon(),
25 std::numeric_limits<double>::epsilon()
30 int map_w,
int map_h,
double map_scale,
32 :
map{std::make_shared<MockGridCell>(), {map_w, map_h, map_scale}}
39 int w_scale,
int h_scale) {
41 offset, w_scale, h_scale);
51 auto no_noise_prob =
spe->estimate_scan_probability(scan,
rpose,
map);
52 auto noise_prob =
spe->estimate_scan_probability(scan,
rpose + noise,
map);
54 return are_equal(no_noise_prob, noise_prob);
63 tr_scan.quality = 1.0;
65 ASSERT_TRUE(tr_scan.scan.points().size() != 0);
68 auto original_map_scale =
map.scale();
70 assert(
map.scale() == original_map_scale);
71 auto result_noise = noise + correction;
77 ASSERT_NEAR(0, std::abs(result_noise.x), acc_error.
x);
78 ASSERT_NEAR(0, std::abs(result_noise.y), acc_error.
y);
79 ASSERT_NEAR(0, std::abs(result_noise.theta), acc_error.
theta);
94 std::shared_ptr<ScanProbabilityEstimator>
spe;
void test_scan_matcher(const RobotPoseDelta &noise)
CONSTEXPR bool are_equal(const T &a, const T &b, const T &eps)
ScanMatcherTestBase(std::shared_ptr< ScanProbabilityEstimator > prob_est, int map_w, int map_h, double map_scale, const LaserScannerParams &dflt_lsp)
virtual RobotPoseDelta default_acceptable_error()
void test_scan_matcher(const LaserScannerParams &lsp, const RobotPoseDelta &noise, const RobotPoseDelta &acc_error)
LaserScannerParams default_lsp
virtual double process_scan(const TransformedLaserScan &scan, const RobotPose &init_pose, const GridMap &map, RobotPoseDelta &pose_delta)=0
virtual void add_primitive_to_map(const TextRasterMapPrimitive &mp, const DiscretePoint2D &offset, int w_scale, int h_scale)
void apply_text_raster(MapType &dst_map, std::istream &src_raster, const DiscretePoint2D &dst_offset, int w_zoom=1, int h_zoom=1)
virtual bool is_result_noise_acceptable(const TransformedLaserScan &raw_scan, const RobotPoseDelta &init_noise, const RobotPoseDelta &noise)
std::shared_ptr< ScanProbabilityEstimator > spe
static constexpr RobotPoseDelta Acceptable_Error
virtual GridScanMatcher & scan_matcher()=0
void test_scan_matcher(const RobotPoseDelta &noise, const RobotPoseDelta &acc_error)