Fix LoadState gRPC (#1179)

master
Christoph Schütte 2018-06-04 11:11:28 +02:00 committed by Wally B. Feed
parent 5b0fe666ee
commit f83ba3db2f
4 changed files with 19 additions and 14 deletions

View File

@ -132,16 +132,24 @@ void MapBuilderStub::LoadState(io::ProtoStreamReaderInterface* reader,
async_grpc::Client<handlers::LoadStateSignature> client(client_channel_); async_grpc::Client<handlers::LoadStateSignature> client(client_channel_);
io::ProtoStreamDeserializer deserializer(reader); io::ProtoStreamDeserializer deserializer(reader);
// Request with a PoseGraph proto is sent first. // Request with the SerializationHeader proto is sent first.
{ {
proto::LoadStateRequest request; proto::LoadStateRequest request;
*request.mutable_pose_graph() = deserializer.pose_graph(); *request.mutable_serialization_header() = deserializer.header();
CHECK(client.Write(request)); CHECK(client.Write(request));
} }
// Request with an AllTrajectoryBuilderOptions should be second. // Request with a PoseGraph proto is sent second.
{ {
proto::LoadStateRequest request; 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(); deserializer.all_trajectory_builder_options();
CHECK(client.Write(request)); CHECK(client.Write(request));
} }

View File

@ -56,6 +56,7 @@ class MapBuilderStub : public mapping::MapBuilderInterface {
GetAllTrajectoryBuilderOptions() const override; GetAllTrajectoryBuilderOptions() const override;
private: private:
::grpc::ChannelArguments channel_arguments_;
std::shared_ptr<::grpc::Channel> client_channel_; std::shared_ptr<::grpc::Channel> client_channel_;
std::unique_ptr<mapping::PoseGraphInterface> pose_graph_stub_; std::unique_ptr<mapping::PoseGraphInterface> pose_graph_stub_;
std::map<int, std::unique_ptr<mapping::TrajectoryBuilderInterface>> std::map<int, std::unique_ptr<mapping::TrajectoryBuilderInterface>>

View File

@ -28,21 +28,19 @@ namespace handlers {
void LoadStateHandler::OnRequest(const proto::LoadStateRequest& request) { void LoadStateHandler::OnRequest(const proto::LoadStateRequest& request) {
switch (request.state_chunk_case()) { 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: case proto::LoadStateRequest::kSerializedData:
reader_.AddProto(request.serialized_data()); reader_.AddProto(request.serialized_data());
break; break;
case proto::LoadStateRequest::kSerializationHeader:
reader_.AddProto(request.serialization_header());
break;
default: default:
LOG(FATAL) << "Unhandled proto::LoadStateRequest case."; LOG(FATAL) << "Unhandled proto::LoadStateRequest case.";
} }
} }
void LoadStateHandler::OnReadsDone() { void LoadStateHandler::OnReadsDone() {
LOG(INFO) << "OnReadsDone";
GetContext<MapBuilderContextInterface>()->map_builder().LoadState(&reader_, GetContext<MapBuilderContextInterface>()->map_builder().LoadState(&reader_,
true); true);
Send(common::make_unique<google::protobuf::Empty>()); Send(common::make_unique<google::protobuf::Empty>());

View File

@ -127,10 +127,8 @@ message GetSubmapRequest {
message LoadStateRequest { message LoadStateRequest {
oneof state_chunk { oneof state_chunk {
cartographer.mapping.proto.PoseGraph pose_graph = 1; cartographer.mapping.proto.SerializedData serialized_data = 1;
cartographer.mapping.proto.AllTrajectoryBuilderOptions cartographer.mapping.proto.SerializationHeader serialization_header = 2;
all_trajectory_builder_options = 2;
cartographer.mapping.proto.SerializedData serialized_data = 3;
} }
} }