1 #include <gtest/gtest.h> 6 #include "../mock_grid_cell.h" 7 #include "../../../src/core/maps/plain_grid_map.h" 8 #include "../../../src/core/scan_matchers/occupancy_observation_probability.h" 19 {100, 100, Map_Scale}} {
32 template <
typename OOPE>
34 const LWR &range = {0, 0, 0, 0})
const {
35 auto actual = OOPE{}.probability(
AOO{
true, {1, 1}, obstacle, 1},
36 range.move_center(obstacle),
map);
37 ASSERT_NEAR(expected, actual, std::numeric_limits<double>::epsilon());
43 template <
int i,
int j>
58 test_oope<OOPE>(1, mid<0,0>());
62 test_oope<OOPE>(1, mid<0,0>(), {-1000, 1000, -1000, 1000});
66 test_oope<OOPE>(1, mid<0,0>());
67 test_oope<OOPE>(1, mid<0,0>() +
Shift{
Map_Scale, Map_Scale} * 0.25);
71 test_oope<OOPE>(1.00, mid<0,0>());
72 test_oope<OOPE>(0.25, mid<0,0>() +
Shift{0, Map_Scale});
86 test_oope<OOPE>(1, mid<0,0>());
91 test_oope<OOPE>(0.25, mid<0,1>(), range);
92 test_oope<OOPE>(1, mid<0,1>() +
Shift{0, -Map_Scale} * 0.5, range);
93 test_oope<OOPE>(0.25, mid<0,1>() +
Shift{
Map_Scale, 0} * 0.5, range);
94 test_oope<OOPE>(1, mid<0,1>() +
Shift{
Map_Scale, -Map_Scale} * 0.5, range);
95 test_oope<OOPE>(0.5, mid<1,0>() +
Shift{0, Map_Scale} * 0.5, range);
100 test_oope<OOPE>(0.25, mid<0,1>(), range);
101 test_oope<OOPE>(1, mid<0,1>() +
Shift{0, -Map_Scale} * 0.375, range);
102 test_oope<OOPE>(0.25, mid<0,1>() +
Shift{
Map_Scale, 0} * 0.375, range);
103 test_oope<OOPE>(1, mid<0,1>() +
Shift{
Map_Scale, -Map_Scale} * 0.375, range);
109 test_oope<OOPE>(0.5, mid<1, -1>(), range);
110 test_oope<OOPE>(1, mid<1,-1>(), range.shrink(0.5));
122 test_oope<OOPE>(1, mid<0,0>());
127 test_oope<OOPE>(0.25, mid<0,1>(), range);
128 test_oope<OOPE>(1.25 / 2, mid<0,1>() +
Shift{0, -Map_Scale} * 0.5, range);
129 test_oope<OOPE>(0.25 / 2, mid<0,1>() +
Shift{
Map_Scale, 0} * 0.5, range);
130 test_oope<OOPE>(1.75 / 4,
136 test_oope<OOPE>(0.25, mid<0,1>(), range);
138 test_oope<OOPE>(1.25 / 2, mid<0,1>() +
Shift{0, -Map_Scale} * 0.375, range);
139 test_oope<OOPE>(0.25 / 2, mid<0,1>() +
Shift{
Map_Scale, 0} * 0.375, range);
140 test_oope<OOPE>(1.75 / 4,
142 test_oope<OOPE>(0.5 / 2, mid<1,0>() +
Shift{0, Map_Scale} * 0.375, range);
148 test_oope<OOPE>(0.5 / 4, mid<1, -1>(), range);
149 test_oope<OOPE>(1.5 / 9, mid<1,-1>(), range.shrink(0.5));
161 test_oope<OOPE>(1, mid<0,0>());
166 test_oope<OOPE>(0.25, mid<0,1>(), range);
167 test_oope<OOPE>(0.625, mid<0,1>() +
Shift{0, -Map_Scale} * 0.5, range);
168 test_oope<OOPE>(0.25 / 2, mid<0,1>() +
Shift{
Map_Scale, 0} * 0.5, range);
169 test_oope<OOPE>(1.75 / 4,
171 test_oope<OOPE>(0.5 / 2, mid<1,0>() +
Shift{0, Map_Scale} * 0.5, range);
176 test_oope<OOPE>(0.25, mid<0,1>(), range);
177 test_oope<OOPE>(0.4375, mid<0,1>() +
Shift{0, -Map_Scale} * 0.375, range);
178 test_oope<OOPE>(0.1875, mid<0,1>() +
Shift{
Map_Scale, 0} * 0.375, range);
179 test_oope<OOPE>(0.25*0.25*0.5 + 0.25 * 0.75 * 1 + 0.75 * 0.75 * 0.25,
185 test_oope<OOPE>(0.5*0.25 + 1*0.125 + 0.25*0.0625,
186 mid<1,0>(), range.shrink(0.5));
191 test_oope<OOPE>((0.5*1 + 1*0.25 + 0.25*0.0625) / 2.25,
192 mid<1,0>(), range.shrink(2.0 / 3.0));
201 auto point_area =
LWR{};
202 test_oope<ObstacleBasedOccupancyObservationPE>(0.5, mid<1,0>(), point_area);
203 test_oope<MaxOccupancyObservationPE>(0.5, mid<1,0>(), point_area);
204 test_oope<MeanOccupancyObservationPE>(0.5, mid<1,0>(), point_area);
205 test_oope<OverlapWeightedOccupancyObservationPE>(0.5, mid<1,0>(), point_area);
210 int main (
int argc,
char *argv[]) {
211 ::testing::InitGoogleTest(&argc, argv);
212 return RUN_ALL_TESTS();
void update(const Coord &area_id, const AreaOccupancyObservation &aoo) override
Updates area with a given observation.
TEST_F(ObstacleBasedOOPETest, obstacleMid)
void update_map(const UnboundedPlainGridMap::Coord &area_id, double occ)
static constexpr double Map_Scale
int main(int argc, char *argv[])
UnboundedPlainGridMap map
static constexpr double Default_Prob
void test_oope(double expected, const Point2D &obstacle, const LWR &range={0, 0, 0, 0}) const