submap_3d.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_3D_SUBMAP_3D_H_
18 #define CARTOGRAPHER_MAPPING_3D_SUBMAP_3D_H_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "Eigen/Geometry"
29 #include "cartographer/mapping/proto/3d/submaps_options_3d.pb.h"
30 #include "cartographer/mapping/proto/serialization.pb.h"
31 #include "cartographer/mapping/proto/submap_visualization.pb.h"
36 
37 namespace cartographer {
38 namespace mapping {
39 
40 proto::SubmapsOptions3D CreateSubmapsOptions3D(
41  common::LuaParameterDictionary* parameter_dictionary);
42 
43 class Submap3D : public Submap {
44  public:
45  Submap3D(float high_resolution, float low_resolution,
46  const transform::Rigid3d& local_submap_pose);
47  explicit Submap3D(const proto::Submap3D& proto);
48 
49  void ToProto(proto::Submap* proto,
50  bool include_probability_grid_data) const override;
51  void UpdateFromProto(const proto::Submap& proto) override;
52 
53  void ToResponseProto(const transform::Rigid3d& global_submap_pose,
54  proto::SubmapQuery::Response* response) const override;
55 
58  }
61  }
62 
63  // Insert 'range_data' into this submap using 'range_data_inserter'. The
64  // submap must not be finished yet.
65  void InsertRangeData(const sensor::RangeData& range_data,
66  const RangeDataInserter3D& range_data_inserter,
67  int high_resolution_max_range);
68  void Finish();
69 
70  private:
71  std::unique_ptr<HybridGrid> high_resolution_hybrid_grid_;
72  std::unique_ptr<HybridGrid> low_resolution_hybrid_grid_;
73 };
74 
75 // Except during initialization when only a single submap exists, there are
76 // always two submaps into which range data is inserted: an old submap that is
77 // used for matching, and a new one, which will be used for matching next, that
78 // is being initialized.
79 //
80 // Once a certain number of range data have been inserted, the new submap is
81 // considered initialized: the old submap is no longer changed, the "new" submap
82 // is now the "old" submap and is used for scan-to-map matching. Moreover, a
83 // "new" submap gets created. The "old" submap is forgotten by this object.
85  public:
86  explicit ActiveSubmaps3D(const proto::SubmapsOptions3D& options);
87 
88  ActiveSubmaps3D(const ActiveSubmaps3D&) = delete;
89  ActiveSubmaps3D& operator=(const ActiveSubmaps3D&) = delete;
90 
91  // Returns the index of the newest initialized Submap which can be
92  // used for scan-to-map matching.
93  int matching_index() const;
94 
95  // Inserts 'range_data' into the Submap collection. 'gravity_alignment' is
96  // used for the orientation of new submaps so that the z axis approximately
97  // aligns with gravity.
98  void InsertRangeData(const sensor::RangeData& range_data,
99  const Eigen::Quaterniond& gravity_alignment);
100 
101  std::vector<std::shared_ptr<Submap3D>> submaps() const;
102 
103  private:
104  void AddSubmap(const transform::Rigid3d& local_submap_pose);
105 
106  const proto::SubmapsOptions3D options_;
107  int matching_submap_index_ = 0;
108  std::vector<std::shared_ptr<Submap3D>> submaps_;
110 };
111 
112 } // namespace mapping
113 } // namespace cartographer
114 
115 #endif // CARTOGRAPHER_MAPPING_3D_SUBMAP_3D_H_
std::unique_ptr< HybridGrid > high_resolution_hybrid_grid_
Definition: submap_3d.h:71
void UpdateFromProto(const proto::Submap &proto) override
Definition: submap_3d.cc:230
const proto::SubmapsOptions3D options_
Definition: submap_3d.h:106
const HybridGrid & high_resolution_hybrid_grid() const
Definition: submap_3d.h:56
RangeDataInserter3D range_data_inserter_
Definition: submap_3d.h:109
const HybridGrid & low_resolution_hybrid_grid() const
Definition: submap_3d.h:59
void ToResponseProto(const transform::Rigid3d &global_submap_pose, proto::SubmapQuery::Response *response) const override
Definition: submap_3d.cc:251
void ToProto(proto::Submap *proto, bool include_probability_grid_data) const override
Definition: submap_3d.cc:216
std::unique_ptr< HybridGrid > low_resolution_hybrid_grid_
Definition: submap_3d.h:72
void InsertRangeData(const sensor::RangeData &range_data, const RangeDataInserter3D &range_data_inserter, int high_resolution_max_range)
Definition: submap_3d.cc:262
proto::SubmapsOptions3D CreateSubmapsOptions3D(common::LuaParameterDictionary *parameter_dictionary)
Definition: submap_3d.cc:181
std::vector< std::shared_ptr< Submap3D > > submaps_
Definition: submap_3d.h:108
Submap3D(float high_resolution, float low_resolution, const transform::Rigid3d &local_submap_pose)
Definition: submap_3d.cc:198


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