Skip to content

Commit fbd0f8e

Browse files
committed
refactor(avoidance): parameterize
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent d7ee1a3 commit fbd0f8e

File tree

6 files changed

+28
-20
lines changed

6 files changed

+28
-20
lines changed

planning/behavior_path_avoidance_by_lane_change_module/src/manager.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,13 @@ void AvoidanceByLaneChangeModuleManager::init(rclcpp::Node * node)
133133

134134
{
135135
const std::string ns = "avoidance.target_filtering.avoidance_for_ambiguous_vehicle.";
136-
p.enable_force_avoidance_for_stopped_vehicle =
137-
getOrDeclareParameter<bool>(*node, ns + "enable");
138-
p.threshold_time_force_avoidance_for_stopped_vehicle =
139-
getOrDeclareParameter<double>(*node, ns + "time_threshold");
136+
p.enable_avoidance_for_ambiguous_vehicle = getOrDeclareParameter<bool>(*node, ns + "enable");
137+
p.closest_distance_to_wait_and_see_for_ambiguous_vehicle =
138+
getOrDeclareParameter<double>(*node, ns + "closest_distance_to_wait_and_see");
139+
p.time_threshold_for_ambiguous_vehicle =
140+
getOrDeclareParameter<double>(*node, ns + "condition.time_threshold");
141+
p.distance_threshold_for_ambiguous_vehicle =
142+
getOrDeclareParameter<double>(*node, ns + "condition.distance_threshold");
140143
p.object_ignore_section_traffic_light_in_front_distance =
141144
getOrDeclareParameter<double>(*node, ns + "ignore_area.traffic_light.front_distance");
142145
p.object_ignore_section_crosswalk_in_front_distance =

planning/behavior_path_avoidance_module/config/avoidance.param.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@
155155
# params for avoidance of vehicle type objects that are ambiguous as to whether they are parked.
156156
avoidance_for_ambiguous_vehicle:
157157
enable: false # [-]
158-
time_threshold: 1.0 # [s]
159-
distance_threshold: 1.0 # [m]
158+
closest_distance_to_wait_and_see: 10.0 # [m]
159+
condition:
160+
time_threshold: 1.0 # [s]
161+
distance_threshold: 1.0 # [m]
160162
ignore_area:
161163
traffic_light:
162164
front_distance: 100.0 # [m]

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/data_structs.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct AvoidanceParameters
100100
bool enable_cancel_maneuver{false};
101101

102102
// enable avoidance for all parking vehicle
103-
bool enable_force_avoidance_for_stopped_vehicle{false};
103+
bool enable_avoidance_for_ambiguous_vehicle{false};
104104

105105
// enable yield maneuver.
106106
bool enable_yield_maneuver{false};
@@ -184,8 +184,9 @@ struct AvoidanceParameters
184184
double object_check_min_road_shoulder_width{0.0};
185185

186186
// force avoidance
187-
double threshold_time_force_avoidance_for_stopped_vehicle{0.0};
188-
double force_avoidance_distance_threshold{0.0};
187+
double closest_distance_to_wait_and_see_for_ambiguous_vehicle{0.0};
188+
double time_threshold_for_ambiguous_vehicle{0.0};
189+
double distance_threshold_for_ambiguous_vehicle{0.0};
189190

190191
// when complete avoidance motion, there is a distance margin with the object
191192
// for longitudinal direction

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/helper.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,13 @@ class AvoidanceHelper
309309
const auto desire_shift_length =
310310
getShiftLength(object, is_object_on_right, object.avoid_margin.value());
311311

312-
constexpr double BUFFER = 10.0;
313312
const auto prepare_distance = getMinimumPrepareDistance();
314313
const auto constant_distance = getFrontConstantDistance(object);
315314
const auto avoidance_distance = getMinAvoidanceDistance(desire_shift_length);
316315

317-
return object.longitudinal < prepare_distance + constant_distance + avoidance_distance + BUFFER;
316+
return object.longitudinal <
317+
prepare_distance + constant_distance + avoidance_distance +
318+
parameters_->closest_distance_to_wait_and_see_for_ambiguous_vehicle;
318319
}
319320

320321
bool isReady(const AvoidLineArray & new_shift_lines, const double current_shift_length) const

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/parameter_helper.hpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,13 @@ AvoidanceParameters getParameter(rclcpp::Node * node)
141141

142142
{
143143
const std::string ns = "avoidance.target_filtering.avoidance_for_ambiguous_vehicle.";
144-
p.enable_force_avoidance_for_stopped_vehicle =
145-
getOrDeclareParameter<bool>(*node, ns + "enable");
146-
p.threshold_time_force_avoidance_for_stopped_vehicle =
147-
getOrDeclareParameter<double>(*node, ns + "time_threshold");
148-
p.force_avoidance_distance_threshold =
149-
getOrDeclareParameter<double>(*node, ns + "distance_threshold");
144+
p.enable_avoidance_for_ambiguous_vehicle = getOrDeclareParameter<bool>(*node, ns + "enable");
145+
p.closest_distance_to_wait_and_see_for_ambiguous_vehicle =
146+
getOrDeclareParameter<double>(*node, ns + "closest_distance_to_wait_and_see");
147+
p.time_threshold_for_ambiguous_vehicle =
148+
getOrDeclareParameter<double>(*node, ns + "condition.time_threshold");
149+
p.distance_threshold_for_ambiguous_vehicle =
150+
getOrDeclareParameter<double>(*node, ns + "condition.distance_threshold");
150151
p.object_ignore_section_traffic_light_in_front_distance =
151152
getOrDeclareParameter<double>(*node, ns + "ignore_area.traffic_light.front_distance");
152153
p.object_ignore_section_crosswalk_in_front_distance =

planning/behavior_path_avoidance_module/src/utils.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ bool isNeverAvoidanceTarget(
680680
const auto & object_pose = object.object.kinematics.initial_pose_with_covariance.pose;
681681
const auto is_moving_distance_longer_than_threshold =
682682
tier4_autoware_utils::calcDistance2d(object.init_pose, object_pose) >
683-
parameters->force_avoidance_distance_threshold;
683+
parameters->distance_threshold_for_ambiguous_vehicle;
684684
if (is_moving_distance_longer_than_threshold) {
685685
object.reason = AvoidanceDebugFactor::MOVING_OBJECT;
686686
return true;
@@ -860,13 +860,13 @@ bool isSatisfiedWithVehicleCondition(
860860

861861
// from here, filtering for ambiguous vehicle.
862862

863-
if (!parameters->enable_force_avoidance_for_stopped_vehicle) {
863+
if (!parameters->enable_avoidance_for_ambiguous_vehicle) {
864864
object.reason = "AmbiguousStoppedVehicle";
865865
return false;
866866
}
867867

868868
const auto stop_time_longer_than_threshold =
869-
object.stop_time > parameters->threshold_time_force_avoidance_for_stopped_vehicle;
869+
object.stop_time > parameters->time_threshold_for_ambiguous_vehicle;
870870
if (!stop_time_longer_than_threshold) {
871871
object.reason = "AmbiguousStoppedVehicle(wait-and-see)";
872872
return false;

0 commit comments

Comments
 (0)