Skip to content

Commit 45035d3

Browse files
committed
feat(safety_check): add option to use polygon along path in safety check (autowarefoundation#6336)
* feat(safety_check): add new function to create polygon along path Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * feat(avoidance): use free steer policy for safety check Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * fix(safety_check): fix polygon edge Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * fix(safety_check): fix param name Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> --------- Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent a9f0bbd commit 45035d3

File tree

4 files changed

+106
-4
lines changed

4 files changed

+106
-4
lines changed

planning/behavior_path_avoidance_module/config/avoidance.param.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
time_horizon_for_rear_object: 10.0 # [s]
188188
delay_until_departure: 0.0 # [s]
189189
# rss parameters
190+
extended_polygon_policy: "along_path" # [-] select "rectangle" or "along_path"
190191
expected_front_deceleration: -1.0 # [m/ss]
191192
expected_rear_deceleration: -1.0 # [m/ss]
192193
rear_vehicle_reaction_time: 2.0 # [s]

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/parameter_helper.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ AvoidanceParameters getParameter(rclcpp::Node * node)
223223
// safety check rss params
224224
{
225225
const std::string ns = "avoidance.safety_check.";
226+
p.rss_params.extended_polygon_policy =
227+
getOrDeclareParameter<std::string>(*node, ns + "extended_polygon_policy");
226228
p.rss_params.longitudinal_distance_min_threshold =
227229
getOrDeclareParameter<double>(*node, ns + "longitudinal_distance_min_threshold");
228230
p.rss_params.longitudinal_velocity_delta_time =

planning/behavior_path_planner_common/include/behavior_path_planner_common/utils/path_safety_checker/path_safety_checker_parameters.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ struct TargetObjectsOnLane
126126
*/
127127
struct RSSparams
128128
{
129+
std::string extended_polygon_policy{
130+
"rectangle"}; ///< Policy to create collision check polygon.
131+
///< possible values: ["rectangle", "along_path"]
129132
double rear_vehicle_reaction_time{0.0}; ///< Reaction time of the rear vehicle.
130133
double rear_vehicle_safety_time_margin{0.0}; ///< Safety time margin for the rear vehicle.
131134
double lateral_distance_max_threshold{0.0}; ///< Maximum threshold for lateral distance.

planning/behavior_path_planner_common/src/utils/path_safety_checker/safety_check.cpp

+100-4
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,88 @@ Polygon2d createExtendedPolygon(
184184
: tier4_autoware_utils::inverseClockwise(polygon);
185185
}
186186

187+
Polygon2d createExtendedPolygonAlongPath(
188+
const PathWithLaneId & planned_path, const Pose & base_link_pose,
189+
const vehicle_info_util::VehicleInfo & vehicle_info, const double lon_length,
190+
const double lat_margin, const double is_stopped_obj, CollisionCheckDebug & debug)
191+
{
192+
const double & base_to_front = vehicle_info.max_longitudinal_offset_m;
193+
const double & width = vehicle_info.vehicle_width_m;
194+
const double & base_to_rear = vehicle_info.rear_overhang_m;
195+
196+
// if stationary object, extend forward and backward by the half of lon length
197+
const double forward_lon_offset = base_to_front + (is_stopped_obj ? lon_length / 2 : lon_length);
198+
const double backward_lon_offset =
199+
-base_to_rear - (is_stopped_obj ? lon_length / 2 : 0); // minus value
200+
const double lat_offset = width / 2.0 + lat_margin;
201+
202+
{
203+
debug.forward_lon_offset = forward_lon_offset;
204+
debug.backward_lon_offset = backward_lon_offset;
205+
debug.lat_offset = lat_offset;
206+
}
207+
208+
const auto lon_offset_pose = motion_utils::calcLongitudinalOffsetPose(
209+
planned_path.points, base_link_pose.position, lon_length);
210+
if (!lon_offset_pose.has_value()) {
211+
return createExtendedPolygon(
212+
base_link_pose, vehicle_info, lon_length, lat_margin, is_stopped_obj, debug);
213+
}
214+
215+
const size_t start_idx =
216+
motion_utils::findNearestSegmentIndex(planned_path.points, base_link_pose.position);
217+
const size_t end_idx =
218+
motion_utils::findNearestSegmentIndex(planned_path.points, lon_offset_pose.value().position);
219+
220+
Polygon2d polygon;
221+
222+
{
223+
const auto p_offset =
224+
tier4_autoware_utils::calcOffsetPose(base_link_pose, backward_lon_offset, lat_offset, 0.0);
225+
appendPointToPolygon(polygon, p_offset.position);
226+
}
227+
228+
for (size_t i = start_idx + 1; i < end_idx + 1; ++i) {
229+
const auto p = tier4_autoware_utils::getPose(planned_path.points.at(i));
230+
const auto p_offset = tier4_autoware_utils::calcOffsetPose(p, 0.0, lat_offset, 0.0);
231+
appendPointToPolygon(polygon, p_offset.position);
232+
}
233+
234+
{
235+
const auto p_offset =
236+
tier4_autoware_utils::calcOffsetPose(lon_offset_pose.value(), base_to_front, lat_offset, 0.0);
237+
appendPointToPolygon(polygon, p_offset.position);
238+
}
239+
240+
{
241+
const auto p_offset = tier4_autoware_utils::calcOffsetPose(
242+
lon_offset_pose.value(), base_to_front, -lat_offset, 0.0);
243+
appendPointToPolygon(polygon, p_offset.position);
244+
}
245+
246+
for (size_t i = end_idx; i > start_idx; --i) {
247+
const auto p = tier4_autoware_utils::getPose(planned_path.points.at(i));
248+
const auto p_offset = tier4_autoware_utils::calcOffsetPose(p, 0.0, -lat_offset, 0.0);
249+
appendPointToPolygon(polygon, p_offset.position);
250+
}
251+
252+
{
253+
const auto p_offset =
254+
tier4_autoware_utils::calcOffsetPose(base_link_pose, backward_lon_offset, -lat_offset, 0.0);
255+
appendPointToPolygon(polygon, p_offset.position);
256+
}
257+
258+
{
259+
const auto p_offset =
260+
tier4_autoware_utils::calcOffsetPose(base_link_pose, backward_lon_offset, lat_offset, 0.0);
261+
appendPointToPolygon(polygon, p_offset.position);
262+
}
263+
264+
return tier4_autoware_utils::isClockwise(polygon)
265+
? polygon
266+
: tier4_autoware_utils::inverseClockwise(polygon);
267+
}
268+
187269
std::vector<Polygon2d> createExtendedPolygonsFromPoseWithVelocityStamped(
188270
const std::vector<PoseWithVelocityStamped> & predicted_path, const VehicleInfo & vehicle_info,
189271
const double forward_margin, const double backward_margin, const double lat_margin)
@@ -552,10 +634,24 @@ std::vector<Polygon2d> getCollidedPolygons(
552634
const auto & lat_margin = rss_parameters.lateral_distance_max_threshold * hysteresis_factor;
553635
// TODO(watanabe) fix hard coding value
554636
const bool is_stopped_object = object_velocity < 0.3;
555-
const auto & extended_ego_polygon = is_object_front ? createExtendedPolygon(
556-
ego_pose, ego_vehicle_info, lon_offset,
557-
lat_margin, is_stopped_object, debug)
558-
: ego_polygon;
637+
const auto extended_ego_polygon = [&]() {
638+
if (!is_object_front) {
639+
return ego_polygon;
640+
}
641+
642+
if (rss_parameters.extended_polygon_policy == "rectangle") {
643+
return createExtendedPolygon(
644+
ego_pose, ego_vehicle_info, lon_offset, lat_margin, is_stopped_object, debug);
645+
}
646+
647+
if (rss_parameters.extended_polygon_policy == "along_path") {
648+
return createExtendedPolygonAlongPath(
649+
planned_path, ego_pose, ego_vehicle_info, lon_offset, lat_margin, is_stopped_object,
650+
debug);
651+
}
652+
653+
throw std::domain_error("invalid rss parameter. please select 'rectangle' or 'along_path'.");
654+
}();
559655
const auto & extended_obj_polygon =
560656
is_object_front
561657
? obj_polygon

0 commit comments

Comments
 (0)