25 #include "gmock/gmock.h" 28 namespace mapping_2d {
31 class RangeDataInserterTest :
public ::testing::Test {
33 RangeDataInserterTest()
35 MapLimits(1.,
Eigen::Vector2d(1., 5.), CellLimits(5, 5))) {
38 "insert_free_space = true, " 39 "hit_probability = 0.7, " 40 "miss_probability = 0.4, " 46 void InsertPointCloud() {
47 sensor::RangeData range_data;
48 range_data.returns.emplace_back(-3.5, 0.5, 0.f);
49 range_data.returns.emplace_back(-2.5, 1.5, 0.f);
50 range_data.returns.emplace_back(-1.5, 2.5, 0.f);
51 range_data.returns.emplace_back(-0.5, 3.5, 0.f);
52 range_data.origin.x() = -0.5;
53 range_data.origin.y() = 0.5;
63 TEST_F(RangeDataInserterTest, InsertPointCloud) {
70 EXPECT_EQ(5, cell_limits.num_x_cells);
71 EXPECT_EQ(5, cell_limits.num_y_cells);
73 enum class State { UNKNOWN, MISS, HIT };
74 State expected_states[5][5] = {
75 {State::UNKNOWN, State::UNKNOWN, State::UNKNOWN, State::UNKNOWN,
77 {State::UNKNOWN, State::HIT, State::MISS, State::MISS, State::MISS},
78 {State::UNKNOWN, State::UNKNOWN, State::HIT, State::MISS, State::MISS},
79 {State::UNKNOWN, State::UNKNOWN, State::UNKNOWN, State::HIT, State::MISS},
80 {State::UNKNOWN, State::UNKNOWN, State::UNKNOWN, State::UNKNOWN,
82 for (
int row = 0; row != 5; ++row) {
83 for (
int column = 0; column != 5; ++column) {
84 Eigen::Array2i xy_index(row, column);
86 switch (expected_states[column][row]) {
91 EXPECT_NEAR(
options_.miss_probability(),
95 EXPECT_NEAR(
options_.hit_probability(),
103 TEST_F(RangeDataInserterTest, ProbabilityProgression) {
105 EXPECT_NEAR(
options_.hit_probability(),
107 EXPECT_NEAR(
options_.miss_probability(),
110 for (
int i = 0; i < 1000; ++i) {
proto::RangeDataInserterOptions options_
constexpr float kMinProbability
constexpr float kMaxProbability
std::unique_ptr< LuaParameterDictionary > MakeDictionary(const string &code)
proto::RangeDataInserterOptions CreateRangeDataInserterOptions(common::LuaParameterDictionary *const parameter_dictionary)
ProbabilityGrid probability_grid_
std::unique_ptr< RangeDataInserter > range_data_inserter_