pose_graph.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_POSE_GRAPH_H_
18 #define CARTOGRAPHER_MAPPING_POSE_GRAPH_H_
19 
20 #include <memory>
21 #include <set>
22 #include <unordered_map>
23 #include <utility>
24 #include <vector>
25 
30 #include "cartographer/mapping/proto/pose_graph.pb.h"
31 #include "cartographer/mapping/proto/pose_graph_options.pb.h"
32 #include "cartographer/mapping/proto/serialization.pb.h"
40 
41 namespace cartographer {
42 namespace mapping {
43 
44 proto::PoseGraphOptions CreatePoseGraphOptions(
45  common::LuaParameterDictionary* const parameter_dictionary);
46 
47 class PoseGraph : public PoseGraphInterface {
48  public:
53  };
54 
55  PoseGraph() {}
56  ~PoseGraph() override {}
57 
58  PoseGraph(const PoseGraph&) = delete;
59  PoseGraph& operator=(const PoseGraph&) = delete;
60 
61  // Inserts an IMU measurement.
62  virtual void AddImuData(int trajectory_id,
63  const sensor::ImuData& imu_data) = 0;
64 
65  // Inserts an odometry measurement.
66  virtual void AddOdometryData(int trajectory_id,
67  const sensor::OdometryData& odometry_data) = 0;
68 
69  // Inserts a fixed frame pose measurement.
70  virtual void AddFixedFramePoseData(
71  int trajectory_id,
72  const sensor::FixedFramePoseData& fixed_frame_pose_data) = 0;
73 
74  // Inserts landmarks observations.
75  virtual void AddLandmarkData(int trajectory_id,
76  const sensor::LandmarkData& landmark_data) = 0;
77 
78  // Finishes the given trajectory.
79  virtual void FinishTrajectory(int trajectory_id) = 0;
80 
81  // Freezes a trajectory. Poses in this trajectory will not be optimized.
82  virtual void FreezeTrajectory(int trajectory_id) = 0;
83 
84  // Adds a 'submap' from a proto with the given 'global_pose' to the
85  // appropriate trajectory.
86  virtual void AddSubmapFromProto(const transform::Rigid3d& global_pose,
87  const proto::Submap& submap) = 0;
88 
89  // Adds a 'node' from a proto with the given 'global_pose' to the
90  // appropriate trajectory.
91  virtual void AddNodeFromProto(const transform::Rigid3d& global_pose,
92  const proto::Node& node) = 0;
93 
94  // Sets the trajectory data from a proto.
95  virtual void SetTrajectoryDataFromProto(
96  const mapping::proto::TrajectoryData& data) = 0;
97 
98  // Adds information that 'node_id' was inserted into 'submap_id'. The submap
99  // has to be deserialized first.
100  virtual void AddNodeToSubmap(const NodeId& node_id,
101  const SubmapId& submap_id) = 0;
102 
103  // Adds serialized constraints. The corresponding trajectory nodes and submaps
104  // have to be deserialized before calling this function.
105  virtual void AddSerializedConstraints(
106  const std::vector<Constraint>& constraints) = 0;
107 
108  // Adds a 'trimmer'. It will be used after all data added before it has been
109  // included in the pose graph.
110  virtual void AddTrimmer(std::unique_ptr<PoseGraphTrimmer> trimmer) = 0;
111 
112  // Gets the current trajectory clusters.
113  virtual std::vector<std::vector<int>> GetConnectedTrajectories() const = 0;
114 
115  // Returns the current optimized transform and submap itself for the given
116  // 'submap_id'. Returns 'nullptr' for the 'submap' member if the submap does
117  // not exist (anymore).
118  virtual SubmapData GetSubmapData(const SubmapId& submap_id) const = 0;
119 
120  proto::PoseGraph ToProto() const override;
121 
122  // Returns the IMU data.
124 
125  // Returns the odometry data.
127 
128  // Returns the fixed frame pose data.
130  const = 0;
131 
132  // Returns the landmark data.
133  virtual std::map<std::string /* landmark ID */, PoseGraph::LandmarkNode>
134  GetLandmarkNodes() const = 0;
135 
136  // Sets a relative initial pose 'relative_pose' for 'from_trajectory_id' with
137  // respect to 'to_trajectory_id' at time 'time'.
138  virtual void SetInitialTrajectoryPose(int from_trajectory_id,
139  int to_trajectory_id,
140  const transform::Rigid3d& pose,
141  const common::Time time) = 0;
142 };
143 
144 std::vector<PoseGraph::Constraint> FromProto(
145  const ::google::protobuf::RepeatedPtrField<
146  ::cartographer::mapping::proto::PoseGraph::Constraint>&
147  constraint_protos);
148 proto::PoseGraph::Constraint ToProto(const PoseGraph::Constraint& constraint);
149 
150 } // namespace mapping
151 } // namespace cartographer
152 
153 #endif // CARTOGRAPHER_MAPPING_POSE_GRAPH_H_
PoseGraph & operator=(const PoseGraph &)=delete
PoseGraph::Constraint::Tag FromProto(const proto::PoseGraph::Constraint::Tag &proto)
Definition: pose_graph.cc:38
proto::PoseGraph ToProto() const override
Definition: pose_graph.cc:118
virtual sensor::MapByTime< sensor::ImuData > GetImuData() const =0
virtual void AddSubmapFromProto(const transform::Rigid3d &global_pose, const proto::Submap &submap)=0
virtual void AddNodeToSubmap(const NodeId &node_id, const SubmapId &submap_id)=0
virtual void AddOdometryData(int trajectory_id, const sensor::OdometryData &odometry_data)=0
virtual sensor::MapByTime< sensor::FixedFramePoseData > GetFixedFramePoseData() const =0
UniversalTimeScaleClock::time_point Time
Definition: time.h:44
virtual void SetInitialTrajectoryPose(int from_trajectory_id, int to_trajectory_id, const transform::Rigid3d &pose, const common::Time time)=0
virtual void FreezeTrajectory(int trajectory_id)=0
virtual std::vector< std::vector< int > > GetConnectedTrajectories() const =0
proto::PoseGraphOptions CreatePoseGraphOptions(common::LuaParameterDictionary *const parameter_dictionary)
Definition: pose_graph.cc:72
virtual void AddFixedFramePoseData(int trajectory_id, const sensor::FixedFramePoseData &fixed_frame_pose_data)=0
virtual void AddTrimmer(std::unique_ptr< PoseGraphTrimmer > trimmer)=0
virtual std::map< std::string, PoseGraph::LandmarkNode > GetLandmarkNodes() const =0
virtual SubmapData GetSubmapData(const SubmapId &submap_id) const =0
virtual std::vector< Constraint > constraints() const =0
virtual void AddImuData(int trajectory_id, const sensor::ImuData &imu_data)=0
virtual void AddSerializedConstraints(const std::vector< Constraint > &constraints)=0
virtual void AddLandmarkData(int trajectory_id, const sensor::LandmarkData &landmark_data)=0
virtual void AddNodeFromProto(const transform::Rigid3d &global_pose, const proto::Node &node)=0
virtual void SetTrajectoryDataFromProto(const mapping::proto::TrajectoryData &data)=0
transform::Rigid3d pose
virtual sensor::MapByTime< sensor::OdometryData > GetOdometryData() const =0
virtual void FinishTrajectory(int trajectory_id)=0


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