Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cherry pick 6438+6470+6558 #1162

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,10 @@ 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 ego started forward-driving (maybe after backward driving
//! completion) in AUTONOMOUS operation mode
std::optional<rclcpp::Time> first_engaged_and_driving_forward_time{std::nullopt};

PullOutStatus() {}
};
Expand Down Expand Up @@ -228,6 +232,7 @@ class StartPlannerModule : public SceneModuleInterface
void updateStatusAfterBackwardDriving();
PredictedObjects filterStopObjectsInPullOutLanes(
const lanelet::ConstLanelets & pull_out_lanes, const double velocity_threshold) const;
bool needToPrepareBlinkerBeforeStartDrivingForward() 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() || needToPrepareBlinkerBeforeStartDrivingForward()) {
return planWaitingApproval();
}

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

if (
planner_data_->operation_mode->mode == OperationModeState::AUTONOMOUS &&
status_.driving_forward && !status_.first_engaged_and_driving_forward_time) {
status_.first_engaged_and_driving_forward_time = clock_->now();
}

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

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

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