26 #include "gmock/gmock.h" 32 class RangeDataInserterTest2D :
public ::testing::Test {
34 RangeDataInserterTest2D()
36 MapLimits(1.,
Eigen::Vector2d(1., 5.), CellLimits(5, 5))) {
39 "insert_free_space = true, " 40 "hit_probability = 0.7, " 41 "miss_probability = 0.4, " 44 parameter_dictionary.get());
46 common::make_unique<ProbabilityGridRangeDataInserter2D>(
options_);
49 void InsertPointCloud() {
50 sensor::RangeData range_data;
51 range_data.returns.emplace_back(-3.5f, 0.5f, 0.f);
52 range_data.returns.emplace_back(-2.5f, 1.5f, 0.f);
53 range_data.returns.emplace_back(-1.5f, 2.5f, 0.f);
54 range_data.returns.emplace_back(-0.5f, 3.5f, 0.f);
55 range_data.origin.x() = -0.5f;
56 range_data.origin.y() = 0.5f;
63 proto::ProbabilityGridRangeDataInserterOptions2D
options_;
66 TEST_F(RangeDataInserterTest2D, InsertPointCloud) {
73 EXPECT_EQ(5, cell_limits.num_x_cells);
74 EXPECT_EQ(5, cell_limits.num_y_cells);
76 enum class State { UNKNOWN, MISS, HIT };
77 State expected_states[5][5] = {
78 {State::UNKNOWN, State::UNKNOWN, State::UNKNOWN, State::UNKNOWN,
80 {State::UNKNOWN, State::HIT, State::MISS, State::MISS, State::MISS},
81 {State::UNKNOWN, State::UNKNOWN, State::HIT, State::MISS, State::MISS},
82 {State::UNKNOWN, State::UNKNOWN, State::UNKNOWN, State::HIT, State::MISS},
83 {State::UNKNOWN, State::UNKNOWN, State::UNKNOWN, State::UNKNOWN,
85 for (
int row = 0; row != 5; ++row) {
86 for (
int column = 0; column != 5; ++column) {
87 Eigen::Array2i cell_index(row, column);
89 switch (expected_states[column][row]) {
94 EXPECT_NEAR(
options_.miss_probability(),
98 EXPECT_NEAR(
options_.hit_probability(),
106 TEST_F(RangeDataInserterTest2D, ProbabilityProgression) {
111 Eigen::Vector2f(-3.5f, 0.5f))),
116 Eigen::Vector2f(-2.5f, 0.5f))),
119 for (
int i = 0; i < 1000; ++i) {
125 Eigen::Vector2f(-3.5f, 0.5f))),
130 Eigen::Vector2f(-2.5f, 0.5f))),
ProbabilityGrid probability_grid_
proto::ProbabilityGridRangeDataInserterOptions2D CreateProbabilityGridRangeDataInserterOptions2D(common::LuaParameterDictionary *parameter_dictionary)
std::unique_ptr< LuaParameterDictionary > MakeDictionary(const std::string &code)
constexpr float kMinProbability
constexpr float kMaxProbability
proto::ProbabilityGridRangeDataInserterOptions2D options_
std::unique_ptr< ProbabilityGridRangeDataInserter2D > range_data_inserter_