2d/submaps_test.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2016 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include <map>
20 #include <string>
21 
26 #include "gmock/gmock.h"
27 
28 namespace cartographer {
29 namespace mapping_2d {
30 namespace {
31 
32 TEST(SubmapsTest, TheRightNumberOfScansAreInserted) {
33  constexpr int kNumRangeData = 10;
34  auto parameter_dictionary = common::MakeDictionary(
35  "return {"
36  "resolution = 0.05, "
37  "half_length = 10., "
38  "num_range_data = " +
39  std::to_string(kNumRangeData) +
40  ", "
41  "output_debug_images = false, "
42  "range_data_inserter = {"
43  "insert_free_space = true, "
44  "hit_probability = 0.53, "
45  "miss_probability = 0.495, "
46  "},"
47  "}");
48  Submaps submaps{CreateSubmapsOptions(parameter_dictionary.get())};
49  for (int i = 0; i != 1000; ++i) {
50  submaps.InsertRangeData({Eigen::Vector3f::Zero(), {}, {}});
51  const int matching = submaps.matching_index();
52  // Except for the first, maps should only be returned after enough scans.
53  if (matching != 0) {
54  EXPECT_LE(kNumRangeData, submaps.Get(matching)->num_range_data());
55  }
56  }
57  for (int i = 0; i != submaps.size() - 2; ++i) {
58  // Submaps should not be left without the right number of scans in them.
59  EXPECT_EQ(kNumRangeData * 2, submaps.Get(i)->num_range_data());
60  }
61 }
62 
63 } // namespace
64 } // namespace mapping_2d
65 } // namespace cartographer
std::unique_ptr< LuaParameterDictionary > MakeDictionary(const string &code)
proto::SubmapsOptions CreateSubmapsOptions(common::LuaParameterDictionary *const parameter_dictionary)
Definition: 2d/submaps.cc:87


cartographer
Author(s):
autogenerated on Wed Jun 5 2019 21:57:59