submap_2d.h
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 
17 #ifndef CARTOGRAPHER_MAPPING_2D_SUBMAP_2D_H_
18 #define CARTOGRAPHER_MAPPING_2D_SUBMAP_2D_H_
19 
20 #include <memory>
21 #include <vector>
22 
23 #include "Eigen/Core"
27 #include "cartographer/mapping/proto/2d/submaps_options_2d.pb.h"
28 #include "cartographer/mapping/proto/serialization.pb.h"
29 #include "cartographer/mapping/proto/submap_visualization.pb.h"
35 
36 namespace cartographer {
37 namespace mapping {
38 
39 proto::SubmapsOptions2D CreateSubmapsOptions2D(
40  common::LuaParameterDictionary* parameter_dictionary);
41 
42 class Submap2D : public Submap {
43  public:
44  Submap2D(const Eigen::Vector2f& origin, std::unique_ptr<Grid2D> grid);
45  explicit Submap2D(const proto::Submap2D& proto);
46 
47  void ToProto(proto::Submap* proto,
48  bool include_probability_grid_data) const override;
49  void UpdateFromProto(const proto::Submap& proto) override;
50 
51  void ToResponseProto(const transform::Rigid3d& global_submap_pose,
52  proto::SubmapQuery::Response* response) const override;
53 
54  const Grid2D* grid() const { return grid_.get(); }
55 
56  // Insert 'range_data' into this submap using 'range_data_inserter'. The
57  // submap must not be finished yet.
58  void InsertRangeData(const sensor::RangeData& range_data,
59  const RangeDataInserterInterface* range_data_inserter);
60  void Finish();
61 
62  private:
63  std::unique_ptr<Grid2D> grid_;
64 };
65 
66 // Except during initialization when only a single submap exists, there are
67 // always two submaps into which range data is inserted: an old submap that is
68 // used for matching, and a new one, which will be used for matching next, that
69 // is being initialized.
70 //
71 // Once a certain number of range data have been inserted, the new submap is
72 // considered initialized: the old submap is no longer changed, the "new" submap
73 // is now the "old" submap and is used for scan-to-map matching. Moreover, a
74 // "new" submap gets created. The "old" submap is forgotten by this object.
76  public:
77  explicit ActiveSubmaps2D(const proto::SubmapsOptions2D& options);
78 
79  ActiveSubmaps2D(const ActiveSubmaps2D&) = delete;
80  ActiveSubmaps2D& operator=(const ActiveSubmaps2D&) = delete;
81 
82  // Returns the index of the newest initialized Submap which can be
83  // used for scan-to-map matching.
84  int matching_index() const;
85 
86  // Inserts 'range_data' into the Submap collection.
87  void InsertRangeData(const sensor::RangeData& range_data);
88 
89  std::vector<std::shared_ptr<Submap2D>> submaps() const;
90 
91  private:
92  std::unique_ptr<RangeDataInserterInterface> CreateRangeDataInserter();
93  std::unique_ptr<GridInterface> CreateGrid(const Eigen::Vector2f& origin);
94  void FinishSubmap();
95  void AddSubmap(const Eigen::Vector2f& origin);
96 
97  const proto::SubmapsOptions2D options_;
98  int matching_submap_index_ = 0;
99  std::vector<std::shared_ptr<Submap2D>> submaps_;
100  std::unique_ptr<RangeDataInserterInterface> range_data_inserter_;
101 };
102 
103 } // namespace mapping
104 } // namespace cartographer
105 
106 #endif // CARTOGRAPHER_MAPPING_2D_SUBMAP_2D_H_
void InsertRangeData(const sensor::RangeData &range_data, const RangeDataInserterInterface *range_data_inserter)
Definition: submap_2d.cc:113
void ToProto(proto::Submap *proto, bool include_probability_grid_data) const override
Definition: submap_2d.cc:80
std::unique_ptr< RangeDataInserterInterface > range_data_inserter_
Definition: submap_2d.h:100
proto::SubmapsOptions2D CreateSubmapsOptions2D(common::LuaParameterDictionary *const parameter_dictionary)
Definition: submap_2d.cc:35
void ToResponseProto(const transform::Rigid3d &global_submap_pose, proto::SubmapQuery::Response *response) const override
Definition: submap_2d.cc:103
const proto::SubmapsOptions2D options_
Definition: submap_2d.h:97
std::vector< std::shared_ptr< Submap2D > > submaps_
Definition: submap_2d.h:99
Submap2D(const Eigen::Vector2f &origin, std::unique_ptr< Grid2D > grid)
Definition: submap_2d.cc:64
const Grid2D * grid() const
Definition: submap_2d.h:54
std::unique_ptr< Grid2D > grid_
Definition: submap_2d.h:63
void UpdateFromProto(const proto::Submap &proto) override
Definition: submap_2d.cc:92


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