Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(behavior_velocity_run_out): construct predicted path up to max pr… #6650

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions planning/behavior_velocity_run_out_module/src/dynamic_obstacle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,31 @@
dynamic_obstacle.max_velocity_mps = max_velocity;
}

double convertDurationToDouble(const builtin_interfaces::msg::Duration & duration)
{
return duration.sec + duration.nanosec / 1e9;

Check warning on line 317 in planning/behavior_velocity_run_out_module/src/dynamic_obstacle.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_run_out_module/src/dynamic_obstacle.cpp#L317

Added line #L317 was not covered by tests
}

// Create a path leading up to a specified prediction time
std::vector<geometry_msgs::msg::Pose> createPathToPredictionTime(

Check warning on line 321 in planning/behavior_velocity_run_out_module/src/dynamic_obstacle.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_run_out_module/src/dynamic_obstacle.cpp#L321

Added line #L321 was not covered by tests
const autoware_auto_perception_msgs::msg::PredictedPath & predicted_path, double prediction_time)
{
// Calculate the number of poses to include based on the prediction time and the time step between
// poses
const double time_step_seconds = convertDurationToDouble(predicted_path.time_step);
const size_t poses_to_include =
std::min(static_cast<size_t>(prediction_time / time_step_seconds), predicted_path.path.size());

// Construct the path to the specified prediction time
std::vector<geometry_msgs::msg::Pose> path_to_prediction_time;
path_to_prediction_time.reserve(poses_to_include);
for (size_t i = 0; i < poses_to_include; ++i) {
path_to_prediction_time.push_back(predicted_path.path[i]);
}

return path_to_prediction_time;

Check warning on line 337 in planning/behavior_velocity_run_out_module/src/dynamic_obstacle.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_run_out_module/src/dynamic_obstacle.cpp#L337

Added line #L337 was not covered by tests
}

} // namespace

DynamicObstacleCreatorForObject::DynamicObstacleCreatorForObject(
Expand Down Expand Up @@ -343,8 +368,7 @@
for (const auto & path : predicted_object.kinematics.predicted_paths) {
PredictedPath predicted_path;
predicted_path.confidence = path.confidence;
predicted_path.path.resize(path.path.size());
std::copy(path.path.cbegin(), path.path.cend(), predicted_path.path.begin());
predicted_path.path = createPathToPredictionTime(path, param_.max_prediction_time);

dynamic_obstacle.predicted_paths.emplace_back(predicted_path);
}
Expand Down
Loading