15
15
#include " perception_online_evaluator/metrics_calculator.hpp"
16
16
17
17
#include " motion_utils/trajectory/trajectory.hpp"
18
- #include " perception_online_evaluator/utils/objects_filtering .hpp"
18
+ #include " object_recognition_utils/object_recognition_utils .hpp"
19
19
#include " tier4_autoware_utils/geometry/geometry.hpp"
20
20
21
21
#include < tier4_autoware_utils/ros/uuid_helper.hpp>
22
22
23
23
namespace perception_diagnostics
24
24
{
25
+ using object_recognition_utils::convertLabelToString;
26
+
25
27
std::optional<MetricStatMap> MetricsCalculator::calculate (const Metric & metric) const
26
28
{
27
29
if (object_map_.empty ()) {
@@ -35,14 +37,19 @@ std::optional<MetricStatMap> MetricsCalculator::calculate(const Metric & metric)
35
37
return {};
36
38
}
37
39
const auto target_objects = getObjectsByStamp (target_stamp);
40
+ const ClassObjectsMap class_objects_map = separateObjectsByClass (target_objects);
41
+
42
+ // print class and size
43
+ for (const auto [label, objects] : class_objects_map) {
44
+ }
38
45
39
46
switch (metric) {
40
47
case Metric::lateral_deviation:
41
- return calcLateralDeviationMetrics (target_objects );
48
+ return calcLateralDeviationMetrics (class_objects_map );
42
49
case Metric::yaw_deviation:
43
- return calcYawDeviationMetrics (target_objects );
50
+ return calcYawDeviationMetrics (class_objects_map );
44
51
case Metric::predicted_path_deviation:
45
- return calcPredictedPathDeviationMetrics (target_objects );
52
+ return calcPredictedPathDeviationMetrics (class_objects_map );
46
53
default :
47
54
return {};
48
55
}
@@ -155,65 +162,70 @@ PredictedObjects MetricsCalculator::getObjectsByStamp(const rclcpp::Time stamp)
155
162
return objects;
156
163
}
157
164
158
- MetricStatMap MetricsCalculator::calcLateralDeviationMetrics (const PredictedObjects & objects) const
165
+ MetricStatMap MetricsCalculator::calcLateralDeviationMetrics (
166
+ const ClassObjectsMap & class_objects_map) const
159
167
{
160
- Stat<double > stat{};
161
- const auto stamp = rclcpp::Time (objects.header .stamp );
162
-
163
- for (const auto & object : objects.objects ) {
164
- const auto uuid = tier4_autoware_utils::toHexString (object.object_id );
165
- if (!hasPassedTime (uuid, stamp)) {
166
- continue ;
167
- }
168
- const auto object_pose = object.kinematics .initial_pose_with_covariance .pose ;
169
- const auto history_path = history_path_map_.at (uuid).second ;
170
- if (history_path.empty ()) {
171
- continue ;
168
+ MetricStatMap metric_stat_map{};
169
+ for (const auto [label, objects] : class_objects_map) {
170
+ Stat<double > stat{};
171
+ const auto stamp = rclcpp::Time (objects.header .stamp );
172
+ for (const auto & object : objects.objects ) {
173
+ const auto uuid = tier4_autoware_utils::toHexString (object.object_id );
174
+ if (!hasPassedTime (uuid, stamp)) {
175
+ continue ;
176
+ }
177
+ const auto object_pose = object.kinematics .initial_pose_with_covariance .pose ;
178
+ const auto history_path = history_path_map_.at (uuid).second ;
179
+ if (history_path.empty ()) {
180
+ continue ;
181
+ }
182
+ stat.add (metrics::calcLateralDeviation (history_path, object_pose));
172
183
}
173
- stat. add ( metrics::calcLateralDeviation (history_path, object_pose)) ;
184
+ metric_stat_map[ " lateral_deviation_ " + convertLabelToString (label)] = stat ;
174
185
}
175
-
176
- MetricStatMap metric_stat_map;
177
- metric_stat_map[" lateral_deviation" ] = stat;
178
186
return metric_stat_map;
179
187
}
180
188
181
- MetricStatMap MetricsCalculator::calcYawDeviationMetrics (const PredictedObjects & objects) const
189
+ MetricStatMap MetricsCalculator::calcYawDeviationMetrics (
190
+ const ClassObjectsMap & class_objects_map) const
182
191
{
183
- Stat<double > stat{};
184
- const auto stamp = rclcpp::Time (objects.header .stamp );
185
- for (const auto & object : objects.objects ) {
186
- const auto uuid = tier4_autoware_utils::toHexString (object.object_id );
187
- if (!hasPassedTime (uuid, stamp)) {
188
- continue ;
189
- }
190
- const auto object_pose = object.kinematics .initial_pose_with_covariance .pose ;
191
- const auto history_path = history_path_map_.at (uuid).second ;
192
- if (history_path.empty ()) {
193
- continue ;
192
+ MetricStatMap metric_stat_map{};
193
+ for (const auto [label, objects] : class_objects_map) {
194
+ Stat<double > stat{};
195
+ const auto stamp = rclcpp::Time (objects.header .stamp );
196
+ for (const auto & object : objects.objects ) {
197
+ const auto uuid = tier4_autoware_utils::toHexString (object.object_id );
198
+ if (!hasPassedTime (uuid, stamp)) {
199
+ continue ;
200
+ }
201
+ const auto object_pose = object.kinematics .initial_pose_with_covariance .pose ;
202
+ const auto history_path = history_path_map_.at (uuid).second ;
203
+ if (history_path.empty ()) {
204
+ continue ;
205
+ }
206
+ stat.add (metrics::calcYawDeviation (history_path, object_pose));
194
207
}
195
- stat. add ( metrics::calcYawDeviation (history_path, object_pose)) ;
208
+ metric_stat_map[ " yaw_deviation_ " + convertLabelToString (label)] = stat ;
196
209
}
197
-
198
- MetricStatMap metric_stat_map;
199
- metric_stat_map[" yaw_deviation" ] = stat;
200
210
return metric_stat_map;
201
211
}
202
212
203
213
MetricStatMap MetricsCalculator::calcPredictedPathDeviationMetrics (
204
- const PredictedObjects & objects ) const
214
+ const ClassObjectsMap & class_objects_map ) const
205
215
{
206
216
const auto time_horizons = parameters_->prediction_time_horizons ;
207
217
208
- MetricStatMap metric_stat_map;
209
- for (const double time_horizon : time_horizons) {
210
- const auto stat = calcPredictedPathDeviationMetrics (objects, time_horizon);
211
- std::ostringstream stream;
212
- stream << std::fixed << std::setprecision (2 ) << time_horizon;
213
- std::string time_horizon_str = stream.str ();
214
- metric_stat_map[" predicted_path_deviation_" + time_horizon_str] = stat;
218
+ MetricStatMap metric_stat_map{};
219
+ for (const auto [label, objects] : class_objects_map) {
220
+ for (const double time_horizon : time_horizons) {
221
+ const auto stat = calcPredictedPathDeviationMetrics (objects, time_horizon);
222
+ std::ostringstream stream;
223
+ stream << std::fixed << std::setprecision (2 ) << time_horizon;
224
+ std::string time_horizon_str = stream.str ();
225
+ metric_stat_map
226
+ [" predicted_path_deviation_" + convertLabelToString (label) + " _" + time_horizon_str] = stat;
227
+ }
215
228
}
216
-
217
229
return metric_stat_map;
218
230
}
219
231
0 commit comments