pose_graph_trimmer.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 "glog/logging.h"
20 
21 namespace cartographer {
22 namespace mapping {
23 
25  const int num_submaps_to_keep)
26  : trajectory_id_(trajectory_id), num_submaps_to_keep_(num_submaps_to_keep) {
27  CHECK_GE(num_submaps_to_keep, 3);
28 }
29 
30 void PureLocalizationTrimmer::Trim(Trimmable* const pose_graph) {
31  if (pose_graph->IsFinished(trajectory_id_)) {
33  }
34 
35  auto submap_ids = pose_graph->GetSubmapIds(trajectory_id_);
36  for (std::size_t i = 0; i + num_submaps_to_keep_ < submap_ids.size(); ++i) {
37  pose_graph->MarkSubmapAsTrimmed(submap_ids.at(i));
38  }
39 
40  if (num_submaps_to_keep_ == 0) {
41  finished_ = true;
42  }
43 }
44 
46 
47 } // namespace mapping
48 } // namespace cartographer
virtual bool IsFinished(int trajectory_id) const =0
virtual void MarkSubmapAsTrimmed(const SubmapId &submap_id)=0
int trajectory_id_
PureLocalizationTrimmer(int trajectory_id, int num_submaps_to_keep)
virtual std::vector< SubmapId > GetSubmapIds(int trajectory_id) const =0
void Trim(Trimmable *pose_graph) override


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