-
Notifications
You must be signed in to change notification settings - Fork 661
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
feat(obstacle_cruise_planner): yield function for ocp #6242
feat(obstacle_cruise_planner): yield function for ocp #6242
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #6242 +/- ##
==========================================
- Coverage 14.91% 14.90% -0.02%
==========================================
Files 1817 1817
Lines 125357 125452 +95
Branches 37640 37697 +57
==========================================
Hits 18697 18697
- Misses 85651 85739 +88
- Partials 21009 21016 +7
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. |
bool isFrontObstacle( | ||
const std::vector<TrajectoryPoint> & traj_points, const size_t ego_idx, | ||
const geometry_msgs::msg::Point & obstacle_pos) | ||
const geometry_msgs::msg::Point & obstacle_pos, double * ego_to_obstacle_distance) | ||
{ | ||
const size_t obstacle_idx = motion_utils::findNearestIndex(traj_points, obstacle_pos); | ||
|
||
const double ego_to_obstacle_distance = | ||
motion_utils::calcSignedArcLength(traj_points, ego_idx, obstacle_idx); | ||
|
||
if (ego_to_obstacle_distance < 0) { | ||
return false; | ||
} | ||
|
||
return true; | ||
*ego_to_obstacle_distance = motion_utils::calcSignedArcLength(traj_points, ego_idx, obstacle_idx); | ||
return *ego_to_obstacle_distance >= 0.0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reference argument is not recommended.
How about renaming the function to calcDistanceToFrontVehicle
or something whose return value's type is std::optional<double>
and return std::nullopt if the vehicle is not a front vehicle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks for the suggestion!
@@ -491,9 +509,19 @@ void ObstacleCruisePlannerNode::onTrajectory(const Trajectory::ConstSharedPtr ms | |||
// (1) with a proper label | |||
// (2) in front of ego | |||
// (3) not too far from trajectory | |||
const auto target_obstacles = convertToObstacles(traj_points); | |||
const auto target_obstacles = [&]() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to rename to sorted_target_obstacles, so that other people will know this variable's order has an implicit meaning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to refactor a little and sort the moving and stopped obstacles in the findYieldCruiseObstacles function instead. I think it makes the code easier to read and it makes more sense semantically. Please let me know if you agree.
double lat_dist_from_obstacle_to_traj; | ||
const double min_lat_dist_to_traj_poly = [&]() { | ||
const double lat_dist_from_obstacle_to_traj = | ||
lat_dist_from_obstacle_to_traj = | ||
motion_utils::calcLateralOffset(traj_points, current_obstacle_pose.pose.position); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const double lat_dist_from_obstacle_to_traj =
motion_utils::calcLateralOffset(traj_points, current_obstacle_pose.pose.position);
can be moved to the outside of the lambda function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Thanks for the review
5515d35
to
71755e1
Compare
RCLCPP_INFO_EXPRESSION( | ||
get_logger(), enable_debug_info_, "Ignore obstacle (%s) since it is not front obstacle.", | ||
object_id.c_str()); | ||
continue; | ||
} | ||
|
||
// 3. Check if rough lateral distance is smaller than the threshold | ||
double lat_dist_from_obstacle_to_traj = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double lat_dist_from_obstacle_to_traj = | |
const double lat_dist_from_obstacle_to_traj = |
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
Signed-off-by: Daniel Sanchez <[email protected]>
47d64b6
to
8ee7e7a
Compare
6b884ea
into
autowarefoundation:main
…tion#6242) * WIP make ego yield to cut in vehicles Signed-off-by: Daniel Sanchez <[email protected]> * param name change Signed-off-by: Daniel Sanchez <[email protected]> * add params Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * fix bug for distance comparison Signed-off-by: Daniel Sanchez <[email protected]> * implement a collision time check for yield candidates Signed-off-by: Daniel Sanchez <[email protected]> * deleting comments Signed-off-by: Daniel Sanchez <[email protected]> * comment out prints for test Signed-off-by: Daniel Sanchez <[email protected]> * delete comments, use param Signed-off-by: Daniel Sanchez <[email protected]> * Add param to set moving obstacle speed threshold Signed-off-by: Daniel Sanchez <[email protected]> * WIP check for cars going opposite direction Signed-off-by: Daniel Sanchez <[email protected]> * check opposite line driving Signed-off-by: Daniel Sanchez <[email protected]> * update documentation Signed-off-by: Daniel Sanchez <[email protected]> * update README Signed-off-by: Daniel Sanchez <[email protected]> * set default false Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * refactor isFrontObstacle Signed-off-by: Daniel Sanchez <[email protected]> * make const Signed-off-by: Daniel Sanchez <[email protected]> --------- Signed-off-by: Daniel Sanchez <[email protected]> Signed-off-by: Daniel Sanchez <[email protected]>
…tion#6242) * WIP make ego yield to cut in vehicles Signed-off-by: Daniel Sanchez <[email protected]> * param name change Signed-off-by: Daniel Sanchez <[email protected]> * add params Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * fix bug for distance comparison Signed-off-by: Daniel Sanchez <[email protected]> * implement a collision time check for yield candidates Signed-off-by: Daniel Sanchez <[email protected]> * deleting comments Signed-off-by: Daniel Sanchez <[email protected]> * comment out prints for test Signed-off-by: Daniel Sanchez <[email protected]> * delete comments, use param Signed-off-by: Daniel Sanchez <[email protected]> * Add param to set moving obstacle speed threshold Signed-off-by: Daniel Sanchez <[email protected]> * WIP check for cars going opposite direction Signed-off-by: Daniel Sanchez <[email protected]> * check opposite line driving Signed-off-by: Daniel Sanchez <[email protected]> * update documentation Signed-off-by: Daniel Sanchez <[email protected]> * update README Signed-off-by: Daniel Sanchez <[email protected]> * set default false Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * refactor isFrontObstacle Signed-off-by: Daniel Sanchez <[email protected]> * make const Signed-off-by: Daniel Sanchez <[email protected]> --------- Signed-off-by: Daniel Sanchez <[email protected]> Signed-off-by: Daniel Sanchez <[email protected]>
…tion#6242) * WIP make ego yield to cut in vehicles Signed-off-by: Daniel Sanchez <[email protected]> * param name change Signed-off-by: Daniel Sanchez <[email protected]> * add params Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * fix bug for distance comparison Signed-off-by: Daniel Sanchez <[email protected]> * implement a collision time check for yield candidates Signed-off-by: Daniel Sanchez <[email protected]> * deleting comments Signed-off-by: Daniel Sanchez <[email protected]> * comment out prints for test Signed-off-by: Daniel Sanchez <[email protected]> * delete comments, use param Signed-off-by: Daniel Sanchez <[email protected]> * Add param to set moving obstacle speed threshold Signed-off-by: Daniel Sanchez <[email protected]> * WIP check for cars going opposite direction Signed-off-by: Daniel Sanchez <[email protected]> * check opposite line driving Signed-off-by: Daniel Sanchez <[email protected]> * update documentation Signed-off-by: Daniel Sanchez <[email protected]> * update README Signed-off-by: Daniel Sanchez <[email protected]> * set default false Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * refactor isFrontObstacle Signed-off-by: Daniel Sanchez <[email protected]> * make const Signed-off-by: Daniel Sanchez <[email protected]> --------- Signed-off-by: Daniel Sanchez <[email protected]> Signed-off-by: Daniel Sanchez <[email protected]>
…tion#6242) * WIP make ego yield to cut in vehicles Signed-off-by: Daniel Sanchez <[email protected]> * param name change Signed-off-by: Daniel Sanchez <[email protected]> * add params Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * fix bug for distance comparison Signed-off-by: Daniel Sanchez <[email protected]> * implement a collision time check for yield candidates Signed-off-by: Daniel Sanchez <[email protected]> * deleting comments Signed-off-by: Daniel Sanchez <[email protected]> * comment out prints for test Signed-off-by: Daniel Sanchez <[email protected]> * delete comments, use param Signed-off-by: Daniel Sanchez <[email protected]> * Add param to set moving obstacle speed threshold Signed-off-by: Daniel Sanchez <[email protected]> * WIP check for cars going opposite direction Signed-off-by: Daniel Sanchez <[email protected]> * check opposite line driving Signed-off-by: Daniel Sanchez <[email protected]> * update documentation Signed-off-by: Daniel Sanchez <[email protected]> * update README Signed-off-by: Daniel Sanchez <[email protected]> * set default false Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * refactor isFrontObstacle Signed-off-by: Daniel Sanchez <[email protected]> * make const Signed-off-by: Daniel Sanchez <[email protected]> --------- Signed-off-by: Daniel Sanchez <[email protected]> Signed-off-by: Daniel Sanchez <[email protected]>
feat(obstacle_cruise_planner): yield function for ocp (autowarefoundation#6242)
…tion#6242) * WIP make ego yield to cut in vehicles Signed-off-by: Daniel Sanchez <[email protected]> * param name change Signed-off-by: Daniel Sanchez <[email protected]> * add params Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * fix bug for distance comparison Signed-off-by: Daniel Sanchez <[email protected]> * implement a collision time check for yield candidates Signed-off-by: Daniel Sanchez <[email protected]> * deleting comments Signed-off-by: Daniel Sanchez <[email protected]> * comment out prints for test Signed-off-by: Daniel Sanchez <[email protected]> * delete comments, use param Signed-off-by: Daniel Sanchez <[email protected]> * Add param to set moving obstacle speed threshold Signed-off-by: Daniel Sanchez <[email protected]> * WIP check for cars going opposite direction Signed-off-by: Daniel Sanchez <[email protected]> * check opposite line driving Signed-off-by: Daniel Sanchez <[email protected]> * update documentation Signed-off-by: Daniel Sanchez <[email protected]> * update README Signed-off-by: Daniel Sanchez <[email protected]> * set default false Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * refactor isFrontObstacle Signed-off-by: Daniel Sanchez <[email protected]> * make const Signed-off-by: Daniel Sanchez <[email protected]> --------- Signed-off-by: Daniel Sanchez <[email protected]> Signed-off-by: Daniel Sanchez <[email protected]>
…tion#6242) * WIP make ego yield to cut in vehicles Signed-off-by: Daniel Sanchez <[email protected]> * param name change Signed-off-by: Daniel Sanchez <[email protected]> * add params Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * fix bug for distance comparison Signed-off-by: Daniel Sanchez <[email protected]> * implement a collision time check for yield candidates Signed-off-by: Daniel Sanchez <[email protected]> * deleting comments Signed-off-by: Daniel Sanchez <[email protected]> * comment out prints for test Signed-off-by: Daniel Sanchez <[email protected]> * delete comments, use param Signed-off-by: Daniel Sanchez <[email protected]> * Add param to set moving obstacle speed threshold Signed-off-by: Daniel Sanchez <[email protected]> * WIP check for cars going opposite direction Signed-off-by: Daniel Sanchez <[email protected]> * check opposite line driving Signed-off-by: Daniel Sanchez <[email protected]> * update documentation Signed-off-by: Daniel Sanchez <[email protected]> * update README Signed-off-by: Daniel Sanchez <[email protected]> * set default false Signed-off-by: Daniel Sanchez <[email protected]> * refactor Signed-off-by: Daniel Sanchez <[email protected]> * refactor isFrontObstacle Signed-off-by: Daniel Sanchez <[email protected]> * make const Signed-off-by: Daniel Sanchez <[email protected]> --------- Signed-off-by: Daniel Sanchez <[email protected]> Signed-off-by: Daniel Sanchez <[email protected]>
Description
This PR adds an (optional) yield functionality for the obstacle cruise planner. The yield action is performed by cruising behind vehicles on neighbor lanes that might cut in into the ego vehicle's current lane.
How it works:
The algorithm searches for cruise type obstacles that:
a) are moving faster than a speed threshold (parameter) and are in front of the ego.
b) have another cruise obstacle that is stopped in front of them.
c) will collide with the stopped obstacle within a given time (if they continue a straight path towards it)
Related links
TIER IV internal link
Tests performed
Scenario Evaluation tests: TIER IV INTERNAL LINK
Several tests with PSim:
Example using time of collision (between static obstacle and moving obstacle) to decide to yield or not. default threshold time is 10 seconds.
yield1.mp4
Example 2
cap-.2024-01-25-15-38-52.mp4
Example 3
cap-.2024-01-25-16-31-33.mp4
Notes for reviewers
Requires changes to launch. autowarefoundation/autoware_launch#837
Interface changes
Effects on system behavior
If enabled, the ego will cruise behind neighbor cars that will likely cut in into the ego's lane.
Pre-review checklist for the PR author
The PR author must check the checkboxes below when creating the PR.
In-review checklist for the PR reviewers
The PR reviewers must check the checkboxes below before approval.
Post-review checklist for the PR author
The PR author must check the checkboxes below before merging.
After all checkboxes are checked, anyone who has write access can merge the PR.