Autoware.Auto
include/tracking/tracked_object.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__TRACKED_OBJECT_HPP_
22 #define TRACKING__TRACKED_OBJECT_HPP_
23 
24 #include <autoware_auto_perception_msgs/msg/detected_object.hpp>
25 #include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
26 #include <autoware_auto_perception_msgs/msg/shape.hpp>
27 #include <autoware_auto_perception_msgs/msg/tracked_objects.hpp>
28 #include <common/types.hpp>
35 
36 #include <chrono>
37 #include <cstddef>
38 #include <vector>
39 
40 namespace autoware
41 {
42 namespace perception
43 {
44 namespace tracking
45 {
46 
48 class TRACKING_PUBLIC TrackedObject
49 {
50 public:
51  // Aliases for convenience
56  using TrackedObjectMsg = autoware_auto_perception_msgs::msg::TrackedObject;
57  using DetectedObjectMsg = autoware_auto_perception_msgs::msg::DetectedObject;
58  using ObjectClassifications =
59  autoware_auto_perception_msgs::msg::TrackedObject::_classification_type;
60  using ShapeMsg = autoware_auto_perception_msgs::msg::Shape;
61 
71  explicit TrackedObject(
72  const DetectedObjectMsg & detection,
73  common::types::float64_t default_variance,
74  common::types::float64_t noise_variance);
75 
84  explicit TrackedObject(
85  const DetectedObjectMsg & detection,
86  const DetectedObjectMsg::_classification_type & override_classification,
87  common::types::float64_t default_variance,
88  common::types::float64_t noise_variance);
90  // TODO(nikolai.morin): Change signature to use absolute time after #1002
91  void predict(std::chrono::nanoseconds dt);
92 
94  void update(const DetectedObjectMsg & detection);
95 
97  void update(
98  const ObjectClassifications & obj_type, const common::types::float32_t covariance);
99 
101  void no_update();
102 
104  bool should_be_removed(
105  const std::chrono::nanoseconds time_threshold,
106  const std::size_t ticks_threshold) const;
107 
109  const TrackedObjectMsg & msg();
110 
112  inline Eigen::Matrix2d position_covariance() const
113  {
114  return m_ekf.covariance().topLeftCorner<2, 2>();
115  }
116 
118  inline Eigen::Vector2d centroid() const
119  {
120  return Eigen::Vector2d {
122  m_ekf.state().at<autoware::common::state_vector::variable::Y>()};
123  }
124 
125  inline double z() const noexcept {return m_msg.kinematics.centroid_position.z;}
126 
128  inline const ShapeMsg & shape() const
129  {
130  return m_msg.shape[0];
131  }
132 
133  inline const geometry_msgs::msg::Quaternion orientation() const
134  {
135  return m_msg.kinematics.orientation;
136  }
137 
138 private:
140  TrackedObjectMsg m_msg;
142  EKF m_ekf;
144  std::chrono::nanoseconds m_time_since_last_seen = std::chrono::nanoseconds::zero();
146  std::size_t m_ticks_since_last_seen = 0;
148  std::size_t m_ticks_alive = 1;
151  common::types::float64_t m_default_variance = -1.0;
153  ClassificationTracker m_classifier;
154 };
155 
156 
158 struct TRACKING_PUBLIC TrackedObjects
159 {
161  std::vector<TrackedObject> objects;
163  std_msgs::msg::Header::_frame_id_type frame_id;
164 };
165 
166 } // namespace tracking
167 } // namespace perception
168 } // namespace autoware
169 
170 #endif // TRACKING__TRACKED_OBJECT_HPP_
autoware::perception::tracking::TrackedObjects
A collection of tracked objects.
Definition: include/tracking/tracked_object.hpp:158
autoware::perception::tracking::TrackedObjects::objects
std::vector< TrackedObject > objects
Tracked objects.
Definition: include/tracking/tracked_object.hpp:161
linear_motion_model.hpp
types.hpp
This file includes common type definition.
visibility_control.hpp
autoware::perception::tracking::TrackedObject::ObjectClassifications
autoware_auto_perception_msgs::msg::TrackedObject::_classification_type ObjectClassifications
Definition: include/tracking/tracked_object.hpp:59
autoware::common::state_vector::GenericState
A representation of a generic state vectors with specified variables.
Definition: generic_state.hpp:60
autoware::perception::tracking::TrackedObject::orientation
const geometry_msgs::msg::Quaternion orientation() const
Definition: include/tracking/tracked_object.hpp:133
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
autoware::perception::tracking::TrackedObject::TrackedObjectMsg
autoware_auto_perception_msgs::msg::TrackedObject TrackedObjectMsg
Definition: include/tracking/tracked_object.hpp:56
autoware::common::state_vector::variable::Y
Definition: common_variables.hpp:39
autoware::perception::tracking::TrackedObject::position_covariance
Eigen::Matrix2d position_covariance() const
Getter for position covariance array.
Definition: include/tracking/tracked_object.hpp:112
autoware::common::state_vector::ConstAccelerationXY64
ConstAccelerationXY< common::types::float64_t > ConstAccelerationXY64
Definition: common_states.hpp:47
autoware::perception::tracking::TrackedObject::z
double z() const noexcept
Definition: include/tracking/tracked_object.hpp:125
autoware::perception::tracking::GenericClassificationTracker< ObjectClassificationState >
autoware::perception::tracking::TrackedObject::ShapeMsg
autoware_auto_perception_msgs::msg::Shape ShapeMsg
Definition: include/tracking/tracked_object.hpp:60
autoware::perception::tracking::TrackedObject::shape
const ShapeMsg & shape() const
Getter for shape.
Definition: include/tracking/tracked_object.hpp:128
autoware::common::types::float32_t
float float32_t
Definition: types.hpp:45
autoware::perception::tracking::TrackedObject::centroid
Eigen::Vector2d centroid() const
Getter for centroid position.
Definition: include/tracking/tracked_object.hpp:118
autoware::common::state_estimation::KalmanFilter< MotionModel, NoiseModel >
autoware::common::state_vector::variable::X
Definition: common_variables.hpp:38
classification_tracker.hpp
wiener_noise.hpp
autoware::common::motion_model::LinearMotionModel
A generic linear motion model class.
Definition: linear_motion_model.hpp:42
autoware::common::state_estimation::WienerNoise
A class that describes the Wiener process noise.
Definition: wiener_noise.hpp:54
autoware::common::types::float64_t
double float64_t
Definition: types.hpp:47
autoware::perception::tracking::TrackedObjects::frame_id
std_msgs::msg::Header::_frame_id_type frame_id
Frame in which the objects exist.
Definition: include/tracking/tracked_object.hpp:163
kalman_filter.hpp
autoware::perception::tracking::TrackedObject::DetectedObjectMsg
autoware_auto_perception_msgs::msg::DetectedObject DetectedObjectMsg
Definition: include/tracking/tracked_object.hpp:57
autoware::perception::tracking::TrackedObject
Internal class containing the object state and other information.
Definition: include/tracking/tracked_object.hpp:48
common_states.hpp
This file holds a collection of states that are commonly used in this package.