From f83ba3db2f336c147500e6874cebaaf6252e8711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Sch=C3=BCtte?= Date: Mon, 4 Jun 2018 11:11:28 +0200 Subject: [PATCH] Fix LoadState gRPC (#1179) --- cartographer/cloud/client/map_builder_stub.cc | 16 ++++++++++++---- cartographer/cloud/client/map_builder_stub.h | 1 + .../internal/handlers/load_state_handler.cc | 10 ++++------ .../cloud/proto/map_builder_service.proto | 6 ++---- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/cartographer/cloud/client/map_builder_stub.cc b/cartographer/cloud/client/map_builder_stub.cc index c3c4e43..0690cc1 100644 --- a/cartographer/cloud/client/map_builder_stub.cc +++ b/cartographer/cloud/client/map_builder_stub.cc @@ -132,16 +132,24 @@ void MapBuilderStub::LoadState(io::ProtoStreamReaderInterface* reader, async_grpc::Client client(client_channel_); io::ProtoStreamDeserializer deserializer(reader); - // Request with a PoseGraph proto is sent first. + // Request with the SerializationHeader proto is sent first. { proto::LoadStateRequest request; - *request.mutable_pose_graph() = deserializer.pose_graph(); + *request.mutable_serialization_header() = deserializer.header(); CHECK(client.Write(request)); } - // Request with an AllTrajectoryBuilderOptions should be second. + // Request with a PoseGraph proto is sent second. { proto::LoadStateRequest request; - *request.mutable_all_trajectory_builder_options() = + *request.mutable_serialized_data()->mutable_pose_graph() = + deserializer.pose_graph(); + CHECK(client.Write(request)); + } + // Request with an AllTrajectoryBuilderOptions should be third. + { + proto::LoadStateRequest request; + *request.mutable_serialized_data() + ->mutable_all_trajectory_builder_options() = deserializer.all_trajectory_builder_options(); CHECK(client.Write(request)); } diff --git a/cartographer/cloud/client/map_builder_stub.h b/cartographer/cloud/client/map_builder_stub.h index 1aea0de..d102cef 100644 --- a/cartographer/cloud/client/map_builder_stub.h +++ b/cartographer/cloud/client/map_builder_stub.h @@ -56,6 +56,7 @@ class MapBuilderStub : public mapping::MapBuilderInterface { GetAllTrajectoryBuilderOptions() const override; private: + ::grpc::ChannelArguments channel_arguments_; std::shared_ptr<::grpc::Channel> client_channel_; std::unique_ptr pose_graph_stub_; std::map> diff --git a/cartographer/cloud/internal/handlers/load_state_handler.cc b/cartographer/cloud/internal/handlers/load_state_handler.cc index 1a3de1e..c087aae 100644 --- a/cartographer/cloud/internal/handlers/load_state_handler.cc +++ b/cartographer/cloud/internal/handlers/load_state_handler.cc @@ -28,21 +28,19 @@ namespace handlers { void LoadStateHandler::OnRequest(const proto::LoadStateRequest& request) { switch (request.state_chunk_case()) { - case proto::LoadStateRequest::kPoseGraph: - reader_.AddProto(request.pose_graph()); - break; - case proto::LoadStateRequest::kAllTrajectoryBuilderOptions: - reader_.AddProto(request.all_trajectory_builder_options()); - break; case proto::LoadStateRequest::kSerializedData: reader_.AddProto(request.serialized_data()); break; + case proto::LoadStateRequest::kSerializationHeader: + reader_.AddProto(request.serialization_header()); + break; default: LOG(FATAL) << "Unhandled proto::LoadStateRequest case."; } } void LoadStateHandler::OnReadsDone() { + LOG(INFO) << "OnReadsDone"; GetContext()->map_builder().LoadState(&reader_, true); Send(common::make_unique()); diff --git a/cartographer/cloud/proto/map_builder_service.proto b/cartographer/cloud/proto/map_builder_service.proto index 1f78fac..07ab5ea 100644 --- a/cartographer/cloud/proto/map_builder_service.proto +++ b/cartographer/cloud/proto/map_builder_service.proto @@ -127,10 +127,8 @@ message GetSubmapRequest { message LoadStateRequest { oneof state_chunk { - cartographer.mapping.proto.PoseGraph pose_graph = 1; - cartographer.mapping.proto.AllTrajectoryBuilderOptions - all_trajectory_builder_options = 2; - cartographer.mapping.proto.SerializedData serialized_data = 3; + cartographer.mapping.proto.SerializedData serialized_data = 1; + cartographer.mapping.proto.SerializationHeader serialization_header = 2; } }