From b383f183653ec80328ef7d46e86456010e416682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Sch=C3=BCtte?= Date: Tue, 12 Sep 2017 17:04:13 +0200 Subject: [PATCH] Fix crash in localization. (#523) This PR fixes a crash when cartographer is run in localization mode due to the map trajectory not having been properly added to the ConnectedComponents. --- cartographer/mapping_2d/sparse_pose_graph.cc | 2 ++ cartographer/mapping_3d/sparse_pose_graph.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cartographer/mapping_2d/sparse_pose_graph.cc b/cartographer/mapping_2d/sparse_pose_graph.cc index 32af168..f462557 100644 --- a/cartographer/mapping_2d/sparse_pose_graph.cc +++ b/cartographer/mapping_2d/sparse_pose_graph.cc @@ -378,6 +378,7 @@ void SparsePoseGraph::WaitForAllComputations() { void SparsePoseGraph::FreezeTrajectory(const int trajectory_id) { common::MutexLocker locker(&mutex_); + trajectory_connectivity_state_.Add(trajectory_id); AddWorkItem([this, trajectory_id]() REQUIRES(mutex_) { CHECK_EQ(frozen_trajectories_.count(trajectory_id), 0); frozen_trajectories_.insert(trajectory_id); @@ -396,6 +397,7 @@ void SparsePoseGraph::AddSubmapFromProto(const int trajectory_id, const transform::Rigid2d initial_pose_2d = transform::Project2D(initial_pose); common::MutexLocker locker(&mutex_); + trajectory_connectivity_state_.Add(trajectory_id); const mapping::SubmapId submap_id = submap_data_.Append(trajectory_id, SubmapData()); submap_data_.at(submap_id).submap = submap_ptr; diff --git a/cartographer/mapping_3d/sparse_pose_graph.cc b/cartographer/mapping_3d/sparse_pose_graph.cc index dbecef8..1a0e5f0 100644 --- a/cartographer/mapping_3d/sparse_pose_graph.cc +++ b/cartographer/mapping_3d/sparse_pose_graph.cc @@ -400,6 +400,7 @@ void SparsePoseGraph::WaitForAllComputations() { void SparsePoseGraph::FreezeTrajectory(const int trajectory_id) { common::MutexLocker locker(&mutex_); + trajectory_connectivity_state_.Add(trajectory_id); AddWorkItem([this, trajectory_id]() REQUIRES(mutex_) { CHECK_EQ(frozen_trajectories_.count(trajectory_id), 0); frozen_trajectories_.insert(trajectory_id); @@ -417,6 +418,7 @@ void SparsePoseGraph::AddSubmapFromProto(const int trajectory_id, std::make_shared(submap.submap_3d()); common::MutexLocker locker(&mutex_); + trajectory_connectivity_state_.Add(trajectory_id); const mapping::SubmapId submap_id = submap_data_.Append(trajectory_id, SubmapData()); submap_data_.at(submap_id).submap = submap_ptr;