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,11 +560,14 @@ 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(
|
||||||
optimization_problem_->InsertSubmap(submap_id, global_submap_pose_2d);
|
[this, submap_id, global_submap_pose_2d, finished]() REQUIRES(mutex_) {
|
||||||
return WorkItem::Result::kDoNotRunOptimization;
|
data_.submap_data.at(submap_id).state =
|
||||||
});
|
finished ? SubmapState::kFinished : SubmapState::kActive;
|
||||||
|
optimization_problem_->InsertSubmap(submap_id, global_submap_pose_2d);
|
||||||
|
return WorkItem::Result::kDoNotRunOptimization;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoseGraph2D::AddNodeFromProto(const transform::Rigid3d& global_pose,
|
void PoseGraph2D::AddNodeFromProto(const transform::Rigid3d& global_pose,
|
||||||
|
|
|
@ -650,12 +650,15 @@ 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();
|
||||||
common::MutexLocker locker(&mutex_);
|
AddWorkItem(
|
||||||
data_.submap_data.at(submap_id).state = SubmapState::kFinished;
|
[this, submap_id, global_submap_pose, finished]() EXCLUDES(mutex_) {
|
||||||
optimization_problem_->InsertSubmap(submap_id, global_submap_pose);
|
common::MutexLocker locker(&mutex_);
|
||||||
return WorkItem::Result::kDoNotRunOptimization;
|
data_.submap_data.at(submap_id).state =
|
||||||
});
|
finished ? SubmapState::kFinished : SubmapState::kActive;
|
||||||
|
optimization_problem_->InsertSubmap(submap_id, global_submap_pose);
|
||||||
|
return WorkItem::Result::kDoNotRunOptimization;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoseGraph3D::AddNodeFromProto(const transform::Rigid3d& global_pose,
|
void PoseGraph3D::AddNodeFromProto(const transform::Rigid3d& global_pose,
|
||||||
|
|
|
@ -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