collator_interface.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_COLLATOR_INTERFACE_H_
18 #define CARTOGRAPHER_SENSOR_COLLATOR_INTERFACE_H_
19 
20 #include <functional>
21 #include <memory>
22 #include <unordered_set>
23 #include <vector>
24 
27 
28 namespace cartographer {
29 namespace sensor {
30 
32  public:
33  using Callback =
34  std::function<void(const std::string&, std::unique_ptr<Data>)>;
35 
37  virtual ~CollatorInterface() {}
38  CollatorInterface(const CollatorInterface&) = delete;
40 
41  // Adds a trajectory to produce sorted sensor output for. Calls 'callback'
42  // for each collated sensor data.
43  virtual void AddTrajectory(
44  int trajectory_id,
45  const std::unordered_set<std::string>& expected_sensor_ids,
46  const Callback& callback) = 0;
47 
48  // Marks 'trajectory_id' as finished.
49  virtual void FinishTrajectory(int trajectory_id) = 0;
50 
51  // Adds 'data' for 'trajectory_id' to be collated. 'data' must contain valid
52  // sensor data. Sensor packets with matching 'data.sensor_id_' must be added
53  // in time order.
54  virtual void AddSensorData(int trajectory_id, std::unique_ptr<Data> data) = 0;
55 
56  // Dispatches all queued sensor packets. May only be called once.
57  // AddSensorData may not be called after Flush.
58  virtual void Flush() = 0;
59 
60  // Must only be called if at least one unfinished trajectory exists. Returns
61  // the ID of the trajectory that needs more data before CollatorInterface is
62  // unblocked. Returns 'nullopt' for implementations that do not wait for a
63  // particular trajectory.
65 };
66 
67 } // namespace sensor
68 } // namespace cartographer
69 
70 #endif // CARTOGRAPHER_SENSOR_COLLATOR_INTERFACE_H_
std::function< void(const std::string &, std::unique_ptr< Data >)> Callback
virtual void AddSensorData(int trajectory_id, std::unique_ptr< Data > data)=0
virtual common::optional< int > GetBlockingTrajectoryId() const =0
virtual void AddTrajectory(int trajectory_id, const std::unordered_set< std::string > &expected_sensor_ids, const Callback &callback)=0
virtual void FinishTrajectory(int trajectory_id)=0
CollatorInterface & operator=(const CollatorInterface &)=delete


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