Autoware.Auto
detected_object_associator.hpp
Go to the documentation of this file.
1 // Copyright 2021 Apex.AI, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #ifndef TRACKING__DETECTED_OBJECT_ASSOCIATOR_HPP_
15 #define TRACKING__DETECTED_OBJECT_ASSOCIATOR_HPP_
16 
18 
19 #include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
20 #include <common/types.hpp>
25 
26 #include <experimental/optional>
27 #include <map>
28 #include <vector>
29 
30 namespace autoware
31 {
32 namespace perception
33 {
34 namespace tracking
35 {
36 
38 
40 class TRACKING_PUBLIC DataAssociationConfig
41 {
42 public:
52  const float32_t max_distance, const float32_t max_area_ratio,
53  const bool consider_edge_for_big_detections);
54 
55  inline float32_t get_max_distance() const {return m_max_distance;}
56 
57  inline float32_t get_max_distance_squared() const {return m_max_distance_squared;}
58 
59  inline float32_t get_max_area_ratio() const {return m_max_area_ratio;}
60 
61  inline float32_t get_max_area_ratio_inv() const {return m_max_area_ratio_inv;}
62 
63  inline bool consider_edge_for_big_detections() const {return m_consider_edge_for_big_detections;}
64 
65 private:
66  float32_t m_max_distance;
67  float32_t m_max_distance_squared;
68  float32_t m_max_area_ratio;
69  float32_t m_max_area_ratio_inv;
70  bool m_consider_edge_for_big_detections;
71 };
72 
75 class TRACKING_PUBLIC DetectedObjectAssociator
76 {
77 public:
81  explicit DetectedObjectAssociator(const DataAssociationConfig & association_cfg);
82 
87  Associations assign(
89  const TrackedObjects & tracks);
90 
91  const Associations & track_associations() const noexcept
92  {
93  return m_track_associations;
94  }
95 
96 private:
98  void reset();
99 
101  void compute_weights(
103  const TrackedObjects & tracks);
104 
106  bool consider_associating(
107  const autoware_auto_perception_msgs::msg::DetectedObject & detection,
108  const TrackedObject & track) const;
109 
111  void set_weight(const float32_t weight, const size_t det_idx, const size_t track_idx);
112 
114  Associations extract_result();
115 
116  DataAssociationConfig m_association_cfg;
117  Assigner m_assigner;
118  // Hungarian assigner expects a fat matrix (not tall). Bool tracks if tracks are rows or cols
119  bool m_are_tracks_rows;
120  size_t m_num_tracks;
121  size_t m_num_detections;
122  bool m_had_errors = false;
123  Associations m_track_associations;
124 };
125 
126 
127 } // namespace tracking
128 } // namespace perception
129 } // namespace autoware
130 
131 #endif // TRACKING__DETECTED_OBJECT_ASSOCIATOR_HPP_
autoware::perception::tracking::TrackedObjects
A collection of tracked objects.
Definition: include/tracking/tracked_object.hpp:158
autoware::perception::tracking::Associations
std::vector< Association > Associations
Definition: objects_with_associations.hpp:69
autoware::perception::tracking::DetectedObjectAssociator
Class to perform data association between existing tracks and new detections using mahalanobis distan...
Definition: detected_object_associator.hpp:75
types.hpp
This file includes common type definition.
autoware::perception::tracking::assigner_idx_t
autoware::fusion::hungarian_assigner::index_t assigner_idx_t
Definition: detected_object_associator.hpp:37
autoware::perception::tracking::DataAssociationConfig::consider_edge_for_big_detections
bool consider_edge_for_big_detections() const
Definition: detected_object_associator.hpp:63
autoware::perception::tracking::DetectedObjectAssociator::track_associations
const Associations & track_associations() const noexcept
Definition: detected_object_associator.hpp:91
visibility_control.hpp
autoware::perception::tracking::DataAssociationConfig::get_max_distance
float32_t get_max_distance() const
Definition: detected_object_associator.hpp:55
autoware::perception::tracking::DataAssociationConfig::get_max_area_ratio
float32_t get_max_area_ratio() const
Definition: detected_object_associator.hpp:59
autoware::fusion::hungarian_assigner::index_t
Eigen::Index index_t
indexing matches what matrices use
Definition: hungarian_assigner.hpp:49
tracker_types.hpp
autoware::perception::tracking::DataAssociationConfig::get_max_distance_squared
float32_t get_max_distance_squared() const
Definition: detected_object_associator.hpp:57
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
hungarian_assigner.hpp
Header for hungarian algorithm for optimal linear assignment.
autoware::common::types::float32_t
float float32_t
Definition: types.hpp:45
objects_with_associations.hpp
tracked_object.hpp
This file defines the multi_object_tracking class.
autoware::perception::tracking::DataAssociationConfig
Class to create configuration parameters for data association.
Definition: detected_object_associator.hpp:40
autoware::perception::tracking::DataAssociationConfig::get_max_area_ratio_inv
float32_t get_max_area_ratio_inv() const
Definition: detected_object_associator.hpp:61
autoware::fusion::hungarian_assigner::hungarian_assigner_c< MAX_NUM_TRACKS >
autoware::perception::tracking::TrackedObject
Internal class containing the object state and other information.
Definition: include/tracking/tracked_object.hpp:48
DetectedObjects
autoware_auto_perception_msgs::msg::DetectedObjects DetectedObjects
Definition: euclidean_cluster_node.cpp:39