Fix LoadState gRPC (#1179)
parent
5b0fe666ee
commit
f83ba3db2f
|
@ -132,16 +132,24 @@ void MapBuilderStub::LoadState(io::ProtoStreamReaderInterface* reader,
|
|||
async_grpc::Client<handlers::LoadStateSignature> 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));
|
||||
}
|
||||
|
|
|
@ -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<mapping::PoseGraphInterface> pose_graph_stub_;
|
||||
std::map<int, std::unique_ptr<mapping::TrajectoryBuilderInterface>>
|
||||
|
|
|
@ -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<MapBuilderContextInterface>()->map_builder().LoadState(&reader_,
|
||||
true);
|
||||
Send(common::make_unique<google::protobuf::Empty>());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue