Autoware.Auto
multi_object_tracker.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 
20 
21 #ifndef TRACKING__MULTI_OBJECT_TRACKER_HPP_
22 #define TRACKING__MULTI_OBJECT_TRACKER_HPP_
23 
29 
30 #include <autoware_auto_perception_msgs/msg/bounding_box_array.hpp>
31 #include <autoware_auto_perception_msgs/msg/detected_object.hpp>
32 #include <autoware_auto_perception_msgs/msg/point_clusters.hpp>
33 #include <autoware_auto_perception_msgs/msg/tracked_object.hpp>
34 #include <autoware_auto_perception_msgs/msg/tracked_objects.hpp>
35 #include <common/types.hpp>
36 #include <geometry_msgs/msg/transform_stamped.hpp>
38 #include <nav_msgs/msg/odometry.hpp>
42 #include <tf2/buffer_core.h>
43 
44 #include <chrono>
45 #include <cstddef>
46 #include <limits>
47 #include <memory>
48 #include <string>
49 #include <vector>
50 
51 
52 namespace autoware
53 {
54 namespace perception
55 {
56 namespace tracking
57 {
58 
59 
62 {
64  Ok,
77 };
78 
80 struct TRACKING_PUBLIC DetectedObjectsUpdateResult
81 {
83  autoware_auto_perception_msgs::msg::TrackedObjects tracks;
85  std::vector<std::size_t> unassigned_clusters_indices;
89  builtin_interfaces::msg::Time related_rois_stamp;
90 };
91 
93 struct TRACKING_PUBLIC MultiObjectTrackerOptions
94 {
100  std::chrono::nanoseconds pruning_time_threshold = std::chrono::nanoseconds::max();
102  std::size_t pruning_ticks_threshold = std::numeric_limits<std::size_t>::max();
104  std::string frame = "map";
105 };
106 
108 template<class TrackCreatorT>
109 class TRACKING_PUBLIC MultiObjectTracker
110 {
111 private:
112  using ClustersMsg = autoware_auto_perception_msgs::msg::PointClusters;
113  using DetectedObjectsMsg = autoware_auto_perception_msgs::msg::DetectedObjects;
114  using DetectedObjectKinematics = autoware_auto_perception_msgs::msg::DetectedObjectKinematics;
115  using BoundingBoxArrayMsg = autoware_auto_perception_msgs::msg::BoundingBoxArray;
116  using ClassifiedRoiArrayMsg = autoware_auto_perception_msgs::msg::ClassifiedRoiArray;
117  using TrackedObjectsMsg = autoware_auto_perception_msgs::msg::TrackedObjects;
118 
119 public:
121  explicit MultiObjectTracker(
123  TrackCreatorT track_creator,
124  const tf2::BufferCore & tf2_buffer);
125 
141  const DetectedObjectsMsg & detections,
142  const nav_msgs::msg::Odometry & detection_frame_odometry);
143 
155  const ClustersMsg & incoming_clusters,
156  const nav_msgs::msg::Odometry & detection_frame_odometry);
157 
160  void update(const ClassifiedRoiArrayMsg & rois);
161 
162 private:
164  TrackerUpdateStatus validate(
165  const DetectedObjectsMsg & detections,
166  const nav_msgs::msg::Odometry & detection_frame_odometry);
167 
169  TrackedObjects m_tracks;
170 
172  std::chrono::system_clock::time_point m_last_update;
173 
175  MultiObjectTrackerOptions m_options;
176 
178  DetectedObjectAssociator m_object_associator;
179 
180  GreedyRoiAssociator m_vision_associator;
181 
183  TrackCreatorT m_track_creator;
184 };
185 
186 template<>
188  const ClassifiedRoiArrayMsg &)
189 {
190  throw std::runtime_error("Trying to update a LiDAR-only tracker with a vision message.");
191 }
192 
193 } // namespace tracking
194 } // namespace perception
195 } // namespace autoware
196 
197 #endif // TRACKING__MULTI_OBJECT_TRACKER_HPP_
autoware::perception::tracking::TrackerUpdateStatus::InvalidShape
@ InvalidShape
At least one of the provided detections has an invalid shape.
autoware::perception::tracking::TrackedObjects
A collection of tracked objects.
Definition: include/tracking/tracked_object.hpp:158
autoware::perception::tracking::DetectedObjectsUpdateResult::status
TrackerUpdateStatus status
Indicates the success or failure, and kind of failure, of the tracking operation.
Definition: multi_object_tracker.hpp:87
autoware::perception::tracking::GreedyRoiAssociator
Class to associate the detections and tracks in euclidean space to ROIs in image space on a first-com...
Definition: greedy_roi_associator.hpp:67
autoware::perception::tracking::DetectedObjectAssociator
Class to perform data association between existing tracks and new detections using mahalanobis distan...
Definition: detected_object_associator.hpp:75
linear_motion_model.hpp
types.hpp
This file includes common type definition.
autoware::perception::tracking::DetectedObjectsUpdateResult::related_rois_stamp
builtin_interfaces::msg::Time related_rois_stamp
Timestamps of ROI msgs used for track creation. Useful for debugging purposes.
Definition: multi_object_tracker.hpp:89
autoware::perception::tracking::MultiObjectTracker
A class for multi-object tracking.
Definition: multi_object_tracker.hpp:109
greedy_roi_associator.hpp
visibility_control.hpp
autoware::perception::tracking::DetectedObjectsUpdateResult
Output of MultiObjectTracker::update.
Definition: multi_object_tracker.hpp:80
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
autoware::perception::tracking::DetectedObjectsUpdateResult::unassigned_clusters_indices
std::vector< std::size_t > unassigned_clusters_indices
Indices of unassigned clusters.
Definition: multi_object_tracker.hpp:85
autoware::perception::tracking::MultiObjectTrackerOptions::vision_association_config
GreedyRoiAssociatorConfig vision_association_config
Vision ROI association parameters.
Definition: multi_object_tracker.hpp:98
autoware::perception::tracking::TrackerUpdateStatus::WentBackInTime
@ WentBackInTime
autoware::perception::tracking::DetectedObjectsUpdateResult::tracks
autoware_auto_perception_msgs::msg::TrackedObjects tracks
The existing tracks output.
Definition: multi_object_tracker.hpp:83
autoware::perception::tracking::MultiObjectTrackerOptions
Options for object tracking, with sensible defaults.
Definition: multi_object_tracker.hpp:93
BoundingBoxArray
autoware_auto_perception_msgs::msg::BoundingBoxArray BoundingBoxArray
Definition: tf2_autoware_auto_msgs.hpp:38
autoware::perception::tracking::GreedyRoiAssociatorConfig
Definition: greedy_roi_associator.hpp:59
autoware::perception::tracking::TrackerUpdateStatus::DetectionFrameMismatch
@ DetectionFrameMismatch
The frame of the detections does not match the source frame of the transform.
detected_object_associator.hpp
autoware::drivers::vehicle_interface::Odometry
autoware_auto_vehicle_msgs::msg::VehicleOdometry Odometry
Definition: safety_state_machine.hpp:50
autoware::perception::tracking::TrackerUpdateStatus::TrackerFrameMismatch
@ TrackerFrameMismatch
The target frame of the transform does not match the frame in which the tracker operates.
tracked_object.hpp
This file defines the multi_object_tracking class.
wiener_noise.hpp
autoware::perception::tracking::TrackerUpdateStatus::Ok
@ Ok
Success.
track_creator.hpp
autoware::perception::tracking::TrackerUpdateStatus::FrameNotGravityAligned
@ FrameNotGravityAligned
autoware::perception::tracking::DataAssociationConfig
Class to create configuration parameters for data association.
Definition: detected_object_associator.hpp:40
autoware::perception::tracking::MultiObjectTrackerOptions::object_association_config
DataAssociationConfig object_association_config
Detected object association parameters.
Definition: multi_object_tracker.hpp:96
autoware::perception::tracking::TrackerUpdateStatus
TrackerUpdateStatus
A return code for the tracker update.
Definition: multi_object_tracker.hpp:61
kalman_filter.hpp
common_states.hpp
This file holds a collection of states that are commonly used in this package.
DetectedObjects
autoware_auto_perception_msgs::msg::DetectedObjects DetectedObjects
Definition: euclidean_cluster_node.cpp:39