fake_trimmable.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 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 
17 #ifndef CARTOGRAPHER_MAPPING_INTERNAL_TESTING_FAKE_TRIMMABLE_H_
18 #define CARTOGRAPHER_MAPPING_INTERNAL_TESTING_FAKE_TRIMMABLE_H_
19 
20 #include <vector>
21 
23 
24 namespace cartographer {
25 namespace mapping {
26 namespace testing {
27 
28 class FakeTrimmable : public Trimmable {
29  public:
30  FakeTrimmable() = default;
31 
32  // Populates dummy SubmapIDs.
33  FakeTrimmable(int trajectory_id, int num_submaps) {
34  for (int index = 0; index < num_submaps; ++index) {
35  submap_data_.Insert(SubmapId{trajectory_id, index}, {});
36  }
37  }
38  ~FakeTrimmable() override {}
39 
40  int num_submaps(const int trajectory_id) const override {
41  return submap_data_.size() - trimmed_submaps_.size();
42  }
43 
44  std::vector<SubmapId> GetSubmapIds(int trajectory_id) const override {
45  std::vector<SubmapId> submap_ids;
46  for (const auto& submap : submap_data_) {
47  submap_ids.push_back(submap.id);
48  }
49  return submap_ids;
50  }
51 
54  submap_data_ = submap_data;
55  }
56 
58  return &submap_data_;
59  }
60 
62  const override {
63  return submap_data_;
64  }
65 
67  const MapById<NodeId, TrajectoryNode>& trajectory_nodes) {
68  trajectory_nodes_ = trajectory_nodes;
69  }
70 
72  return &trajectory_nodes_;
73  }
74 
76  return trajectory_nodes_;
77  }
78 
80  const std::vector<PoseGraphInterface::Constraint>& constraints) {
81  constraints_ = constraints;
82  }
83 
84  std::vector<PoseGraphInterface::Constraint>* mutable_constraints() {
85  return &constraints_;
86  }
87 
88  const std::vector<PoseGraphInterface::Constraint>& GetConstraints()
89  const override {
90  return constraints_;
91  }
92 
93  void MarkSubmapAsTrimmed(const SubmapId& submap_id) override {
94  trimmed_submaps_.push_back(submap_id);
95  }
96 
97  bool IsFinished(const int trajectory_id) const override { return false; }
98 
99  std::vector<SubmapId> trimmed_submaps() { return trimmed_submaps_; }
100 
101  private:
102  std::vector<SubmapId> trimmed_submaps_;
103 
104  std::vector<PoseGraphInterface::Constraint> constraints_;
107 };
108 
109 } // namespace testing
110 } // namespace mapping
111 } // namespace cartographer
112 
113 #endif // CARTOGRAPHER_MAPPING_INTERNAL_TESTING_FAKE_TRIMMABLE_H_
const std::vector< PoseGraphInterface::Constraint > & GetConstraints() const override
MapById< SubmapId, PoseGraphInterface::SubmapData > * mutable_submap_data()
int num_submaps(const int trajectory_id) const override
FakeTrimmable(int trajectory_id, int num_submaps)
MapById< SubmapId, PoseGraphInterface::SubmapData > GetOptimizedSubmapData() const override
const MapById< NodeId, TrajectoryNode > & GetTrajectoryNodes() const override
MapById< NodeId, TrajectoryNode > * mutable_trajectory_nodes()
bool IsFinished(const int trajectory_id) const override
void set_submap_data(const MapById< SubmapId, PoseGraphInterface::SubmapData > &submap_data)
void set_trajectory_nodes(const MapById< NodeId, TrajectoryNode > &trajectory_nodes)
void MarkSubmapAsTrimmed(const SubmapId &submap_id) override
std::vector< PoseGraphInterface::Constraint > constraints_
std::vector< PoseGraphInterface::Constraint > * mutable_constraints()
MapById< NodeId, TrajectoryNode > trajectory_nodes_
std::vector< SubmapId > GetSubmapIds(int trajectory_id) const override
MapById< SubmapId, PoseGraphInterface::SubmapData > submap_data_
void set_constraints(const std::vector< PoseGraphInterface::Constraint > &constraints)


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58