collator.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 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/sensor/internal/collator.h"
00018 
00019 namespace cartographer {
00020 namespace sensor {
00021 
00022 void Collator::AddTrajectory(
00023     const int trajectory_id,
00024     const absl::flat_hash_set<std::string>& expected_sensor_ids,
00025     const Callback& callback) {
00026   for (const auto& sensor_id : expected_sensor_ids) {
00027     const auto queue_key = QueueKey{trajectory_id, sensor_id};
00028     queue_.AddQueue(queue_key,
00029                     [callback, sensor_id](std::unique_ptr<Data> data) {
00030                       callback(sensor_id, std::move(data));
00031                     });
00032     queue_keys_[trajectory_id].push_back(queue_key);
00033   }
00034 }
00035 
00036 void Collator::FinishTrajectory(const int trajectory_id) {
00037   for (const auto& queue_key : queue_keys_[trajectory_id]) {
00038     queue_.MarkQueueAsFinished(queue_key);
00039   }
00040 }
00041 
00042 void Collator::AddSensorData(const int trajectory_id,
00043                              std::unique_ptr<Data> data) {
00044   QueueKey queue_key{trajectory_id, data->GetSensorId()};
00045   queue_.Add(std::move(queue_key), std::move(data));
00046 }
00047 
00048 void Collator::Flush() { queue_.Flush(); }
00049 
00050 absl::optional<int> Collator::GetBlockingTrajectoryId() const {
00051   return absl::optional<int>(queue_.GetBlocker().trajectory_id);
00052 }
00053 
00054 }  // namespace sensor
00055 }  // namespace cartographer


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35