Skip to content

Commit

Permalink
rearrange code
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Zulfaqar Azmi <[email protected]>
  • Loading branch information
zulfaqar-azmi-t4 committed Sep 26, 2023
1 parent ee87960 commit acb0723
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ boost::optional<PoseWithVelocityStamped> calcInterpolatedPoseWithVelocity(
boost::optional<PoseWithVelocityAndPolygonStamped> getInterpolatedPoseWithVelocityAndPolygonStamped(
const std::vector<PoseWithVelocityStamped> & pred_path, const double current_time,
const VehicleInfo & ego_info);

/**
* @brief Iterate the points in the ego and target's predicted path and
* perform safety check for each of the iterated points.
Expand All @@ -101,9 +100,9 @@ boost::optional<PoseWithVelocityAndPolygonStamped> getInterpolatedPoseWithVeloci
* @param front_object_deceleration The deceleration of the object in the front.(used in RSS)
* @param rear_object_deceleration The deceleration of the object in the rear.(used in RSS)
* @param debug The debug information for collision checking.
* @return a list of polygon when collision is expected.
* @return true if distance is safe.
*/
std::vector<Polygon2d> getCollidedPolygons(
bool checkCollision(
const PathWithLaneId & planned_path,
const std::vector<PoseWithVelocityStamped> & predicted_ego_path,
const ExtendedPredictedObject & target_object,
Expand All @@ -123,9 +122,9 @@ std::vector<Polygon2d> getCollidedPolygons(
* @param front_object_deceleration The deceleration of the object in the front.(used in RSS)
* @param rear_object_deceleration The deceleration of the object in the rear.(used in RSS)
* @param debug The debug information for collision checking.
* @return true if distance is safe.
* @return a list of polygon when collision is expected.
*/
bool checkCollision(
std::vector<Polygon2d> getCollidedPolygons(
const PathWithLaneId & planned_path,
const std::vector<PoseWithVelocityStamped> & predicted_ego_path,
const ExtendedPredictedObject & target_object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,20 @@ boost::optional<PoseWithVelocityAndPolygonStamped> getInterpolatedPoseWithVeloci
return PoseWithVelocityAndPolygonStamped{current_time, pose, velocity, ego_polygon};
}

bool checkCollision(
const PathWithLaneId & planned_path,
const std::vector<PoseWithVelocityStamped> & predicted_ego_path,
const ExtendedPredictedObject & target_object,
const PredictedPathWithPolygon & target_object_path,
const BehaviorPathPlannerParameters & common_parameters, const RSSparams & rss_parameters,
const double hysteresis_factor, CollisionCheckDebug & debug)
{
const auto collided_polygons = getCollidedPolygons(
planned_path, predicted_ego_path, target_object, target_object_path, common_parameters,
rss_parameters, hysteresis_factor, debug);
return collided_polygons.empty();
}

std::vector<Polygon2d> getCollidedPolygons(
[[maybe_unused]] const PathWithLaneId & planned_path,
const std::vector<PoseWithVelocityStamped> & predicted_ego_path,
Expand Down Expand Up @@ -350,21 +364,6 @@ std::vector<Polygon2d> getCollidedPolygons(

return collided_polygons;
}

bool checkCollision(
const PathWithLaneId & planned_path,
const std::vector<PoseWithVelocityStamped> & predicted_ego_path,
const ExtendedPredictedObject & target_object,
const PredictedPathWithPolygon & target_object_path,
const BehaviorPathPlannerParameters & common_parameters, const RSSparams & rss_parameters,
const double hysteresis_factor, CollisionCheckDebug & debug)
{
const auto collided_polygons = getCollidedPolygons(
planned_path, predicted_ego_path, target_object, target_object_path, common_parameters,
rss_parameters, hysteresis_factor, debug);
return collided_polygons.empty();
}

bool checkCollisionWithExtraStoppingMargin(
const PathWithLaneId & ego_path, const PredictedObjects & dynamic_objects,
const double base_to_front, const double base_to_rear, const double width,
Expand Down

0 comments on commit acb0723

Please sign in to comment.