00001 /* 00002 * Copyright 2018 The Cartographer Authors 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef CARTOGRAPHER_MAPPING_INTERNAL_2D_OVERLAPPING_SUBMAPS_TRIMMER_H_ 00018 #define CARTOGRAPHER_MAPPING_INTERNAL_2D_OVERLAPPING_SUBMAPS_TRIMMER_H_ 00019 00020 #include "cartographer/common/port.h" 00021 #include "cartographer/mapping/pose_graph_trimmer.h" 00022 00023 namespace cartographer { 00024 namespace mapping { 00025 00026 // Trims submaps that have less than 'min_covered_cells_count' cells not 00027 // overlapped by at least 'fresh_submaps_count` submaps. 00028 class OverlappingSubmapsTrimmer2D : public PoseGraphTrimmer { 00029 public: 00030 OverlappingSubmapsTrimmer2D(uint16 fresh_submaps_count, 00031 double min_covered_area, 00032 uint16 min_added_submaps_count) 00033 : fresh_submaps_count_(fresh_submaps_count), 00034 min_covered_area_(min_covered_area), 00035 min_added_submaps_count_(min_added_submaps_count) {} 00036 ~OverlappingSubmapsTrimmer2D() override = default; 00037 00038 void Trim(Trimmable* pose_graph) override; 00039 bool IsFinished() override { return finished_; } 00040 00041 private: 00042 // Number of the most recent submaps to keep. 00043 const uint16 fresh_submaps_count_; 00044 // Minimum area of covered space to keep submap from trimming measured in m^2. 00045 const double min_covered_area_; 00046 // Number of added submaps before the trimmer is invoked. 00047 const uint16 min_added_submaps_count_; 00048 // Current finished submap count. 00049 uint16 current_submap_count_ = 0; 00050 00051 bool finished_ = false; 00052 }; 00053 00054 } // namespace mapping 00055 } // namespace cartographer 00056 00057 #endif // CARTOGRAPHER_MAPPING_INTERNAL_2D_OVERLAPPING_SUBMAPS_TRIMMER_H_