optimization_problem_2d.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_OPTIMIZATION_PROBLEM_2D_H_
00018 #define CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_OPTIMIZATION_PROBLEM_2D_H_
00019 
00020 #include <array>
00021 #include <deque>
00022 #include <map>
00023 #include <set>
00024 #include <vector>
00025 
00026 #include "Eigen/Core"
00027 #include "Eigen/Geometry"
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/imu_data.h"
00035 #include "cartographer/sensor/map_by_time.h"
00036 #include "cartographer/sensor/odometry_data.h"
00037 #include "cartographer/transform/timestamped_transform.h"
00038 
00039 namespace cartographer {
00040 namespace mapping {
00041 namespace optimization {
00042 
00043 struct NodeSpec2D {
00044   common::Time time;
00045   transform::Rigid2d local_pose_2d;
00046   transform::Rigid2d global_pose_2d;
00047   Eigen::Quaterniond gravity_alignment;
00048 };
00049 
00050 struct SubmapSpec2D {
00051   transform::Rigid2d global_pose;
00052 };
00053 
00054 class OptimizationProblem2D
00055     : public OptimizationProblemInterface<NodeSpec2D, SubmapSpec2D,
00056                                           transform::Rigid2d> {
00057  public:
00058   explicit OptimizationProblem2D(
00059       const optimization::proto::OptimizationProblemOptions& options);
00060   ~OptimizationProblem2D();
00061 
00062   OptimizationProblem2D(const OptimizationProblem2D&) = delete;
00063   OptimizationProblem2D& operator=(const OptimizationProblem2D&) = 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 NodeSpec2D& node_data) override;
00070   void InsertTrajectoryNode(const NodeId& node_id,
00071                             const NodeSpec2D& node_data) override;
00072   void TrimTrajectoryNode(const NodeId& node_id) override;
00073   void AddSubmap(int trajectory_id,
00074                  const transform::Rigid2d& global_submap_pose) override;
00075   void InsertSubmap(const SubmapId& submap_id,
00076                     const transform::Rigid2d& 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, NodeSpec2D>& node_data() const override {
00087     return node_data_;
00088   }
00089   const MapById<SubmapId, SubmapSpec2D>& 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  private:
00105   std::unique_ptr<transform::Rigid3d> InterpolateOdometry(
00106       int trajectory_id, common::Time time) const;
00107   // Computes the relative pose between two nodes based on odometry data.
00108   std::unique_ptr<transform::Rigid3d> CalculateOdometryBetweenNodes(
00109       int trajectory_id, const NodeSpec2D& first_node_data,
00110       const NodeSpec2D& second_node_data) const;
00111 
00112   optimization::proto::OptimizationProblemOptions options_;
00113   MapById<NodeId, NodeSpec2D> node_data_;
00114   MapById<SubmapId, SubmapSpec2D> submap_data_;
00115   std::map<std::string, transform::Rigid3d> landmark_data_;
00116   sensor::MapByTime<sensor::ImuData> imu_data_;
00117   sensor::MapByTime<sensor::OdometryData> odometry_data_;
00118 };
00119 
00120 }  // namespace optimization
00121 }  // namespace mapping
00122 }  // namespace cartographer
00123 
00124 #endif  // CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_OPTIMIZATION_PROBLEM_2D_H_


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35