Skip to content

Commit 84b91ea

Browse files
committed
feat(strat_planner): add a prepare time for blinker before taking action for approval
Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
1 parent e6de0f6 commit 84b91ea

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

planning/behavior_path_start_planner_module/config/start_planner.param.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
backward_path_update_duration: 3.0
3939
ignore_distance_from_lane_end: 15.0
4040
# turns signal
41+
prepare_time_before_start: 3.0
4142
th_turn_signal_on_lateral_offset: 1.0
4243
intersection_search_length: 30.0
4344
length_ratio_for_turn_signal_deactivation_near_intersection: 0.5

planning/behavior_path_start_planner_module/include/behavior_path_start_planner_module/data_structs.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct StartPlannerParameters
5959
double th_arrived_distance{0.0};
6060
double th_stopped_velocity{0.0};
6161
double th_stopped_time{0.0};
62+
double prepare_time_before_start{0.0};
6263
double th_turn_signal_on_lateral_offset{0.0};
6364
double th_distance_to_middle_of_the_road{0.0};
6465
double intersection_search_length{0.0};

planning/behavior_path_start_planner_module/include/behavior_path_start_planner_module/start_planner_module.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ struct PullOutStatus
7070
bool prev_is_safe_dynamic_objects{false};
7171
std::shared_ptr<PathWithLaneId> prev_stop_path_after_approval{nullptr};
7272
std::optional<Pose> stop_pose{std::nullopt};
73+
//! record the first time when the state changed from !isActivated() to isActivated()
74+
std::optional<rclcpp::Time> first_approved_time{std::nullopt};
7375

7476
PullOutStatus() {}
7577
};
@@ -261,6 +263,7 @@ class StartPlannerModule : public SceneModuleInterface
261263
const lanelet::ConstLanelets & pull_out_lanes, const geometry_msgs::msg::Point & current_pose,
262264
const double velocity_threshold, const double object_check_backward_distance,
263265
const double object_check_forward_distance) const;
266+
bool needToPrepareBlinkerBeforeStart() const;
264267
bool hasFinishedPullOut() const;
265268
bool hasFinishedBackwardDriving() const;
266269
bool hasCollisionWithDynamicObjects() const;

planning/behavior_path_start_planner_module/src/manager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void StartPlannerModuleManager::init(rclcpp::Node * node)
3636
p.th_arrived_distance = node->declare_parameter<double>(ns + "th_arrived_distance");
3737
p.th_stopped_velocity = node->declare_parameter<double>(ns + "th_stopped_velocity");
3838
p.th_stopped_time = node->declare_parameter<double>(ns + "th_stopped_time");
39+
p.prepare_time_before_start = node->declare_parameter<double>(ns + "prepare_time_before_start");
3940
p.th_turn_signal_on_lateral_offset =
4041
node->declare_parameter<double>(ns + "th_turn_signal_on_lateral_offset");
4142
p.th_distance_to_middle_of_the_road =

planning/behavior_path_start_planner_module/src/start_planner_module.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void StartPlannerModule::onFreespacePlannerTimer()
117117
BehaviorModuleOutput StartPlannerModule::run()
118118
{
119119
updateData();
120-
if (!isActivated()) {
120+
if (!isActivated() || needToPrepareBlinkerBeforeStart()) {
121121
return planWaitingApproval();
122122
}
123123

@@ -176,6 +176,10 @@ void StartPlannerModule::updateData()
176176
DEBUG_PRINT("StartPlannerModule::updateData() received new route, reset status");
177177
}
178178

179+
if (!status_.first_approved_time && isActivated()) {
180+
status_.first_approved_time = clock_->now();
181+
}
182+
179183
if (hasFinishedBackwardDriving()) {
180184
updateStatusAfterBackwardDriving();
181185
DEBUG_PRINT("StartPlannerModule::updateData() completed backward driving");
@@ -1078,6 +1082,16 @@ bool StartPlannerModule::hasFinishedPullOut() const
10781082
return has_finished;
10791083
}
10801084

1085+
bool StartPlannerModule::needToPrepareBlinkerBeforeStart() const
1086+
{
1087+
if (!status_.first_approved_time) {
1088+
return true;
1089+
}
1090+
const auto first_approved_time = status_.first_approved_time.value();
1091+
const double elapsed = rclcpp::Duration(clock_->now() - first_approved_time).seconds();
1092+
return elapsed < parameters_->prepare_time_before_start;
1093+
}
1094+
10811095
bool StartPlannerModule::isStuck()
10821096
{
10831097
if (!isStopped()) {

0 commit comments

Comments
 (0)