map_builder.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_MAP_BUILDER_H_
18 #define CARTOGRAPHER_MAPPING_MAP_BUILDER_H_
19 
20 #include <memory>
21 #include <string>
22 #include <unordered_map>
23 #include <unordered_set>
24 #include <vector>
25 
26 #include "Eigen/Geometry"
30 #include "cartographer/mapping/proto/map_builder_options.pb.h"
31 #include "cartographer/mapping/proto/submap_visualization.pb.h"
32 #include "cartographer/mapping/proto/trajectory_builder_options.pb.h"
39 
40 namespace cartographer {
41 namespace mapping {
42 
43 proto::MapBuilderOptions CreateMapBuilderOptions(
44  common::LuaParameterDictionary* const parameter_dictionary);
45 
46 // Wires up the complete SLAM stack with TrajectoryBuilders (for local submaps)
47 // and a SparsePoseGraph for loop closure.
48 class MapBuilder {
49  public:
50  MapBuilder(const proto::MapBuilderOptions& options);
51  ~MapBuilder();
52 
53  MapBuilder(const MapBuilder&) = delete;
54  MapBuilder& operator=(const MapBuilder&) = delete;
55 
56  // Create a new trajectory and return its index.
58  const std::unordered_set<string>& expected_sensor_ids,
59  const proto::TrajectoryBuilderOptions& trajectory_options);
60 
61  // Returns the TrajectoryBuilder corresponding to the specified
62  // 'trajectory_id'.
63  mapping::TrajectoryBuilder* GetTrajectoryBuilder(int trajectory_id) const;
64 
65  // Marks the TrajectoryBuilder corresponding to 'trajectory_id' as finished,
66  // i.e. no further sensor data is expected.
67  void FinishTrajectory(int trajectory_id);
68 
69  // Must only be called if at least one unfinished trajectory exists. Returns
70  // the ID of the trajectory that needs more data before the MapBuilder is
71  // unblocked.
72  int GetBlockingTrajectoryId() const;
73 
74  // Fills the SubmapQuery::Response corresponding to 'submap_index' from
75  // 'trajectory_id'. Returns an error string on failure, or an empty string on
76  // success.
77  string SubmapToProto(int trajectory_id, int submap_index,
78  proto::SubmapQuery::Response* response);
79 
80  int num_trajectory_builders() const;
81 
83 
84  private:
85  const proto::MapBuilderOptions options_;
87 
88  std::unique_ptr<mapping_2d::SparsePoseGraph> sparse_pose_graph_2d_;
89  std::unique_ptr<mapping_3d::SparsePoseGraph> sparse_pose_graph_3d_;
91 
93  std::vector<std::unique_ptr<mapping::TrajectoryBuilder>> trajectory_builders_;
94 };
95 
96 } // namespace mapping
97 } // namespace cartographer
98 
99 #endif // CARTOGRAPHER_MAPPING_MAP_BUILDER_H_
std::unique_ptr< mapping_3d::SparsePoseGraph > sparse_pose_graph_3d_
Definition: map_builder.h:89
int AddTrajectoryBuilder(const std::unordered_set< string > &expected_sensor_ids, const proto::TrajectoryBuilderOptions &trajectory_options)
Definition: map_builder.cc:70
std::vector< std::unique_ptr< mapping::TrajectoryBuilder > > trajectory_builders_
Definition: map_builder.h:93
mapping::SparsePoseGraph * sparse_pose_graph()
Definition: map_builder.cc:135
sensor::Collator sensor_collator_
Definition: map_builder.h:92
proto::MapBuilderOptions CreateMapBuilderOptions(common::LuaParameterDictionary *const parameter_dictionary)
Definition: map_builder.cc:38
std::unique_ptr< mapping_2d::SparsePoseGraph > sparse_pose_graph_2d_
Definition: map_builder.h:88
const proto::MapBuilderOptions options_
Definition: map_builder.h:85
mapping::TrajectoryBuilder * GetTrajectoryBuilder(int trajectory_id) const
Definition: map_builder.cc:94
void FinishTrajectory(int trajectory_id)
Definition: map_builder.cc:99
string SubmapToProto(int trajectory_id, int submap_index, proto::SubmapQuery::Response *response)
Definition: map_builder.cc:107
common::ThreadPool thread_pool_
Definition: map_builder.h:86
mapping::SparsePoseGraph * sparse_pose_graph_
Definition: map_builder.h:90
MapBuilder(const proto::MapBuilderOptions &options)
Definition: map_builder.cc:54
MapBuilder & operator=(const MapBuilder &)=delete


cartographer
Author(s):
autogenerated on Mon Jun 10 2019 12:51:39