collator.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2016 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 namespace cartographer {
20 namespace sensor {
21 
23  const int trajectory_id,
24  const std::unordered_set<std::string>& expected_sensor_ids,
25  const Callback& callback) {
26  for (const auto& sensor_id : expected_sensor_ids) {
27  const auto queue_key = QueueKey{trajectory_id, sensor_id};
28  queue_.AddQueue(queue_key,
29  [callback, sensor_id](std::unique_ptr<Data> data) {
30  callback(sensor_id, std::move(data));
31  });
32  queue_keys_[trajectory_id].push_back(queue_key);
33  }
34 }
35 
36 void Collator::FinishTrajectory(const int trajectory_id) {
37  for (const auto& queue_key : queue_keys_[trajectory_id]) {
38  queue_.MarkQueueAsFinished(queue_key);
39  }
40 }
41 
42 void Collator::AddSensorData(const int trajectory_id,
43  std::unique_ptr<Data> data) {
44  QueueKey queue_key{trajectory_id, data->GetSensorId()};
45  queue_.Add(std::move(queue_key), std::move(data));
46 }
47 
49 
52 }
53 
54 } // namespace sensor
55 } // namespace cartographer
std::function< void(const std::string &, std::unique_ptr< Data >)> Callback
void FinishTrajectory(int trajectory_id) override
Definition: collator.cc:36
common::optional< int > GetBlockingTrajectoryId() const override
Definition: collator.cc:50
void AddSensorData(int trajectory_id, std::unique_ptr< Data > data) override
Definition: collator.cc:42
void AddTrajectory(int trajectory_id, const std::unordered_set< std::string > &expected_sensor_ids, const Callback &callback) override
Definition: collator.cc:22
OrderedMultiQueue queue_
Definition: collator.h:54
std::unordered_map< int, std::vector< QueueKey > > queue_keys_
Definition: collator.h:57
void AddQueue(const QueueKey &queue_key, Callback callback)
void MarkQueueAsFinished(const QueueKey &queue_key)
void Add(const QueueKey &queue_key, std::unique_ptr< Data > data)


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