23 #include "gmock/gmock.h" 26 namespace mapping_3d {
29 class RangeDataInserterTest :
public ::testing::Test {
34 "hit_probability = 0.7, " 35 "miss_probability = 0.4, " 36 "num_free_space_voxels = 1000, " 42 void InsertPointCloud() {
43 const Eigen::Vector3f origin = Eigen::Vector3f(0.f, 0.f, -4.f);
45 {-3.f, -1.f, 4.f}, {-2.f, 0.f, 4.f}, {-1.f, 1.f, 4.f}, {0.f, 2.f, 4.f}};
50 float GetProbability(
float x,
float y,
float z)
const {
55 float IsKnown(
float x,
float y,
float z)
const {
60 const proto::RangeDataInserterOptions& options()
const {
return options_; }
68 TEST_F(RangeDataInserterTest, InsertPointCloud) {
70 EXPECT_NEAR(options().miss_probability(), GetProbability(0.f, 0.f, -4.f),
72 EXPECT_NEAR(options().miss_probability(), GetProbability(0.f, 0.f, -3.f),
74 EXPECT_NEAR(options().miss_probability(), GetProbability(0.f, 0.f, -2.f),
76 for (
int x = -4; x <= 4; ++x) {
77 for (
int y = -4; y <= 4; ++y) {
78 if (x < -3 || x > 0 || y != x + 2) {
79 EXPECT_FALSE(IsKnown(x, y, 4.f));
81 EXPECT_NEAR(options().hit_probability(), GetProbability(x, y, 4.f),
88 TEST_F(RangeDataInserterTest, ProbabilityProgression) {
90 EXPECT_NEAR(options().hit_probability(), GetProbability(-2.f, 0.f, 4.f),
92 EXPECT_NEAR(options().miss_probability(), GetProbability(-2.f, 0.f, 3.f),
94 EXPECT_NEAR(options().miss_probability(), GetProbability(0.f, 0.f, -3.f),
97 for (
int i = 0; i < 1000; ++i) {
proto::RangeDataInserterOptions options_
proto::RangeDataInserterOptions CreateRangeDataInserterOptions(common::LuaParameterDictionary *parameter_dictionary)
constexpr float kMinProbability
constexpr float kMaxProbability
std::unique_ptr< LuaParameterDictionary > MakeDictionary(const string &code)
std::vector< Eigen::Vector3f > PointCloud
std::unique_ptr< RangeDataInserter > range_data_inserter_