trajectory_collator.h
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 
17 #ifndef CARTOGRAPHER_SENSOR_INTERNAL_TRAJECTORY_COLLATOR_H_
18 #define CARTOGRAPHER_SENSOR_INTERNAL_TRAJECTORY_COLLATOR_H_
19 
20 #include <memory>
21 #include <unordered_map>
22 #include <vector>
23 
26 
27 namespace cartographer {
28 namespace sensor {
29 
30 // Waits to see at least one data item for all sensor ids and dispatches data
31 // in merge-sorted order. Contrary to 'Collator', it does not wait for other
32 // trajectories.
33 // Also contrary to 'Collator', whose output is deterministic, the sequence in
34 // which data is dispatched is not sorted, so non-deterministic input sequences
35 // will result in non-deterministic output.
37  public:
39 
40  TrajectoryCollator(const TrajectoryCollator&) = delete;
42 
43  void AddTrajectory(int trajectory_id,
44  const std::unordered_set<std::string>& expected_sensor_ids,
45  const Callback& callback) override;
46 
47  void FinishTrajectory(int trajectory_id) override;
48 
49  void AddSensorData(int trajectory_id, std::unique_ptr<Data> data) override;
50 
51  void Flush() override;
52 
54 
55  private:
56  std::unordered_map<int, OrderedMultiQueue> trajectory_to_queue_;
57 
58  // Map of trajectory ID to all associated QueueKeys.
59  std::unordered_map<int, std::vector<QueueKey>> trajectory_to_queue_keys_;
60 };
61 
62 } // namespace sensor
63 } // namespace cartographer
64 
65 #endif // CARTOGRAPHER_SENSOR_INTERNAL_TRAJECTORY_COLLATOR_H_
std::function< void(const std::string &, std::unique_ptr< Data >)> Callback
std::unordered_map< int, OrderedMultiQueue > trajectory_to_queue_
TrajectoryCollator & operator=(const TrajectoryCollator &)=delete
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