@@ -312,6 +312,31 @@ void calculateMinAndMaxVelFromCovariance(
312
312
dynamic_obstacle.max_velocity_mps = max_velocity;
313
313
}
314
314
315
+ double convertDurationToDouble (const builtin_interfaces::msg::Duration & duration)
316
+ {
317
+ return duration.sec + duration.nanosec / 1e9 ;
318
+ }
319
+
320
+ // Create a path leading up to a specified prediction time
321
+ std::vector<geometry_msgs::msg::Pose> createPathToPredictionTime (
322
+ const autoware_auto_perception_msgs::msg::PredictedPath & predicted_path, double prediction_time)
323
+ {
324
+ // Calculate the number of poses to include based on the prediction time and the time step between
325
+ // poses
326
+ const double time_step_seconds = convertDurationToDouble (predicted_path.time_step );
327
+ const size_t poses_to_include =
328
+ std::min (static_cast <size_t >(prediction_time / time_step_seconds), predicted_path.path .size ());
329
+
330
+ // Construct the path to the specified prediction time
331
+ std::vector<geometry_msgs::msg::Pose> path_to_prediction_time;
332
+ path_to_prediction_time.reserve (poses_to_include);
333
+ for (size_t i = 0 ; i < poses_to_include; ++i) {
334
+ path_to_prediction_time.push_back (predicted_path.path [i]);
335
+ }
336
+
337
+ return path_to_prediction_time;
338
+ }
339
+
315
340
} // namespace
316
341
317
342
DynamicObstacleCreatorForObject::DynamicObstacleCreatorForObject (
@@ -343,8 +368,7 @@ std::vector<DynamicObstacle> DynamicObstacleCreatorForObject::createDynamicObsta
343
368
for (const auto & path : predicted_object.kinematics .predicted_paths ) {
344
369
PredictedPath predicted_path;
345
370
predicted_path.confidence = path.confidence ;
346
- predicted_path.path .resize (path.path .size ());
347
- std::copy (path.path .cbegin (), path.path .cend (), predicted_path.path .begin ());
371
+ predicted_path.path = createPathToPredictionTime (path, param_.max_prediction_time );
348
372
349
373
dynamic_obstacle.predicted_paths .emplace_back (predicted_path);
350
374
}
0 commit comments