Autoware.Auto
objects_with_associations.hpp
Go to the documentation of this file.
1 // Copyright 2021 The Autoware Foundation
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 //
15 // Co-developed by Tier IV, Inc. and Apex.AI, Inc.
16 
17 #ifndef TRACKING__OBJECTS_WITH_ASSOCIATIONS_HPP_
18 #define TRACKING__OBJECTS_WITH_ASSOCIATIONS_HPP_
19 
20 
21 #include <autoware_auto_perception_msgs/msg/classified_roi_array.hpp>
22 #include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
23 #include <autoware_auto_perception_msgs/msg/tracked_objects.hpp>
25 
26 #include <utility>
27 #include <vector>
28 
29 namespace autoware
30 {
31 namespace perception
32 {
33 namespace tracking
34 {
35 
36 namespace detail
37 {
38 template<class MsgT>
39 std::size_t get_size(const MsgT & msg);
40 
41 template<>
43 {
44  return msg.objects.size();
45 }
46 } // namespace detail
47 
51 enum class Matched
52 {
53  kNothing,
56  kNewTrack
57 };
58 
64 {
66  std::size_t match_index;
67 };
68 
69 using Associations = std::vector<Association>;
70 
79 template<class MsgT>
80 class TRACKING_PUBLIC Associated
81 {
82 public:
83  explicit Associated(const MsgT & objects, const Associations & associations)
84  : m_objects{objects}, m_associations{associations}
85  {
86  if (detail::get_size(m_objects) != m_associations.size()) {
87  throw std::runtime_error("Objects number must match the associations number");
88  }
89  }
90 
91  explicit Associated(const MsgT & objects)
92  : m_objects{objects}, m_associations(detail::get_size(m_objects), {Matched::kNothing, 0UL}) {}
93 
94  explicit Associated(MsgT && objects)
95  : m_objects{std::move(objects)},
96  m_associations(detail::get_size(m_objects), {Matched::kNothing, 0UL}) {}
97 
98  const MsgT & objects() const noexcept {return m_objects;}
99 
100  const Associations & associations() const noexcept
101  {
102  return m_associations;
103  }
104  Associations & associations() noexcept {return m_associations;}
105 
106 private:
107  MsgT m_objects;
108  Associations m_associations;
109 };
110 
114 
115 } // namespace tracking
116 } // namespace perception
117 } // namespace autoware
118 
119 
120 #endif // TRACKING__OBJECTS_WITH_ASSOCIATIONS_HPP_
autoware::perception::tracking::Associations
std::vector< Association > Associations
Definition: objects_with_associations.hpp:69
autoware::perception::tracking::Matched
Matched
This enum holds various values that signify a match to a certain modality.
Definition: objects_with_associations.hpp:51
autoware::perception::tracking::detail::get_size
std::size_t get_size(const MsgT &msg)
autoware::perception::tracking::Matched::kNothing
@ kNothing
Nothing was matched.
visibility_control.hpp
autoware::perception::tracking::Association::match_index
std::size_t match_index
Definition: objects_with_associations.hpp:66
autoware::perception::tracking::Associated
This class describes an associated object array of a certain message type.
Definition: objects_with_associations.hpp:80
autoware::perception::tracking::Matched::kOtherDetection
@ kOtherDetection
Matched another detection.
autoware::perception::tracking::Matched::kExistingTrack
@ kExistingTrack
Matched an existing track.
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
autoware::perception::tracking::Associated::Associated
Associated(const MsgT &objects)
Definition: objects_with_associations.hpp:91
autoware::perception::tracking::Associated::associations
const Associations & associations() const noexcept
Definition: objects_with_associations.hpp:100
autoware::perception::tracking::Associated::objects
const MsgT & objects() const noexcept
Definition: objects_with_associations.hpp:98
autoware::perception::tracking::Associated::associations
Associations & associations() noexcept
Definition: objects_with_associations.hpp:104
autoware::perception::tracking::Association::matched
Matched matched
Definition: objects_with_associations.hpp:65
autoware::perception::tracking::Associated::Associated
Associated(const MsgT &objects, const Associations &associations)
Definition: objects_with_associations.hpp:83
autoware::perception::tracking::Associated::Associated
Associated(MsgT &&objects)
Definition: objects_with_associations.hpp:94
autoware::perception::tracking::Association
A struct that represents an association. It holds an enum that indicates the type of a match and an i...
Definition: objects_with_associations.hpp:63
autoware::perception::tracking::Matched::kNewTrack
@ kNewTrack
Matched a new track.
DetectedObjects
autoware_auto_perception_msgs::msg::DetectedObjects DetectedObjects
Definition: euclidean_cluster_node.cpp:39