trajectory_collator.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 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  CHECK_EQ(trajectory_to_queue_.count(trajectory_id), 0);
27  for (const auto& sensor_id : expected_sensor_ids) {
28  const auto queue_key = QueueKey{trajectory_id, sensor_id};
29  trajectory_to_queue_[trajectory_id].AddQueue(
30  queue_key, [callback, sensor_id](std::unique_ptr<Data> data) {
31  callback(sensor_id, std::move(data));
32  });
33  trajectory_to_queue_keys_[trajectory_id].push_back(queue_key);
34  }
35 }
36 
37 void TrajectoryCollator::FinishTrajectory(const int trajectory_id) {
38  for (const auto& queue_key : trajectory_to_queue_keys_[trajectory_id]) {
39  trajectory_to_queue_.at(trajectory_id).MarkQueueAsFinished(queue_key);
40  }
41 }
42 
43 void TrajectoryCollator::AddSensorData(const int trajectory_id,
44  std::unique_ptr<Data> data) {
45  QueueKey queue_key{trajectory_id, data->GetSensorId()};
46  trajectory_to_queue_.at(trajectory_id)
47  .Add(std::move(queue_key), std::move(data));
48 }
49 
51  for (auto& it : trajectory_to_queue_) {
52  it.second.Flush();
53  }
54 }
55 
57  return common::optional<int>();
58 }
59 
60 } // namespace sensor
61 } // namespace cartographer
std::function< void(const std::string &, std::unique_ptr< Data >)> Callback
std::unordered_map< int, OrderedMultiQueue > trajectory_to_queue_
void AddTrajectory(int trajectory_id, const std::unordered_set< std::string > &expected_sensor_ids, const Callback &callback) override
std::unordered_map< int, std::vector< QueueKey > > trajectory_to_queue_keys_
common::optional< int > GetBlockingTrajectoryId() const override
void AddSensorData(int trajectory_id, std::unique_ptr< Data > data) override
void FinishTrajectory(int trajectory_id) override


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