From 39f140da66adf879f4121360327dedc6fdb8b83e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Sch=C3=BCtte?= Date: Wed, 7 Feb 2018 16:35:44 +0100 Subject: [PATCH] Follow googlecartographer/cartographer#859 (#892) --- cartographer_grpc/handlers/load_map_handler.cc | 3 +++ cartographer_grpc/handlers/write_map_handler.cc | 3 +++ cartographer_grpc/mapping/map_builder_stub.cc | 16 +++++++++++++++- .../proto/map_builder_service.proto | 8 ++++++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/cartographer_grpc/handlers/load_map_handler.cc b/cartographer_grpc/handlers/load_map_handler.cc index 462fcdb..900156a 100644 --- a/cartographer_grpc/handlers/load_map_handler.cc +++ b/cartographer_grpc/handlers/load_map_handler.cc @@ -31,6 +31,9 @@ void LoadMapHandler::OnRequest(const proto::LoadMapRequest& request) { case proto::LoadMapRequest::kPoseGraph: reader_.AddProto(request.pose_graph()); break; + case proto::LoadMapRequest::kAllTrajectoryBuilderOptions: + reader_.AddProto(request.all_trajectory_builder_options()); + break; case proto::LoadMapRequest::kSerializedData: reader_.AddProto(request.serialized_data()); break; diff --git a/cartographer_grpc/handlers/write_map_handler.cc b/cartographer_grpc/handlers/write_map_handler.cc index d9a4d89..adcbdd5 100644 --- a/cartographer_grpc/handlers/write_map_handler.cc +++ b/cartographer_grpc/handlers/write_map_handler.cc @@ -39,6 +39,9 @@ void WriteMapHandler::OnRequest(const google::protobuf::Empty& request) { cartographer::common::make_unique(); if (proto->GetTypeName() == "cartographer.mapping.proto.PoseGraph") { response->mutable_pose_graph()->CopyFrom(*proto); + } else if (proto->GetTypeName() == + "cartographer.mapping.proto.AllTrajectoryBuilderOptions") { + response->mutable_all_trajectory_builder_options()->CopyFrom(*proto); } else if (proto->GetTypeName() == "cartographer.mapping.proto.SerializedData") { response->mutable_serialized_data()->CopyFrom(*proto); diff --git a/cartographer_grpc/mapping/map_builder_stub.cc b/cartographer_grpc/mapping/map_builder_stub.cc index f1fcc72..99d3645 100644 --- a/cartographer_grpc/mapping/map_builder_stub.cc +++ b/cartographer_grpc/mapping/map_builder_stub.cc @@ -97,7 +97,20 @@ void MapBuilderStub::SerializeState( CHECK(client.Write(request)); proto::WriteMapResponse response; while (client.Read(&response)) { - writer->WriteProto(response); + // writer->WriteProto(response); + switch (response.map_chunk_case()) { + case proto::WriteMapResponse::kPoseGraph: + writer->WriteProto(response.pose_graph()); + break; + case proto::WriteMapResponse::kAllTrajectoryBuilderOptions: + writer->WriteProto(response.all_trajectory_builder_options()); + break; + case proto::WriteMapResponse::kSerializedData: + writer->WriteProto(response.serialized_data()); + break; + default: + LOG(FATAL) << "Unhandled message type"; + } } CHECK(writer->Close()); } @@ -109,6 +122,7 @@ void MapBuilderStub::LoadMap( { proto::LoadMapRequest request; CHECK(reader->ReadProto(request.mutable_pose_graph())); + CHECK(reader->ReadProto(request.mutable_all_trajectory_builder_options())); CHECK(client.Write(request)); } // Multiple requests with SerializedData are sent after. diff --git a/cartographer_grpc/proto/map_builder_service.proto b/cartographer_grpc/proto/map_builder_service.proto index 49ead22..6c614d9 100644 --- a/cartographer_grpc/proto/map_builder_service.proto +++ b/cartographer_grpc/proto/map_builder_service.proto @@ -105,7 +105,9 @@ message GetSubmapRequest { message LoadMapRequest { oneof map_chunk { cartographer.mapping.proto.PoseGraph pose_graph = 1; - cartographer.mapping.proto.SerializedData serialized_data = 2; + cartographer.mapping.proto.AllTrajectoryBuilderOptions + all_trajectory_builder_options = 2; + cartographer.mapping.proto.SerializedData serialized_data = 3; } } @@ -163,7 +165,9 @@ message AddLocalSlamResultDataRequest { message WriteMapResponse { oneof map_chunk { cartographer.mapping.proto.PoseGraph pose_graph = 1; - cartographer.mapping.proto.SerializedData serialized_data = 2; + cartographer.mapping.proto.AllTrajectoryBuilderOptions + all_trajectory_builder_options = 2; + cartographer.mapping.proto.SerializedData serialized_data = 3; } }