pose_graph_trimmer_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 <vector>
20 
22 #include "gtest/gtest.h"
23 
24 namespace cartographer {
25 namespace mapping {
26 namespace {
27 
28 class FakePoseGraph : public Trimmable {
29  public:
30  ~FakePoseGraph() override {}
31 
32  int num_submaps(int trajectory_id) const override { return 17; }
33 
34  void MarkSubmapAsTrimmed(const SubmapId& submap_id) override {
35  trimmed_submaps_.push_back(submap_id);
36  }
37 
38  std::vector<SubmapId> trimmed_submaps() { return trimmed_submaps_; }
39 
40  private:
41  std::vector<SubmapId> trimmed_submaps_;
42 };
43 
44 TEST(PureLocalizationTrimmerTest, MarksSubmapsAsExpected) {
45  const int kTrajectoryId = 42;
46  PureLocalizationTrimmer trimmer(kTrajectoryId, 15);
47  FakePoseGraph fake_pose_graph;
48  trimmer.Trim(&fake_pose_graph);
49 
50  const auto trimmed_submaps = fake_pose_graph.trimmed_submaps();
51  ASSERT_EQ(2, trimmed_submaps.size());
52  EXPECT_EQ((SubmapId{kTrajectoryId, 0}), trimmed_submaps[0]);
53  EXPECT_EQ((SubmapId{kTrajectoryId, 1}), trimmed_submaps[1]);
54 }
55 
56 } // namespace
57 } // namespace mapping
58 } // namespace cartographer
std::vector< SubmapId > trimmed_submaps_


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