Remove 'pose_graph_*d.h' from local_slam_result_data.h. (#965)

master
Alexander Belyaev 2018-03-08 13:09:43 +01:00 committed by GitHub
parent 256b5a6ff0
commit 20a980aade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 31 deletions

View File

@ -15,54 +15,34 @@
*/ */
#include "local_slam_result_data.h" #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" #include "cartographer/mapping/trajectory_builder_interface.h"
namespace cartographer { namespace cartographer {
namespace mapping { 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<const mapping::TrajectoryNode::Data> node_data,
const std::vector<std::shared_ptr<const mapping::Submap2D>>&
insertion_submaps)
: LocalSlamResultData(sensor_id, time),
node_data_(node_data),
insertion_submaps_(insertion_submaps) {}
void LocalSlamResult2D::AddToTrajectoryBuilder( void LocalSlamResult2D::AddToTrajectoryBuilder(
mapping::TrajectoryBuilderInterface* const trajectory_builder) { TrajectoryBuilderInterface* const trajectory_builder) {
trajectory_builder->AddLocalSlamResultData( trajectory_builder->AddLocalSlamResultData(
common::make_unique<LocalSlamResult2D>(*this)); common::make_unique<LocalSlamResult2D>(*this));
} }
void LocalSlamResult2D::AddToPoseGraph(int trajectory_id, void LocalSlamResult2D::AddToPoseGraph(int trajectory_id,
mapping::PoseGraph* pose_graph) const { PoseGraph* pose_graph) const {
DCHECK(dynamic_cast<PoseGraph2D*>(pose_graph)); DCHECK(dynamic_cast<PoseGraph2D*>(pose_graph));
PoseGraph2D* pose_graph_2d = static_cast<PoseGraph2D*>(pose_graph); PoseGraph2D* pose_graph_2d = static_cast<PoseGraph2D*>(pose_graph);
pose_graph_2d->AddNode(node_data_, trajectory_id, insertion_submaps_); pose_graph_2d->AddNode(node_data_, trajectory_id, insertion_submaps_);
} }
LocalSlamResult3D::LocalSlamResult3D(
const std::string& sensor_id, common::Time time,
std::shared_ptr<const mapping::TrajectoryNode::Data> node_data,
const std::vector<std::shared_ptr<const mapping::Submap3D>>&
insertion_submaps)
: LocalSlamResultData(sensor_id, time),
node_data_(node_data),
insertion_submaps_(insertion_submaps) {}
void LocalSlamResult3D::AddToTrajectoryBuilder( void LocalSlamResult3D::AddToTrajectoryBuilder(
mapping::TrajectoryBuilderInterface* const trajectory_builder) { TrajectoryBuilderInterface* const trajectory_builder) {
trajectory_builder->AddLocalSlamResultData( trajectory_builder->AddLocalSlamResultData(
common::make_unique<LocalSlamResult3D>(*this)); common::make_unique<LocalSlamResult3D>(*this));
} }
void LocalSlamResult3D::AddToPoseGraph(int trajectory_id, void LocalSlamResult3D::AddToPoseGraph(int trajectory_id,
mapping::PoseGraph* pose_graph) const { PoseGraph* pose_graph) const {
DCHECK(dynamic_cast<PoseGraph3D*>(pose_graph)); DCHECK(dynamic_cast<PoseGraph3D*>(pose_graph));
PoseGraph3D* pose_graph_3d = static_cast<PoseGraph3D*>(pose_graph); PoseGraph3D* pose_graph_3d = static_cast<PoseGraph3D*>(pose_graph);
pose_graph_3d->AddNode(node_data_, trajectory_id, insertion_submaps_); pose_graph_3d->AddNode(node_data_, trajectory_id, insertion_submaps_);

View File

@ -17,8 +17,9 @@
#ifndef CARTOGRAPHER_MAPPING_LOCAL_SLAM_RESULT_DATA_H #ifndef CARTOGRAPHER_MAPPING_LOCAL_SLAM_RESULT_DATA_H
#define 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/2d/submap_2d.h"
#include "cartographer/mapping/3d/pose_graph_3d.h" #include "cartographer/mapping/3d/submap_3d.h"
#include "cartographer/mapping/pose_graph.h"
#include "cartographer/sensor/data.h" #include "cartographer/sensor/data.h"
namespace cartographer { namespace cartographer {
@ -27,7 +28,8 @@ namespace mapping {
class TrajectoryBuilderInterface; class TrajectoryBuilderInterface;
class LocalSlamResultData : public cartographer::sensor::Data { class LocalSlamResultData : public cartographer::sensor::Data {
public: 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_; } common::Time GetTime() const override { return time_; }
virtual void AddToPoseGraph(int trajectory_id, virtual void AddToPoseGraph(int trajectory_id,
@ -42,7 +44,10 @@ class LocalSlamResult2D : public LocalSlamResultData {
LocalSlamResult2D( LocalSlamResult2D(
const std::string& sensor_id, common::Time time, const std::string& sensor_id, common::Time time,
std::shared_ptr<const TrajectoryNode::Data> node_data, std::shared_ptr<const TrajectoryNode::Data> node_data,
const std::vector<std::shared_ptr<const Submap2D>>& insertion_submaps); const std::vector<std::shared_ptr<const Submap2D>>& insertion_submaps)
: LocalSlamResultData(sensor_id, time),
node_data_(node_data),
insertion_submaps_(insertion_submaps) {}
void AddToTrajectoryBuilder( void AddToTrajectoryBuilder(
TrajectoryBuilderInterface* const trajectory_builder) override; TrajectoryBuilderInterface* const trajectory_builder) override;
@ -58,7 +63,10 @@ class LocalSlamResult3D : public LocalSlamResultData {
LocalSlamResult3D( LocalSlamResult3D(
const std::string& sensor_id, common::Time time, const std::string& sensor_id, common::Time time,
std::shared_ptr<const TrajectoryNode::Data> node_data, std::shared_ptr<const TrajectoryNode::Data> node_data,
const std::vector<std::shared_ptr<const Submap3D>>& insertion_submaps); const std::vector<std::shared_ptr<const Submap3D>>& insertion_submaps)
: LocalSlamResultData(sensor_id, time),
node_data_(node_data),
insertion_submaps_(insertion_submaps) {}
void AddToTrajectoryBuilder( void AddToTrajectoryBuilder(
TrajectoryBuilderInterface* const trajectory_builder) override; TrajectoryBuilderInterface* const trajectory_builder) override;