trajectory_connectivity_state.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 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_MAPPING_INTERNAL_TRAJECTORY_CONNECTIVITY_STATE_H_
18 #define CARTOGRAPHER_MAPPING_INTERNAL_TRAJECTORY_CONNECTIVITY_STATE_H_
19 
22 
23 namespace cartographer {
24 namespace mapping {
25 
26 // A class that tracks the connectivity state between trajectories. Compared to
27 // ConnectedComponents it tracks additionally the last time that a global
28 // constraint connected to trajectories.
29 //
30 // This class is thread-compatible.
32  public:
34 
37  delete;
38 
39  // Add a trajectory which is initially connected to only itself.
40  void Add(int trajectory_id);
41 
42  // Connect two trajectories. If either trajectory is untracked, it will be
43  // tracked. This function is invariant to the order of its arguments. Repeated
44  // calls to Connect increment the connectivity count and update the last
45  // connected time.
46  void Connect(int trajectory_id_a, int trajectory_id_b, common::Time time);
47 
48  // Determines if two trajectories have been (transitively) connected. If
49  // either trajectory is not being tracked, returns false, except when it is
50  // the same trajectory, where it returns true. This function is invariant to
51  // the order of its arguments.
52  bool TransitivelyConnected(int trajectory_id_a, int trajectory_id_b) const;
53 
54  // The trajectory IDs, grouped by connectivity.
55  std::vector<std::vector<int>> Components() const;
56 
57  // Return the last connection count between the two trajectories. If either of
58  // the trajectories is untracked or they have never been connected returns the
59  // beginning of time.
60  common::Time LastConnectionTime(int trajectory_id_a, int trajectory_id_b);
61 
62  private:
63  // ConnectedComponents are thread safe.
65 
66  // Tracks the last time a direct connection between two trajectories has
67  // been added. The exception is when a connection between two trajectories
68  // connects two formerly unconnected connected components. In this case all
69  // bipartite trajectories entries for these components are updated with the
70  // new connection time.
71  std::map<std::pair<int, int>, common::Time> last_connection_time_map_;
72 };
73 
74 } // namespace mapping
75 } // namespace cartographer
76 
77 #endif // CARTOGRAPHER_MAPPING_INTERNAL_TRAJECTORY_CONNECTIVITY_STATE_H_
void Connect(int trajectory_id_a, int trajectory_id_b, common::Time time)
UniversalTimeScaleClock::time_point Time
Definition: time.h:44
static time_point time
common::Time LastConnectionTime(int trajectory_id_a, int trajectory_id_b)
std::map< std::pair< int, int >, common::Time > last_connection_time_map_
TrajectoryConnectivityState & operator=(const TrajectoryConnectivityState &)=delete
bool TransitivelyConnected(int trajectory_id_a, int trajectory_id_b) const


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