19 #include "async_grpc/rpc_handler.h" 21 #include "cartographer/cloud/proto/map_builder_service.pb.h" 30 std::unique_ptr<proto::ReceiveLocalSlamResultsResponse> GenerateResponse(
31 std::unique_ptr<MapBuilderContextInterface::LocalSlamResult>
33 auto response = common::make_unique<proto::ReceiveLocalSlamResultsResponse>();
34 response->set_trajectory_id(local_slam_result->trajectory_id);
36 *response->mutable_local_pose() =
38 if (local_slam_result->range_data) {
39 *response->mutable_range_data() =
42 if (local_slam_result->insertion_result) {
43 local_slam_result->insertion_result->node_id.ToProto(
44 response->mutable_insertion_result()->mutable_node_id());
51 void ReceiveLocalSlamResultsHandler::OnRequest(
52 const proto::ReceiveLocalSlamResultsRequest& request) {
53 auto writer = GetWriter();
54 MapBuilderContextInterface::LocalSlamSubscriptionId subscription_id =
55 GetUnsynchronizedContext<MapBuilderContextInterface>()
56 ->SubscribeLocalSlamResults(
57 request.trajectory_id(),
59 std::unique_ptr<MapBuilderContextInterface::LocalSlamResult>
61 if (local_slam_result) {
63 GenerateResponse(std::move(local_slam_result)))) {
65 LOG(INFO) <<
"Client closed connection.";
77 common::make_unique<MapBuilderContextInterface::LocalSlamSubscriptionId>(
81 void ReceiveLocalSlamResultsHandler::OnFinish() {
82 if (subscription_id_) {
83 GetUnsynchronizedContext<MapBuilderContextInterface>()
84 ->UnsubscribeLocalSlamResults(*subscription_id_);
proto::FixedFramePoseData ToProto(const FixedFramePoseData &pose_data)
int64 ToUniversal(const Time time)