23 #include "gmock/gmock.h" 29 class RangeDataInserter3DTest :
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::RangeDataInserterOptions3D& options()
const {
return options_; }
68 TEST_F(RangeDataInserter3DTest, 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(RangeDataInserter3DTest, 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::RangeDataInserterOptions3D options_
proto::RangeDataInserterOptions3D CreateRangeDataInserterOptions3D(common::LuaParameterDictionary *parameter_dictionary)
std::unique_ptr< LuaParameterDictionary > MakeDictionary(const std::string &code)
constexpr float kMinProbability
constexpr float kMaxProbability
std::vector< Eigen::Vector3f > PointCloud
std::unique_ptr< RangeDataInserter3D > range_data_inserter_