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

fix(behavior_velocity_planner): fix rtc in crosswalk module #1273

Merged
merged 3 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -106,6 +106,9 @@ class CrosswalkModule : public SceneModuleInterface
private:
int64_t module_id_;

boost::optional<std::pair<size_t, PathPointWithLaneId>> findRTCStopPoint(
const PathWithLaneId & ego_path);

boost::optional<std::pair<size_t, PathPointWithLaneId>> findNearestStopPoint(
const PathWithLaneId & ego_path, StopReason & stop_reason);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,19 +355,22 @@ bool CrosswalkModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
stop_watch_.toc("total_processing_time", false));

const auto nearest_stop_point = findNearestStopPoint(ego_path, *stop_reason);
const auto rtc_stop_point = findRTCStopPoint(ego_path);

RCLCPP_INFO_EXPRESSION(
logger_, planner_param_.show_processing_time, "- step3: %f ms",
stop_watch_.toc("total_processing_time", false));

setSafe(!nearest_stop_point);

if (!nearest_stop_point) {
if (isActivated()) {
return true;
}

if (!isActivated()) {
if (nearest_stop_point) {
insertDecelPoint(nearest_stop_point.get(), *path);
} else if (rtc_stop_point) {
insertDecelPoint(rtc_stop_point.get(), *path);
}

RCLCPP_INFO_EXPRESSION(
Expand Down Expand Up @@ -406,6 +409,30 @@ boost::optional<std::pair<double, geometry_msgs::msg::Point>> CrosswalkModule::g
return {};
}

boost::optional<std::pair<size_t, PathPointWithLaneId>> CrosswalkModule::findRTCStopPoint(
const PathWithLaneId & ego_path)
{
const auto & base_link2front = planner_data_->vehicle_info_.max_longitudinal_offset_m;
const auto & ego_pos = planner_data_->current_pose.pose.position;

const auto p_stop_line = getStopLine(ego_path);
if (!p_stop_line) {
return {};
}

const auto & p_stop = p_stop_line.get().second;
const auto & margin = planner_param_.stop_line_distance;

const size_t base_idx = findNearestSegmentIndex(ego_path.points, p_stop);
const auto residual_length = calcLongitudinalOffsetToSegment(ego_path.points, base_idx, p_stop);
const auto update_margin = margin - residual_length + base_link2front;

setDistance(
std::abs(calcSignedArcLength(ego_path.points, ego_pos, p_stop) - margin - base_link2front));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It overwrites the distance set in findNearestStopPoint() because findRTCStopPoint() is called after findNearestStopPoint().
Could you set distance in insertDecelPoint(), for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, ok 👍 I'll fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix in 8e4cf54.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update in 5852ec7


return getBackwardInsertPointFromBasePoint(base_idx, ego_path, update_margin);
}

boost::optional<std::pair<size_t, PathPointWithLaneId>> CrosswalkModule::findNearestStopPoint(
const PathWithLaneId & ego_path, StopReason & stop_reason)
{
Expand Down Expand Up @@ -617,6 +644,10 @@ void CrosswalkModule::insertDecelPoint(
float CrosswalkModule::calcTargetVelocity(
const PathPointWithLaneId & stop_point, const PathWithLaneId & ego_path) const
{
if (!isActivated()) {
return 0.0;
}

if (isTargetExternalInputStatus(CrosswalkStatus::SLOWDOWN)) {
return planner_param_.slow_velocity;
}
Expand Down