add_sensor_data_batch_handler.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2018 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include "async_grpc/rpc_handler.h"
21 #include "cartographer/cloud/proto/map_builder_service.pb.h"
26 #include "google/protobuf/empty.pb.h"
27 
28 namespace cartographer {
29 namespace cloud {
30 namespace handlers {
31 
32 void AddSensorDataBatchHandler::OnRequest(
33  const proto::AddSensorDataBatchRequest& request) {
34  for (const proto::SensorData& sensor_data : request.sensor_data()) {
35  switch (sensor_data.sensor_data_case()) {
36  case proto::SensorData::kOdometryData:
37  GetUnsynchronizedContext<MapBuilderContextInterface>()
38  ->EnqueueSensorData(
39  sensor_data.sensor_metadata().trajectory_id(),
41  sensor_data.sensor_metadata().sensor_id(),
42  sensor::FromProto(sensor_data.odometry_data())));
43  break;
44  case proto::SensorData::kImuData:
45  GetUnsynchronizedContext<MapBuilderContextInterface>()
46  ->EnqueueSensorData(sensor_data.sensor_metadata().trajectory_id(),
48  sensor_data.sensor_metadata().sensor_id(),
49  sensor::FromProto(sensor_data.imu_data())));
50  break;
51  case proto::SensorData::kTimedPointCloudData:
52  GetUnsynchronizedContext<MapBuilderContextInterface>()
53  ->EnqueueSensorData(
54  sensor_data.sensor_metadata().trajectory_id(),
56  sensor_data.sensor_metadata().sensor_id(),
57  sensor::FromProto(sensor_data.timed_point_cloud_data())));
58  break;
59  case proto::SensorData::kFixedFramePoseData:
60  GetUnsynchronizedContext<MapBuilderContextInterface>()
61  ->EnqueueSensorData(
62  sensor_data.sensor_metadata().trajectory_id(),
64  sensor_data.sensor_metadata().sensor_id(),
65  sensor::FromProto(sensor_data.fixed_frame_pose_data())));
66  break;
67  case proto::SensorData::kLandmarkData:
68  GetUnsynchronizedContext<MapBuilderContextInterface>()
69  ->EnqueueSensorData(
70  sensor_data.sensor_metadata().trajectory_id(),
72  sensor_data.sensor_metadata().sensor_id(),
73  sensor::FromProto(sensor_data.landmark_data())));
74  break;
75  case proto::SensorData::kLocalSlamResultData:
76  GetContext<MapBuilderContextInterface>()->EnqueueLocalSlamResultData(
77  sensor_data.sensor_metadata().trajectory_id(),
78  sensor_data.sensor_metadata().sensor_id(),
79  sensor_data.local_slam_result_data());
80  break;
81  default:
82  LOG(FATAL) << "Unknown sensor data type: "
83  << sensor_data.sensor_data_case();
84  }
85  }
86  Send(common::make_unique<google::protobuf::Empty>());
87 }
88 
89 } // namespace handlers
90 } // namespace cloud
91 } // namespace cartographer
FixedFramePoseData FromProto(const proto::FixedFramePoseData &proto)
std::unique_ptr< Dispatchable< DataType > > MakeDispatchable(const std::string &sensor_id, const DataType &data)
Definition: dispatchable.h:44


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58