Skip to content

Commit

Permalink
Merge pull request #1191 from tier4/feat/fix_lv4_bicicle_pedestrian_p…
Browse files Browse the repository at this point in the history
…rediction_issue

feat: fix lv4 bicycle pedestrian prediction issue
  • Loading branch information
TomohitoAndo authored Mar 29, 2024
2 parents fe0b657 + f10a592 commit c5066a0
Show file tree
Hide file tree
Showing 15 changed files with 869 additions and 485 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ ObjectClassification::_label_type changeLabelForPrediction(
// constraints
const bool within_road_lanelet = withinRoadLanelet(object, lanelet_map_ptr_, true);
const float high_speed_threshold =
tier4_autoware_utils::kmph2mps(25.0); // High speed bicycle 25 km/h
tier4_autoware_utils::kmph2mps(9.0); // For lv4 special tuning. High speed bicycle 9 km/h
// calc abs speed from x and y velocity
const double abs_speed = std::hypot(
object.kinematics.twist_with_covariance.twist.linear.x,
Expand All @@ -624,17 +624,17 @@ ObjectClassification::_label_type changeLabelForPrediction(
case ObjectClassification::PEDESTRIAN: {
const bool within_road_lanelet = withinRoadLanelet(object, lanelet_map_ptr_, true);
const float max_velocity_for_human_mps =
tier4_autoware_utils::kmph2mps(25.0); // Max human being motion speed is 25km/h
tier4_autoware_utils::kmph2mps(9.0); // Max human being motion speed is 25km/h
const double abs_speed = std::hypot(
object.kinematics.twist_with_covariance.twist.linear.x,
object.kinematics.twist_with_covariance.twist.linear.y);
const bool high_speed_object = abs_speed > max_velocity_for_human_mps;
// fast, human-like object: like segway
if (within_road_lanelet && high_speed_object) return label; // currently do nothing
// return ObjectClassification::MOTORCYCLE;
if (high_speed_object) return label; // currently do nothing
// fast human outside road lanelet will move like unknown object
// return ObjectClassification::UNKNOWN;
if (within_road_lanelet && high_speed_object) // return label; // currently do nothing
return ObjectClassification::MOTORCYCLE;
if (high_speed_object) // return label; // currently do nothing
// fast human outside road lanelet will move like unknown object
return ObjectClassification::UNKNOWN;
return label;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ class BicycleTracker : public Tracker
private:
KalmanFilter ekf_;
rclcpp::Time last_update_time_;
enum IDX { X = 0, Y = 1, YAW = 2, VX = 3, SLIP = 4 };
enum IDX { X = 0, Y = 1, YAW = 2, VEL = 3, SLIP = 4 };
struct EkfParams
{
char dim_x = 5;
float q_cov_x;
float q_cov_y;
float q_cov_yaw;
float q_cov_slip;
float q_cov_vx;
float p0_cov_vx;
float q_stddev_acc_long;
float q_stddev_acc_lat;
float q_stddev_yaw_rate_min;
float q_stddev_yaw_rate_max;
float q_cov_slip_rate_min;
float q_cov_slip_rate_max;
float q_max_slip_angle;
float p0_cov_vel;
float p0_cov_slip;
float r_cov_x;
float r_cov_y;
Expand All @@ -51,7 +53,7 @@ class BicycleTracker : public Tracker
float p0_cov_yaw;
} ekf_params_;

double max_vx_;
double max_vel_;
double max_slip_;
double lf_;
double lr_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,28 @@ class BigVehicleTracker : public Tracker
private:
KalmanFilter ekf_;
rclcpp::Time last_update_time_;
enum IDX { X = 0, Y = 1, YAW = 2, VX = 3, SLIP = 4 };
enum IDX { X = 0, Y = 1, YAW = 2, VEL = 3, SLIP = 4 };
struct EkfParams
{
char dim_x = 5;
float q_cov_x;
float q_cov_y;
float q_cov_yaw;
float q_cov_slip;
float q_cov_vx;
float p0_cov_vx;
float q_stddev_acc_long;
float q_stddev_acc_lat;
float q_stddev_yaw_rate_min;
float q_stddev_yaw_rate_max;
float q_cov_slip_rate_min;
float q_cov_slip_rate_max;
float q_max_slip_angle;
float p0_cov_vel;
float p0_cov_slip;
float r_cov_x;
float r_cov_y;
float r_cov_yaw;
float r_cov_vx;
float r_cov_vel;
float p0_cov_x;
float p0_cov_y;
float p0_cov_yaw;
} ekf_params_;
double max_vx_;
double max_vel_;
double max_slip_;
double lf_;
double lr_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,30 @@ class NormalVehicleTracker : public Tracker
private:
KalmanFilter ekf_;
rclcpp::Time last_update_time_;
enum IDX { X = 0, Y = 1, YAW = 2, VX = 3, SLIP = 4 };
enum IDX { X = 0, Y = 1, YAW = 2, VEL = 3, SLIP = 4 };

struct EkfParams
{
char dim_x = 5;
float q_cov_x;
float q_cov_y;
float q_cov_yaw;
float q_cov_slip;
float q_cov_vx;
float p0_cov_vx;
float q_stddev_acc_long;
float q_stddev_acc_lat;
float q_stddev_yaw_rate_min;
float q_stddev_yaw_rate_max;
float q_cov_slip_rate_min;
float q_cov_slip_rate_max;
float q_max_slip_angle;
float p0_cov_vel;
float p0_cov_slip;
float r_cov_x;
float r_cov_y;
float r_cov_yaw;
float r_cov_vx;
float r_cov_vel;
float p0_cov_x;
float p0_cov_y;
float p0_cov_yaw;
} ekf_params_;

double max_vx_;
double max_vel_;
double max_slip_;
double lf_;
double lr_;
Expand Down Expand Up @@ -88,6 +90,7 @@ class NormalVehicleTracker : public Tracker
const rclcpp::Time & time,
autoware_auto_perception_msgs::msg::TrackedObject & object) const override;
void setNearestCornerOrSurfaceIndex(const geometry_msgs::msg::Transform & self_transform);
double getMeasurementYaw(const autoware_auto_perception_msgs::msg::DetectedObject & object);
virtual ~NormalVehicleTracker() {}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class Tracker
{
classification_ = classification;
}
void updateClassification(
const std::vector<autoware_auto_perception_msgs::msg::ObjectClassification> & classification);

private:
unique_identifier_msgs::msg::UUID uuid_;
Expand Down
45 changes: 27 additions & 18 deletions perception/multi_object_tracker/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ CTRV model is a model that assumes constant turn rate and velocity magnitude.
- state transition equation

$$
\begin{align*}
x_{k+1} &= x_k + v_{x_k} \cos(\psi_k) \cdot dt \\
y_{k+1} &= y_k + v_{x_k} \sin(\psi_k) \cdot dt \\
\psi_{k+1} &= \psi_k + \dot{\psi}_k \cdot dt \\
v_{x_{k+1}} &= v_{x_k} \\
\dot{\psi}_{k+1} &= \dot{\psi}_k \\
\end{align*}
\begin{aligned}
x_{k+1} & = x_{k} + v_{k} \cos(\psi_k) \cdot {d t} \\
y_{k+1} & = y_{k} + v_{k} \sin(\psi_k) \cdot {d t} \\
\psi_{k+1} & = \psi_k + \dot\psi_{k} \cdot {d t} \\
v_{k+1} & = v_{k} \\
\dot\psi_{k+1} & = \dot\psi_{k} \\
\end{aligned}
$$

- jacobian

$$
A = \begin{bmatrix}
1 & 0 & -v_x \sin(\psi) \cdot dt & \cos(\psi) \cdot dt & 0 \\
0 & 1 & v_x \cos(\psi) \cdot dt & \sin(\psi) \cdot dt & 0 \\
1 & 0 & -v \sin(\psi) \cdot dt & \cos(\psi) \cdot dt & 0 \\
0 & 1 & v \cos(\psi) \cdot dt & \sin(\psi) \cdot dt & 0 \\
0 & 0 & 1 & 0 & dt \\
0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 0 & 1 \\
Expand All @@ -40,17 +40,20 @@ The merit of using this model is that it can prevent unintended yaw rotation whe
![kinematic_bicycle_model](image/kinematic_bicycle_model.png)

- **state variable**
- pose( $x,y$ ), velocity( $v$ ), yaw( $\psi$ ), and slip angle ( $\beta$ )
- $[x_{k} ,y_{k} , v_{k} , \psi_{k} , \beta_{k} ]^\mathrm{T}$
- pose( $x,y$ ), yaw( $\psi$ ), velocity( $v$ ), and slip angle ( $\beta$ )
- $[x_{k}, y_{k}, \psi_{k}, v_{k}, \beta_{k} ]^\mathrm{T}$
- **Prediction Equation**
- $dt$: sampling time
- $w_{k} = \dot\psi_{k} = \frac{ v_{k} \sin \left( \beta_{k} \right) }{ l_r }$ : angular velocity

$$
\begin{aligned}
x_{k+1} & =x_{k}+v_{k} \cos \left(\psi_{k}+\beta_{k}\right) d t \\
y_{k+1} & =y_{k}+v_{k} \sin \left(\psi_{k}+\beta_{k}\right) d t \\
v_{k+1} & =v_{k} \\
\psi_{k+1} & =\psi_{k}+\frac{v_{k}}{l_{r}} \sin \beta_{k} d t \\
x_{k+1} & = x_{k} + v_{k} \cos \left( \psi_{k}+\beta_{k} \right) {d t}
-\frac{1}{2} \left\lbrace w_k v_k \sin \left(\psi_{k}+\beta_{k} \right) \right\rbrace {d t}^2\\
y_{k+1} & = y_{k} + v_{k} \sin \left( \psi_{k}+\beta_{k} \right) {d t}
+\frac{1}{2} \left\lbrace w_k v_k \cos \left(\psi_{k}+\beta_{k} \right) \right\rbrace {d t}^2\\
\psi_{k+1} & =\psi_{k} + w_k {d t} \\
v_{k+1} & = v_{k} \\
\beta_{k+1} & =\beta_{k}
\end{aligned}
$$
Expand All @@ -59,9 +62,15 @@ $$

$$
\frac{\partial f}{\partial \mathrm x}=\left[\begin{array}{ccccc}
1 & 0 & -v \sin (\psi+\beta) d t & v \cos (\psi+\beta) & -v \sin (\psi+\beta) d t \\
0 & 1 & v \cos (\psi+\beta) d t & v \sin (\psi+\beta) & v \cos (\psi+\beta) d t \\
0 & 0 & 1 & \frac{1}{l_r} \sin \beta d t & \frac{v}{l_r} \cos \beta d t \\
1 & 0
& v \cos (\psi+\beta) {d t} - \frac{1}{2} \left\lbrace w v \cos \left( \psi+\beta \right) \right\rbrace {d t}^2
& \sin (\psi+\beta) {d t} - \left\lbrace w \sin \left( \psi+\beta \right) \right\rbrace {d t}^2
& -v \sin (\psi+\beta) {d t} - \frac{v^2}{2l_r} \left\lbrace \cos(\beta)\sin(\psi+\beta)+\sin(\beta)\cos(\psi+\beta) \right\rbrace {d t}^2 \\
0 & 1
& v \sin (\psi+\beta) {d t} - \frac{1}{2} \left\lbrace w v \sin \left( \psi+\beta \right) \right\rbrace {d t}^2
& \cos (\psi+\beta) {d t} + \left\lbrace w \cos \left( \psi+\beta \right) \right\rbrace {d t}^2
& v \cos (\psi+\beta) {d t} + \frac{v^2}{2l_r} \left\lbrace \cos(\beta)\cos(\psi+\beta)-\sin(\beta)\sin(\psi+\beta) \right\rbrace {d t}^2 \\
0 & 0 & 1 & \frac{1}{l_r} \sin \beta {d t} & \frac{v}{l_r} \cos \beta d t \\
0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 0 & 1
\end{array}\right]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Eigen::MatrixXd DataAssociation::calcScoreMatrix(
measurement_object.kinematics.pose_with_covariance.pose.position,
tracked_object.kinematics.pose_with_covariance.pose.position,
getXYCovariance(tracked_object.kinematics.pose_with_covariance));
if (2.448 /*95%*/ <= mahalanobis_dist) passed_gate = false;
if (3.035 /*99%*/ <= mahalanobis_dist) passed_gate = false;
}
// 2d iou gate
if (passed_gate) {
Expand Down
Loading

0 comments on commit c5066a0

Please sign in to comment.