Skip to content

Commit 0707fcd

Browse files
committed
fix(behavior_velocity_run_out): construct predicted path up to max prediction time in object method
Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp>
1 parent 152b11e commit 0707fcd

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

planning/behavior_velocity_run_out_module/src/dynamic_obstacle.cpp

+26-2
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,31 @@ void calculateMinAndMaxVelFromCovariance(
312312
dynamic_obstacle.max_velocity_mps = max_velocity;
313313
}
314314

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+
315340
} // namespace
316341

317342
DynamicObstacleCreatorForObject::DynamicObstacleCreatorForObject(
@@ -343,8 +368,7 @@ std::vector<DynamicObstacle> DynamicObstacleCreatorForObject::createDynamicObsta
343368
for (const auto & path : predicted_object.kinematics.predicted_paths) {
344369
PredictedPath predicted_path;
345370
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);
348372

349373
dynamic_obstacle.predicted_paths.emplace_back(predicted_path);
350374
}

0 commit comments

Comments
 (0)