00001 /* 00002 * Copyright 2018 The Cartographer Authors 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include "cartographer/cloud/internal/handlers/add_rangefinder_data_handler.h" 00018 00019 #include "absl/memory/memory.h" 00020 #include "async_grpc/rpc_handler.h" 00021 #include "cartographer/cloud/internal/map_builder_context_interface.h" 00022 #include "cartographer/cloud/proto/map_builder_service.pb.h" 00023 #include "cartographer/sensor/internal/dispatchable.h" 00024 #include "cartographer/sensor/timed_point_cloud_data.h" 00025 #include "google/protobuf/empty.pb.h" 00026 00027 namespace cartographer { 00028 namespace cloud { 00029 namespace handlers { 00030 00031 void AddRangefinderDataHandler::OnSensorData( 00032 const proto::AddRangefinderDataRequest& request) { 00033 // The 'BlockingQueue' returned by 'sensor_data_queue()' is already 00034 // thread-safe. Therefore it suffices to get an unsynchronized reference to 00035 // the 'MapBuilderContext'. 00036 GetUnsynchronizedContext<MapBuilderContextInterface>()->EnqueueSensorData( 00037 request.sensor_metadata().trajectory_id(), 00038 sensor::MakeDispatchable( 00039 request.sensor_metadata().sensor_id(), 00040 sensor::FromProto(request.timed_point_cloud_data()))); 00041 } 00042 00043 } // namespace handlers 00044 } // namespace cloud 00045 } // namespace cartographer