Skip to content

Commit a6c6912

Browse files
authored
feat(perception_online_evaluator): imporve yaw rate metrics considering flip (#6881)
* feat(perception_online_evaluator): imporve yaw rate metrics considering flip Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * fix test Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> --------- Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
1 parent 41bee43 commit a6c6912

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

evaluator/perception_online_evaluator/src/metrics_calculator.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -442,13 +442,12 @@ MetricStatMap MetricsCalculator::calcYawRateMetrics(const ClassObjectsMap & clas
442442
tf2::getYaw(object.kinematics.initial_pose_with_covariance.pose.orientation);
443443
const double previous_yaw =
444444
tf2::getYaw(previous_object.kinematics.initial_pose_with_covariance.pose.orientation);
445+
// Calculate the absolute difference between current_yaw and previous_yaw
445446
const double yaw_diff =
446447
std::abs(tier4_autoware_utils::normalizeRadian(current_yaw - previous_yaw));
447-
// if yaw_diff is close to PI, reversal of orientation is likely occurring, so ignore it
448-
if (std::abs(M_PI - yaw_diff) < 0.1) {
449-
continue;
450-
}
451-
const auto yaw_rate = yaw_diff / time_diff;
448+
// The yaw difference is flipped if the angle is larger than 90 degrees
449+
const double yaw_diff_flip_fixed = std::min(yaw_diff, M_PI - yaw_diff);
450+
const double yaw_rate = yaw_diff_flip_fixed / time_diff;
452451
stat.add(yaw_rate);
453452
}
454453
metric_stat_map["yaw_rate_" + convertLabelToString(label)] = stat;

evaluator/perception_online_evaluator/test/test_perception_online_evaluator_node.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,8 @@ TEST_F(EvalTest, testYawRate_5)
924924
setTargetMetric("yaw_rate_CAR");
925925

926926
const double yaw_rate = 5.0;
927+
const double yaw_rate_flip_fixed =
928+
std::min(yaw_rate, (M_PI - yaw_rate * time_step_) / time_step_);
927929

928930
for (double time = 0; time <= time_delay_ + 0.01; time += time_step_) {
929931
const auto objects = rotateObjects(
@@ -936,7 +938,7 @@ TEST_F(EvalTest, testYawRate_5)
936938
const auto objects = rotateObjects(
937939
makeStraightPredictedObjects(time, ObjectClassification::CAR, 0.0), yaw_rate * time);
938940
publishEgoTF(time);
939-
EXPECT_NEAR(publishObjectsAndGetMetric(objects), yaw_rate, epsilon);
941+
EXPECT_NEAR(publishObjectsAndGetMetric(objects), yaw_rate_flip_fixed, epsilon);
940942
}
941943
}
942944

@@ -946,6 +948,8 @@ TEST_F(EvalTest, testYawRate_minus_5)
946948
setTargetMetric("yaw_rate_CAR");
947949

948950
const double yaw_rate = 5.0;
951+
const double yaw_rate_flip_fixed =
952+
std::min(yaw_rate, (M_PI - yaw_rate * time_step_) / time_step_);
949953

950954
for (double time = 0; time <= time_delay_ + 0.01; time += time_step_) {
951955
const auto objects = rotateObjects(
@@ -958,7 +962,7 @@ TEST_F(EvalTest, testYawRate_minus_5)
958962
const auto objects = rotateObjects(
959963
makeStraightPredictedObjects(time, ObjectClassification::CAR, 0.0), -yaw_rate * time);
960964
publishEgoTF(time);
961-
EXPECT_NEAR(publishObjectsAndGetMetric(objects), yaw_rate, epsilon);
965+
EXPECT_NEAR(publishObjectsAndGetMetric(objects), yaw_rate_flip_fixed, epsilon);
962966
}
963967
}
964968
// ==========================================================================================

0 commit comments

Comments
 (0)