Skip to content

Commit e52689b

Browse files
go-sakayoriTetsuKawa
authored andcommitted
feat(static_obstacle_avoidance): force deactivation (autowarefoundation#8288)
* add force cancel function Signed-off-by: Go Sakayori <go.sakayori@tier4.jp> * fix format Signed-off-by: Go Sakayori <gsakayori@gmail.com> * fix json schema Signed-off-by: Go Sakayori <go.sakayori@tier4.jp> * fix spelling Signed-off-by: Go Sakayori <go.sakayori@tier4.jp> * fix Signed-off-by: Go Sakayori <go.sakayori@tier4.jp> --------- Signed-off-by: Go Sakayori <go.sakayori@tier4.jp> Signed-off-by: Go Sakayori <gsakayori@gmail.com>
1 parent f591fd5 commit e52689b

File tree

7 files changed

+61
-0
lines changed

7 files changed

+61
-0
lines changed

planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/config/static_obstacle_avoidance.param.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@
243243
# For cancel maneuver
244244
cancel:
245245
enable: true # [-]
246+
force:
247+
duration_time: 2.0 # [s]
246248

247249
# For yield maneuver
248250
yield:

planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/include/autoware/behavior_path_static_obstacle_avoidance_module/data_structs.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ struct AvoidanceParameters
107107
// if this param is true, it reverts avoidance path when the path is no longer needed.
108108
bool enable_cancel_maneuver{false};
109109

110+
double force_deactivate_duration_time{0.0};
111+
110112
// enable avoidance for all parking vehicle
111113
std::string policy_ambiguous_vehicle{"ignore"};
112114

@@ -581,6 +583,8 @@ struct AvoidancePlanningData
581583

582584
bool found_avoidance_path{false};
583585

586+
bool force_deactivated{false};
587+
584588
double to_stop_line{std::numeric_limits<double>::max()};
585589

586590
double to_start_point{std::numeric_limits<double>::lowest()};

planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/include/autoware/behavior_path_static_obstacle_avoidance_module/parameter_helper.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ AvoidanceParameters getParameter(rclcpp::Node * node)
301301
{
302302
const std::string ns = "avoidance.cancel.";
303303
p.enable_cancel_maneuver = getOrDeclareParameter<bool>(*node, ns + "enable");
304+
p.force_deactivate_duration_time =
305+
getOrDeclareParameter<double>(*node, ns + "force.duration_time");
304306
}
305307

306308
// yield

planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/include/autoware/behavior_path_static_obstacle_avoidance_module/scene.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,9 @@ class StaticObstacleAvoidanceModule : public SceneModuleInterface
477477
mutable std::vector<AvoidanceDebugMsg> debug_avoidance_initializer_for_shift_line_;
478478

479479
mutable rclcpp::Time debug_avoidance_initializer_for_shift_line_time_;
480+
481+
bool force_deactivated_{false};
482+
rclcpp::Time last_deactivation_triggered_time_;
480483
};
481484

482485
} // namespace autoware::behavior_path_planner

planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/schema/static_obstacle_avoidance.schema.json

+10
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,16 @@
12631263
"type": "boolean",
12641264
"description": "Flag to enable cancel maneuver.",
12651265
"default": "true"
1266+
},
1267+
"force": {
1268+
"type": "object",
1269+
"properties": {
1270+
"duration_time": {
1271+
"type": "number",
1272+
"description": "force deactivate duration time",
1273+
"default": 2.0
1274+
}
1275+
}
12661276
}
12671277
},
12681278
"required": ["enable"],

planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/src/manager.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ void StaticObstacleAvoidanceModuleManager::updateModuleParams(
182182
updateParam<bool>(parameters, ns + "consider_rear_overhang", p->consider_rear_overhang);
183183
}
184184

185+
{
186+
const std::string ns = "avoidance.cancel.";
187+
updateParam<double>(parameters, ns + "force.duration_time", p->force_deactivate_duration_time);
188+
}
189+
185190
{
186191
const std::string ns = "avoidance.stop.";
187192
updateParam<double>(parameters, ns + "max_distance", p->stop_max_distance);

planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/src/scene.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,24 @@ void StaticObstacleAvoidanceModule::fillEgoStatus(
570570
return;
571571
}
572572

573+
const auto registered_sl_force_deactivated =
574+
[&](const std::string & direction, const RegisteredShiftLineArray shift_line_array) {
575+
return std::any_of(
576+
shift_line_array.begin(), shift_line_array.end(), [&](const auto & shift_line) {
577+
return rtc_interface_ptr_map_.at(direction)->isForceDeactivated(shift_line.uuid);
578+
});
579+
};
580+
581+
const auto is_force_deactivated = registered_sl_force_deactivated("left", left_shift_array_) ||
582+
registered_sl_force_deactivated("right", right_shift_array_);
583+
if (is_force_deactivated && can_yield_maneuver) {
584+
data.yield_required = true;
585+
data.safe_shift_line = data.new_shift_line;
586+
data.force_deactivated = true;
587+
RCLCPP_INFO(getLogger(), "this module is force deactivated. wait until reactivation");
588+
return;
589+
}
590+
573591
/**
574592
* If the avoidance path is safe, use unapproved_new_sl for avoidance path generation.
575593
*/
@@ -755,6 +773,10 @@ bool StaticObstacleAvoidanceModule::isSafePath(
755773
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
756774
const auto & p = planner_data_->parameters;
757775

776+
if (force_deactivated_) {
777+
return false;
778+
}
779+
758780
if (!parameters_->enable_safety_check) {
759781
return true; // if safety check is disabled, it always return safe.
760782
}
@@ -1366,6 +1388,19 @@ void StaticObstacleAvoidanceModule::updateData()
13661388
}
13671389

13681390
safe_ = avoid_data_.safe;
1391+
1392+
if (!force_deactivated_) {
1393+
last_deactivation_triggered_time_ = clock_->now();
1394+
force_deactivated_ = avoid_data_.force_deactivated;
1395+
return;
1396+
}
1397+
1398+
if (
1399+
(clock_->now() - last_deactivation_triggered_time_).seconds() >
1400+
parameters_->force_deactivate_duration_time) {
1401+
RCLCPP_INFO(getLogger(), "The force deactivation is released");
1402+
force_deactivated_ = false;
1403+
}
13691404
}
13701405

13711406
void StaticObstacleAvoidanceModule::processOnEntry()

0 commit comments

Comments
 (0)