Deactivate memory-critical histogram backwards compatibility. (#1710)

It's essentially leading to buffering all submaps twice, which
is a high (~2x) peak in memory consumption during deserialization.

Don't convert anymore since this affects _all_ pbstreams and not only
the (probably few) old pbstreams that require the conversion.

Signed-off-by: Michael Grupp <grupp@magazino.eu>
master
Michael Grupp 2020-08-17 19:34:35 +02:00 committed by GitHub
parent 19a6eab07a
commit 9b405c3dc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 22 deletions

View File

@ -55,7 +55,7 @@ constexpr double kDuration = 4.; // Seconds.
constexpr double kTimeStep = 0.1; // Seconds. constexpr double kTimeStep = 0.1; // Seconds.
constexpr double kTravelDistance = 1.2; // Meters. constexpr double kTravelDistance = 1.2; // Meters.
constexpr char kSerializationHeaderProtoString[] = "format_version: 1"; constexpr char kSerializationHeaderProtoString[] = "format_version: 2";
constexpr char kPoseGraphProtoString[] = R"(pose_graph { constexpr char kPoseGraphProtoString[] = R"(pose_graph {
trajectory: { trajectory: {
trajectory_id: 0 trajectory_id: 0

View File

@ -285,8 +285,14 @@ std::map<int, int> MapBuilder::LoadState(
true); true);
} }
MapById<SubmapId, mapping::proto::Submap> submap_id_to_submap; if (options_.use_trajectory_builder_3d()) {
MapById<NodeId, mapping::proto::Node> node_id_to_node; CHECK_NE(deserializer.header().format_version(),
io::kFormatVersionWithoutSubmapHistograms)
<< "The pbstream file contains submaps without rotational histograms. "
"This can be converted with the 'pbstream migrate' tool, see the "
"Cartographer documentation for details. ";
}
SerializedData proto; SerializedData proto;
while (deserializer.ReadNextSerializedData(&proto)) { while (deserializer.ReadNextSerializedData(&proto)) {
switch (proto.data_case()) { switch (proto.data_case()) {
@ -303,9 +309,9 @@ std::map<int, int> MapBuilder::LoadState(
proto.mutable_submap()->mutable_submap_id()->set_trajectory_id( proto.mutable_submap()->mutable_submap_id()->set_trajectory_id(
trajectory_remapping.at( trajectory_remapping.at(
proto.submap().submap_id().trajectory_id())); proto.submap().submap_id().trajectory_id()));
submap_id_to_submap.Insert( const SubmapId submap_id(proto.submap().submap_id().trajectory_id(),
SubmapId{proto.submap().submap_id().trajectory_id(), proto.submap().submap_id().submap_index());
proto.submap().submap_id().submap_index()}, pose_graph_->AddSubmapFromProto(submap_poses.at(submap_id),
proto.submap()); proto.submap());
break; break;
} }
@ -316,7 +322,6 @@ std::map<int, int> MapBuilder::LoadState(
proto.node().node_id().node_index()); proto.node().node_id().node_index());
const transform::Rigid3d& node_pose = node_poses.at(node_id); const transform::Rigid3d& node_pose = node_poses.at(node_id);
pose_graph_->AddNodeFromProto(node_pose, proto.node()); pose_graph_->AddNodeFromProto(node_pose, proto.node());
node_id_to_node.Insert(node_id, proto.node());
break; break;
} }
case SerializedData::kTrajectoryData: { case SerializedData::kTrajectoryData: {
@ -361,20 +366,6 @@ std::map<int, int> MapBuilder::LoadState(
} }
} }
// TODO(schwoere): Remove backwards compatibility once the pbstream format
// version 2 is established.
if (deserializer.header().format_version() ==
io::kFormatVersionWithoutSubmapHistograms) {
submap_id_to_submap =
cartographer::io::MigrateSubmapFormatVersion1ToVersion2(
submap_id_to_submap, node_id_to_node, pose_graph_proto);
}
for (const auto& submap_id_submap : submap_id_to_submap) {
pose_graph_->AddSubmapFromProto(submap_poses.at(submap_id_submap.id),
submap_id_submap.data);
}
if (load_frozen_state) { if (load_frozen_state) {
// Add information about which nodes belong to which submap. // Add information about which nodes belong to which submap.
// Required for 3D pure localization. // Required for 3D pure localization.