From 20a980aade4d4e0c4d60d6f0e2b593b1db4d645d Mon Sep 17 00:00:00 2001 From: Alexander Belyaev <32522095+pifon2a@users.noreply.github.com> Date: Thu, 8 Mar 2018 13:09:43 +0100 Subject: [PATCH] Remove 'pose_graph_*d.h' from local_slam_result_data.h. (#965) --- .../mapping/local_slam_result_data.cc | 32 ++++--------------- cartographer/mapping/local_slam_result_data.h | 18 ++++++++--- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/cartographer/mapping/local_slam_result_data.cc b/cartographer/mapping/local_slam_result_data.cc index 6fcea8e..17ecd8d 100644 --- a/cartographer/mapping/local_slam_result_data.cc +++ b/cartographer/mapping/local_slam_result_data.cc @@ -15,54 +15,34 @@ */ #include "local_slam_result_data.h" +#include "cartographer/mapping/2d/pose_graph_2d.h" +#include "cartographer/mapping/3d/pose_graph_3d.h" #include "cartographer/mapping/trajectory_builder_interface.h" namespace cartographer { namespace mapping { -LocalSlamResultData::LocalSlamResultData(const std::string& sensor_id, - common::Time time) - : Data(sensor_id), time_(time) {} - -LocalSlamResult2D::LocalSlamResult2D( - const std::string& sensor_id, common::Time time, - std::shared_ptr node_data, - const std::vector>& - insertion_submaps) - : LocalSlamResultData(sensor_id, time), - node_data_(node_data), - insertion_submaps_(insertion_submaps) {} - void LocalSlamResult2D::AddToTrajectoryBuilder( - mapping::TrajectoryBuilderInterface* const trajectory_builder) { + TrajectoryBuilderInterface* const trajectory_builder) { trajectory_builder->AddLocalSlamResultData( common::make_unique(*this)); } void LocalSlamResult2D::AddToPoseGraph(int trajectory_id, - mapping::PoseGraph* pose_graph) const { + PoseGraph* pose_graph) const { DCHECK(dynamic_cast(pose_graph)); PoseGraph2D* pose_graph_2d = static_cast(pose_graph); pose_graph_2d->AddNode(node_data_, trajectory_id, insertion_submaps_); } -LocalSlamResult3D::LocalSlamResult3D( - const std::string& sensor_id, common::Time time, - std::shared_ptr node_data, - const std::vector>& - insertion_submaps) - : LocalSlamResultData(sensor_id, time), - node_data_(node_data), - insertion_submaps_(insertion_submaps) {} - void LocalSlamResult3D::AddToTrajectoryBuilder( - mapping::TrajectoryBuilderInterface* const trajectory_builder) { + TrajectoryBuilderInterface* const trajectory_builder) { trajectory_builder->AddLocalSlamResultData( common::make_unique(*this)); } void LocalSlamResult3D::AddToPoseGraph(int trajectory_id, - mapping::PoseGraph* pose_graph) const { + PoseGraph* pose_graph) const { DCHECK(dynamic_cast(pose_graph)); PoseGraph3D* pose_graph_3d = static_cast(pose_graph); pose_graph_3d->AddNode(node_data_, trajectory_id, insertion_submaps_); diff --git a/cartographer/mapping/local_slam_result_data.h b/cartographer/mapping/local_slam_result_data.h index fa89ead..1397511 100644 --- a/cartographer/mapping/local_slam_result_data.h +++ b/cartographer/mapping/local_slam_result_data.h @@ -17,8 +17,9 @@ #ifndef CARTOGRAPHER_MAPPING_LOCAL_SLAM_RESULT_DATA_H #define CARTOGRAPHER_MAPPING_LOCAL_SLAM_RESULT_DATA_H -#include "cartographer/mapping/2d/pose_graph_2d.h" -#include "cartographer/mapping/3d/pose_graph_3d.h" +#include "cartographer/mapping/2d/submap_2d.h" +#include "cartographer/mapping/3d/submap_3d.h" +#include "cartographer/mapping/pose_graph.h" #include "cartographer/sensor/data.h" namespace cartographer { @@ -27,7 +28,8 @@ namespace mapping { class TrajectoryBuilderInterface; class LocalSlamResultData : public cartographer::sensor::Data { public: - LocalSlamResultData(const std::string& sensor_id, common::Time time); + LocalSlamResultData(const std::string& sensor_id, common::Time time) + : Data(sensor_id), time_(time) {} common::Time GetTime() const override { return time_; } virtual void AddToPoseGraph(int trajectory_id, @@ -42,7 +44,10 @@ class LocalSlamResult2D : public LocalSlamResultData { LocalSlamResult2D( const std::string& sensor_id, common::Time time, std::shared_ptr node_data, - const std::vector>& insertion_submaps); + const std::vector>& insertion_submaps) + : LocalSlamResultData(sensor_id, time), + node_data_(node_data), + insertion_submaps_(insertion_submaps) {} void AddToTrajectoryBuilder( TrajectoryBuilderInterface* const trajectory_builder) override; @@ -58,7 +63,10 @@ class LocalSlamResult3D : public LocalSlamResultData { LocalSlamResult3D( const std::string& sensor_id, common::Time time, std::shared_ptr node_data, - const std::vector>& insertion_submaps); + const std::vector>& insertion_submaps) + : LocalSlamResultData(sensor_id, time), + node_data_(node_data), + insertion_submaps_(insertion_submaps) {} void AddToTrajectoryBuilder( TrajectoryBuilderInterface* const trajectory_builder) override;