Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_OPTIMIZATION_PROBLEM_3D_H_
00018 #define CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_OPTIMIZATION_PROBLEM_3D_H_
00019
00020 #include <array>
00021 #include <map>
00022 #include <set>
00023 #include <vector>
00024
00025 #include "Eigen/Core"
00026 #include "Eigen/Geometry"
00027 #include "absl/types/optional.h"
00028 #include "cartographer/common/port.h"
00029 #include "cartographer/common/time.h"
00030 #include "cartographer/mapping/id.h"
00031 #include "cartographer/mapping/internal/optimization/optimization_problem_interface.h"
00032 #include "cartographer/mapping/pose_graph_interface.h"
00033 #include "cartographer/mapping/proto/pose_graph/optimization_problem_options.pb.h"
00034 #include "cartographer/sensor/fixed_frame_pose_data.h"
00035 #include "cartographer/sensor/imu_data.h"
00036 #include "cartographer/sensor/map_by_time.h"
00037 #include "cartographer/sensor/odometry_data.h"
00038 #include "cartographer/transform/transform_interpolation_buffer.h"
00039
00040 namespace cartographer {
00041 namespace mapping {
00042 namespace optimization {
00043
00044 struct NodeSpec3D {
00045 common::Time time;
00046 transform::Rigid3d local_pose;
00047 transform::Rigid3d global_pose;
00048 };
00049
00050 struct SubmapSpec3D {
00051 transform::Rigid3d global_pose;
00052 };
00053
00054 class OptimizationProblem3D
00055 : public OptimizationProblemInterface<NodeSpec3D, SubmapSpec3D,
00056 transform::Rigid3d> {
00057 public:
00058 explicit OptimizationProblem3D(
00059 const optimization::proto::OptimizationProblemOptions& options);
00060 ~OptimizationProblem3D();
00061
00062 OptimizationProblem3D(const OptimizationProblem3D&) = delete;
00063 OptimizationProblem3D& operator=(const OptimizationProblem3D&) = delete;
00064
00065 void AddImuData(int trajectory_id, const sensor::ImuData& imu_data) override;
00066 void AddOdometryData(int trajectory_id,
00067 const sensor::OdometryData& odometry_data) override;
00068 void AddTrajectoryNode(int trajectory_id,
00069 const NodeSpec3D& node_data) override;
00070 void InsertTrajectoryNode(const NodeId& node_id,
00071 const NodeSpec3D& node_data) override;
00072 void TrimTrajectoryNode(const NodeId& node_id) override;
00073 void AddSubmap(int trajectory_id,
00074 const transform::Rigid3d& global_submap_pose) override;
00075 void InsertSubmap(const SubmapId& submap_id,
00076 const transform::Rigid3d& global_submap_pose) override;
00077 void TrimSubmap(const SubmapId& submap_id) override;
00078 void SetMaxNumIterations(int32 max_num_iterations) override;
00079
00080 void Solve(
00081 const std::vector<Constraint>& constraints,
00082 const std::map<int, PoseGraphInterface::TrajectoryState>&
00083 trajectories_state,
00084 const std::map<std::string, LandmarkNode>& landmark_nodes) override;
00085
00086 const MapById<NodeId, NodeSpec3D>& node_data() const override {
00087 return node_data_;
00088 }
00089 const MapById<SubmapId, SubmapSpec3D>& submap_data() const override {
00090 return submap_data_;
00091 }
00092 const std::map<std::string, transform::Rigid3d>& landmark_data()
00093 const override {
00094 return landmark_data_;
00095 }
00096 const sensor::MapByTime<sensor::ImuData>& imu_data() const override {
00097 return imu_data_;
00098 }
00099 const sensor::MapByTime<sensor::OdometryData>& odometry_data()
00100 const override {
00101 return odometry_data_;
00102 }
00103
00104 void AddFixedFramePoseData(
00105 int trajectory_id,
00106 const sensor::FixedFramePoseData& fixed_frame_pose_data);
00107 void SetTrajectoryData(
00108 int trajectory_id,
00109 const PoseGraphInterface::TrajectoryData& trajectory_data);
00110 const sensor::MapByTime<sensor::FixedFramePoseData>& fixed_frame_pose_data()
00111 const {
00112 return fixed_frame_pose_data_;
00113 }
00114 const std::map<int, PoseGraphInterface::TrajectoryData>& trajectory_data()
00115 const {
00116 return trajectory_data_;
00117 }
00118
00119 private:
00120
00121 std::unique_ptr<transform::Rigid3d> CalculateOdometryBetweenNodes(
00122 int trajectory_id, const NodeSpec3D& first_node_data,
00123 const NodeSpec3D& second_node_data) const;
00124
00125 optimization::proto::OptimizationProblemOptions options_;
00126 MapById<NodeId, NodeSpec3D> node_data_;
00127 MapById<SubmapId, SubmapSpec3D> submap_data_;
00128 std::map<std::string, transform::Rigid3d> landmark_data_;
00129 sensor::MapByTime<sensor::ImuData> imu_data_;
00130 sensor::MapByTime<sensor::OdometryData> odometry_data_;
00131 sensor::MapByTime<sensor::FixedFramePoseData> fixed_frame_pose_data_;
00132 std::map<int, PoseGraphInterface::TrajectoryData> trajectory_data_;
00133 };
00134
00135 }
00136 }
00137 }
00138
00139 #endif // CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_OPTIMIZATION_PROBLEM_3D_H_