Skip to content

Commit

Permalink
feat(strat_planner): add a prepare time for blinker before taking act…
Browse files Browse the repository at this point in the history
…ion for approval (autowarefoundation#6438)

Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
  • Loading branch information
soblin authored and 0x126 committed Mar 11, 2024
1 parent 0a8cc23 commit e6fbf9e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
backward_path_update_duration: 3.0
ignore_distance_from_lane_end: 15.0
# turns signal
prepare_time_before_start: 0.0
th_turn_signal_on_lateral_offset: 1.0
intersection_search_length: 30.0
length_ratio_for_turn_signal_deactivation_near_intersection: 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ struct PullOutStatus
bool prev_is_safe_dynamic_objects{false};
std::shared_ptr<PathWithLaneId> prev_stop_path_after_approval{nullptr};
bool has_stop_point{false};
std::optional<Pose> stop_pose{std::nullopt};
//! record the first time when the state changed from !isActivated() to isActivated()
std::optional<rclcpp::Time> first_approved_time{std::nullopt};

PullOutStatus() {}
};
Expand Down Expand Up @@ -228,6 +231,7 @@ class StartPlannerModule : public SceneModuleInterface
void updateStatusAfterBackwardDriving();
PredictedObjects filterStopObjectsInPullOutLanes(
const lanelet::ConstLanelets & pull_out_lanes, const double velocity_threshold) const;
bool needToPrepareBlinkerBeforeStart() const;
bool hasFinishedPullOut() const;
bool hasFinishedBackwardDriving() const;
bool hasCollisionWithDynamicObjects() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct StartPlannerParameters
double th_arrived_distance{0.0};
double th_stopped_velocity{0.0};
double th_stopped_time{0.0};
double prepare_time_before_start{0.0};
double th_turn_signal_on_lateral_offset{0.0};
double th_distance_to_middle_of_the_road{0.0};
double intersection_search_length{0.0};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void StartPlannerModuleManager::init(rclcpp::Node * node)
p.th_arrived_distance = node->declare_parameter<double>(ns + "th_arrived_distance");
p.th_stopped_velocity = node->declare_parameter<double>(ns + "th_stopped_velocity");
p.th_stopped_time = node->declare_parameter<double>(ns + "th_stopped_time");
p.prepare_time_before_start = node->declare_parameter<double>(ns + "prepare_time_before_start");
p.th_turn_signal_on_lateral_offset =
node->declare_parameter<double>(ns + "th_turn_signal_on_lateral_offset");
p.th_distance_to_middle_of_the_road =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void StartPlannerModule::onFreespacePlannerTimer()
BehaviorModuleOutput StartPlannerModule::run()
{
updateData();
if (!isActivated()) {
if (!isActivated() || needToPrepareBlinkerBeforeStart()) {
return planWaitingApproval();
}

Expand Down Expand Up @@ -161,6 +161,10 @@ void StartPlannerModule::updateData()
DEBUG_PRINT("StartPlannerModule::updateData() received new route, reset status");
}

if (!status_.first_approved_time && isActivated()) {
status_.first_approved_time = clock_->now();
}

if (hasFinishedBackwardDriving()) {
updateStatusAfterBackwardDriving();
DEBUG_PRINT("StartPlannerModule::updateData() completed backward driving");
Expand Down Expand Up @@ -962,6 +966,16 @@ bool StartPlannerModule::hasFinishedPullOut() const
return has_finished;
}

bool StartPlannerModule::needToPrepareBlinkerBeforeStart() const
{
if (!status_.first_approved_time) {
return true;
}
const auto first_approved_time = status_.first_approved_time.value();
const double elapsed = rclcpp::Duration(clock_->now() - first_approved_time).seconds();
return elapsed < parameters_->prepare_time_before_start;
}

bool StartPlannerModule::isStuck()
{
if (!isStopped()) {
Expand Down

0 comments on commit e6fbf9e

Please sign in to comment.