16
16
// Author: v1.0 Yukihiro Saito
17
17
//
18
18
19
+ #include " multi_object_tracker/tracker/model/big_vehicle_tracker.hpp"
20
+ #include " multi_object_tracker/utils/utils.hpp"
21
+
22
+ #include < tier4_autoware_utils/geometry/boost_polygon_utils.hpp>
23
+ #include < tier4_autoware_utils/math/normalization.hpp>
24
+ #include < tier4_autoware_utils/math/unit_conversion.hpp>
25
+
19
26
#include < bits/stdc++.h>
20
27
#include < tf2/LinearMath/Matrix3x3.h>
21
28
#include < tf2/LinearMath/Quaternion.h>
26
33
#else
27
34
#include < tf2_geometry_msgs/tf2_geometry_msgs.hpp>
28
35
#endif
29
-
30
- #define EIGEN_MPL2_ONLY
31
- #include " multi_object_tracker/tracker/model/big_vehicle_tracker.hpp"
32
- #include " multi_object_tracker/utils/utils.hpp"
33
36
#include " object_recognition_utils/object_recognition_utils.hpp"
34
37
38
+ #define EIGEN_MPL2_ONLY
35
39
#include < Eigen/Core>
36
40
#include < Eigen/Geometry>
37
- #include < tier4_autoware_utils/geometry/boost_polygon_utils.hpp>
38
- #include < tier4_autoware_utils/math/normalization.hpp>
39
- #include < tier4_autoware_utils/math/unit_conversion.hpp>
40
41
41
42
using Label = autoware_auto_perception_msgs::msg::ObjectClassification;
42
43
@@ -99,7 +100,6 @@ BigVehicleTracker::BigVehicleTracker(
99
100
X (IDX::SLIP) = 0.0 ;
100
101
if (object.kinematics .has_twist ) {
101
102
X (IDX::VEL) = object.kinematics .twist_with_covariance .twist .linear .x ;
102
- // X(IDX::YAW) = object.kinematics.twist_with_covariance.twist.angular.z;
103
103
} else {
104
104
X (IDX::VEL) = 0.0 ;
105
105
}
@@ -149,9 +149,7 @@ BigVehicleTracker::BigVehicleTracker(
149
149
bounding_box_ = {
150
150
bbox_object.shape .dimensions .x , bbox_object.shape .dimensions .y ,
151
151
bbox_object.shape .dimensions .z };
152
- last_input_bounding_box_ = {
153
- bbox_object.shape .dimensions .x , bbox_object.shape .dimensions .y ,
154
- bbox_object.shape .dimensions .z };
152
+ last_input_bounding_box_ = bounding_box_;
155
153
}
156
154
ekf_.init (X, P);
157
155
@@ -265,16 +263,15 @@ bool BigVehicleTracker::predict(const double dt, KalmanFilter & ekf) const
265
263
q_stddev_yaw_rate = std::min (q_stddev_yaw_rate, ekf_params_.q_stddev_yaw_rate_max );
266
264
q_stddev_yaw_rate = std::max (q_stddev_yaw_rate, ekf_params_.q_stddev_yaw_rate_min );
267
265
}
268
- float q_cov_slip_rate{0.0 };
266
+ float q_cov_slip_rate{0 .0f };
269
267
if (vel <= 0.01 ) {
270
268
q_cov_slip_rate = ekf_params_.q_cov_slip_rate_min ;
271
269
} else {
270
+ // The slip angle rate uncertainty is modeled as follows:
271
+ // d(slip)/dt ~ - sin(slip)/v * d(v)/dt + l_r/v * d(w)/dt
272
272
// where sin(slip) = w * l_r / v
273
- // uncertainty of the slip angle rate is modeled as
274
- // d(slip)/dt ~ - w*l_r/v^2 * d(v)/dt + l_r/v * d(w)/dt
275
- // = - sin(slip)/v * d(v)/dt + l_r/v * d(w)/dt
276
- // d(w)/dt is modeled as proportional to w (more uncertain when slip is large)
277
- // d(v)/dt and d(w)/t is considered that those are not correlated
273
+ // d(w)/dt is assumed to be proportional to w (more uncertain when slip is large)
274
+ // d(v)/dt and d(w)/t are considered to be uncorrelated
278
275
q_cov_slip_rate =
279
276
std::pow (ekf_params_.q_stddev_acc_lat * sin_slip / vel, 2 ) + std::pow (sin_slip * 1.5 , 2 );
280
277
q_cov_slip_rate = std::min (q_cov_slip_rate, ekf_params_.q_cov_slip_rate_max );
@@ -317,14 +314,14 @@ bool BigVehicleTracker::measureWithPose(
317
314
float r_cov_y;
318
315
const uint8_t label = object_recognition_utils::getHighestProbLabel (object.classification );
319
316
320
- if (label == Label::CAR) {
317
+ if (utils::isLargeVehicleLabel (label)) {
318
+ r_cov_x = ekf_params_.r_cov_x ;
319
+ r_cov_y = ekf_params_.r_cov_y ;
320
+ } else if (label == Label::CAR) {
321
321
constexpr float r_stddev_x = 2.0 ; // [m]
322
322
constexpr float r_stddev_y = 2.0 ; // [m]
323
323
r_cov_x = std::pow (r_stddev_x, 2.0 );
324
324
r_cov_y = std::pow (r_stddev_y, 2.0 );
325
- } else if (utils::isLargeVehicleLabel (label)) {
326
- r_cov_x = ekf_params_.r_cov_x ;
327
- r_cov_y = ekf_params_.r_cov_y ;
328
325
} else {
329
326
r_cov_x = ekf_params_.r_cov_x ;
330
327
r_cov_y = ekf_params_.r_cov_y ;
@@ -364,7 +361,7 @@ bool BigVehicleTracker::measureWithPose(
364
361
last_input_bounding_box_.width , last_input_bounding_box_.length , last_nearest_corner_index_,
365
362
bbox_object, X_t (IDX::YAW), offset_object, tracking_offset_);
366
363
367
- /* Set measurement matrix */
364
+ /* Set measurement matrix and noise covariance */
368
365
Eigen::MatrixXd Y (dim_y, 1 );
369
366
Eigen::MatrixXd C = Eigen::MatrixXd::Zero (dim_y, ekf_params_.dim_x );
370
367
Eigen::MatrixXd R = Eigen::MatrixXd::Zero (dim_y, dim_y);
@@ -398,6 +395,7 @@ bool BigVehicleTracker::measureWithPose(
398
395
R (2 , 2 ) = object.kinematics .pose_with_covariance .covariance [utils::MSG_COV_IDX::YAW_YAW];
399
396
}
400
397
398
+ // Update the velocity when necessary
401
399
if (dim_y == 4 ) {
402
400
Y (IDX::VEL, 0 ) = object.kinematics .twist_with_covariance .twist .linear .x ;
403
401
C (3 , IDX::VEL) = 1.0 ; // for vel
@@ -409,7 +407,7 @@ bool BigVehicleTracker::measureWithPose(
409
407
}
410
408
}
411
409
412
- /* ekf tracks constant tracking point */
410
+ // ekf update
413
411
if (!ekf_.update (Y, C, R)) {
414
412
RCLCPP_WARN (logger_, " Cannot update" );
415
413
}
@@ -440,9 +438,8 @@ bool BigVehicleTracker::measureWithPose(
440
438
bool BigVehicleTracker::measureWithShape (
441
439
const autoware_auto_perception_msgs::msg::DetectedObject & object)
442
440
{
441
+ // if the input shape is convex type, convert it to bbox type
443
442
autoware_auto_perception_msgs::msg::DetectedObject bbox_object;
444
-
445
- // if input is convex shape convert it to bbox shape
446
443
if (object.shape .type != autoware_auto_perception_msgs::msg::Shape::BOUNDING_BOX) {
447
444
utils::convertConvexHullToBoundingBox (object, bbox_object);
448
445
} else {
@@ -565,6 +562,7 @@ bool BigVehicleTracker::getTrackedObject(
565
562
* wz = vel * sin(slip) / l_r = vy / l_r
566
563
*
567
564
*/
565
+
568
566
constexpr double vz_cov = 0.1 * 0.1 ; // TODO(yukkysaito) Currently tentative
569
567
constexpr double wx_cov = 0.1 * 0.1 ; // TODO(yukkysaito) Currently tentative
570
568
constexpr double wy_cov = 0.1 * 0.1 ; // TODO(yukkysaito) Currently tentative
@@ -599,7 +597,6 @@ bool BigVehicleTracker::getTrackedObject(
599
597
const auto ekf_pose_yaw = tf2::getYaw (pose_with_cov.pose .orientation );
600
598
object.shape .footprint =
601
599
tier4_autoware_utils::rotatePolygon (object.shape .footprint , origin_yaw - ekf_pose_yaw);
602
-
603
600
return true ;
604
601
}
605
602
0 commit comments