From ccc25862bfe9a701e4a2d134581d049b4b4b3c96 Mon Sep 17 00:00:00 2001 From: Alexander Belyaev <32522095+pifon2a@users.noreply.github.com> Date: Wed, 10 Oct 2018 13:38:58 +0200 Subject: [PATCH] [GenericPoseGraph] Add a helper func to add PoseGraphData. (#1443) --- cartographer/pose_graph/pose_graph_controller.cc | 10 ++++++++++ cartographer/pose_graph/pose_graph_controller.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/cartographer/pose_graph/pose_graph_controller.cc b/cartographer/pose_graph/pose_graph_controller.cc index bdd56d9..5a7aa2c 100644 --- a/cartographer/pose_graph/pose_graph_controller.cc +++ b/cartographer/pose_graph/pose_graph_controller.cc @@ -19,6 +19,16 @@ namespace cartographer { namespace pose_graph { +void PoseGraphController::AddData(const proto::PoseGraphData& data) { + absl::MutexLock locker(&mutex_); + for (const auto& node : data.nodes()) { + AddNodeToPoseGraphData(node, &data_); + } + for (const auto& constraint : data.constraints()) { + AddConstraintToPoseGraphData(constraint, &data_); + } +} + void PoseGraphController::AddNode(const proto::Node& node) { absl::MutexLock locker(&mutex_); AddNodeToPoseGraphData(node, &data_); diff --git a/cartographer/pose_graph/pose_graph_controller.h b/cartographer/pose_graph/pose_graph_controller.h index e72cc31..3c915ed 100644 --- a/cartographer/pose_graph/pose_graph_controller.h +++ b/cartographer/pose_graph/pose_graph_controller.h @@ -19,6 +19,7 @@ #include "absl/synchronization/mutex.h" #include "cartographer/pose_graph/pose_graph_data.h" +#include "cartographer/pose_graph/proto/pose_graph_data.pb.h" #include "cartographer/pose_graph/solver/solver.h" namespace cartographer { @@ -32,6 +33,7 @@ class PoseGraphController { PoseGraphController(const PoseGraphController&) = delete; PoseGraphController& operator=(const PoseGraphController&) = delete; + void AddData(const proto::PoseGraphData& data) LOCKS_EXCLUDED(mutex_); void AddNode(const proto::Node& node) LOCKS_EXCLUDED(mutex_); void AddConstraint(const proto::Constraint& constraint) LOCKS_EXCLUDED(mutex_);