Fix writing state of trajectories with unfinished submaps. (#1286)
parent
482f912d95
commit
0ee06ba561
|
@ -88,8 +88,10 @@ void SerializeSubmaps(
|
||||||
submap_id_data.id.trajectory_id);
|
submap_id_data.id.trajectory_id);
|
||||||
submap_proto->mutable_submap_id()->set_submap_index(
|
submap_proto->mutable_submap_id()->set_submap_index(
|
||||||
submap_id_data.id.submap_index);
|
submap_id_data.id.submap_index);
|
||||||
submap_id_data.data.submap->ToProto(submap_proto,
|
submap_id_data.data.submap->ToProto(
|
||||||
/*include_probability_grid_data=*/true);
|
submap_proto,
|
||||||
|
/*include_probability_grid_data=*/submap_id_data.data.submap
|
||||||
|
->finished());
|
||||||
writer->WriteProto(proto);
|
writer->WriteProto(proto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -560,8 +560,11 @@ void PoseGraph2D::AddSubmapFromProto(
|
||||||
// Immediately show the submap at the 'global_submap_pose'.
|
// Immediately show the submap at the 'global_submap_pose'.
|
||||||
data_.global_submap_poses_2d.Insert(
|
data_.global_submap_poses_2d.Insert(
|
||||||
submap_id, optimization::SubmapSpec2D{global_submap_pose_2d});
|
submap_id, optimization::SubmapSpec2D{global_submap_pose_2d});
|
||||||
AddWorkItem([this, submap_id, global_submap_pose_2d]() REQUIRES(mutex_) {
|
bool finished = submap.submap_2d().finished();
|
||||||
data_.submap_data.at(submap_id).state = SubmapState::kFinished;
|
AddWorkItem(
|
||||||
|
[this, submap_id, global_submap_pose_2d, finished]() REQUIRES(mutex_) {
|
||||||
|
data_.submap_data.at(submap_id).state =
|
||||||
|
finished ? SubmapState::kFinished : SubmapState::kActive;
|
||||||
optimization_problem_->InsertSubmap(submap_id, global_submap_pose_2d);
|
optimization_problem_->InsertSubmap(submap_id, global_submap_pose_2d);
|
||||||
return WorkItem::Result::kDoNotRunOptimization;
|
return WorkItem::Result::kDoNotRunOptimization;
|
||||||
});
|
});
|
||||||
|
|
|
@ -650,9 +650,12 @@ void PoseGraph3D::AddSubmapFromProto(
|
||||||
data_.global_submap_poses_3d.Insert(
|
data_.global_submap_poses_3d.Insert(
|
||||||
submap_id, optimization::SubmapSpec3D{global_submap_pose});
|
submap_id, optimization::SubmapSpec3D{global_submap_pose});
|
||||||
}
|
}
|
||||||
AddWorkItem([this, submap_id, global_submap_pose]() EXCLUDES(mutex_) {
|
bool finished = submap.submap_3d().finished();
|
||||||
|
AddWorkItem(
|
||||||
|
[this, submap_id, global_submap_pose, finished]() EXCLUDES(mutex_) {
|
||||||
common::MutexLocker locker(&mutex_);
|
common::MutexLocker locker(&mutex_);
|
||||||
data_.submap_data.at(submap_id).state = SubmapState::kFinished;
|
data_.submap_data.at(submap_id).state =
|
||||||
|
finished ? SubmapState::kFinished : SubmapState::kActive;
|
||||||
optimization_problem_->InsertSubmap(submap_id, global_submap_pose);
|
optimization_problem_->InsertSubmap(submap_id, global_submap_pose);
|
||||||
return WorkItem::Result::kDoNotRunOptimization;
|
return WorkItem::Result::kDoNotRunOptimization;
|
||||||
});
|
});
|
||||||
|
|
|
@ -85,6 +85,7 @@ proto::Submap CreateFakeSubmap3D(int trajectory_id, int submap_index) {
|
||||||
proto.mutable_submap_3d()->set_num_range_data(1);
|
proto.mutable_submap_3d()->set_num_range_data(1);
|
||||||
*proto.mutable_submap_3d()->mutable_local_pose() =
|
*proto.mutable_submap_3d()->mutable_local_pose() =
|
||||||
transform::ToProto(transform::Rigid3d::Identity());
|
transform::ToProto(transform::Rigid3d::Identity());
|
||||||
|
proto.mutable_submap_3d()->set_finished(true);
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -417,7 +417,7 @@ TEST_F(MapBuilderTest, LocalizationOnFrozenTrajectory2D) {
|
||||||
++num_cross_trajectory_constraints;
|
++num_cross_trajectory_constraints;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXPECT_GT(num_cross_trajectory_constraints, 3);
|
EXPECT_EQ(num_cross_trajectory_constraints, 3);
|
||||||
// TODO(gaschler): Subscribe global slam callback, verify that all nodes are
|
// TODO(gaschler): Subscribe global slam callback, verify that all nodes are
|
||||||
// optimized.
|
// optimized.
|
||||||
EXPECT_THAT(constraints, ::testing::Contains(::testing::Field(
|
EXPECT_THAT(constraints, ::testing::Contains(::testing::Field(
|
||||||
|
|
Loading…
Reference in New Issue