Skip to content

Commit

Permalink
Merge pull request #822 from tier4/chore/cherry-pick-v0.10.0
Browse files Browse the repository at this point in the history
chore: cherry pick from v0.10.0
  • Loading branch information
0x126 authored Sep 11, 2023
2 parents f7af5cf + d5bd087 commit 898aa9e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ class GoalPlannerModule : public SceneModuleInterface

// for parking policy
bool left_side_parking_{true};
mutable bool allow_goal_modification_{false}; // need to be set in isExecutionRequested

// pre-generate lane parking paths in a separate thread
rclcpp::TimerBase::SharedPtr lane_parking_timer_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,6 @@ bool GoalPlannerModule::isExecutionRequested() const
const Pose & current_pose = planner_data_->self_odometry->pose.pose;
const Pose & goal_pose = route_handler->getGoalPose();

// if goal is shoulder lane, allow goal modification
allow_goal_modification_ =
route_handler->isAllowedGoalModification() || checkOriginalGoalIsInShoulder();

// check if goal_pose is in current_lanes.
lanelet::ConstLanelet current_lane{};
const lanelet::ConstLanelets current_lanes = utils::getCurrentLanes(planner_data_);
Expand Down
19 changes: 10 additions & 9 deletions planning/behavior_path_planner/src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,7 @@ void makeBoundLongitudinallyMonotonic(
if (intersect_point) {
Pose pose;
pose.position = *intersect_point;
pose.position.z = bound_with_pose.at(i).position.z;
const auto yaw = calcAzimuthAngle(*intersect_point, bound_with_pose.at(i + 1).position);
pose.orientation = createQuaternionFromRPY(0.0, 0.0, yaw);
monotonic_bound.push_back(pose);
Expand Down Expand Up @@ -1902,18 +1903,18 @@ void makeBoundLongitudinallyMonotonic(

std::vector<Point> ret;

ret.push_back(bound.front());
for (size_t i = 0; i < bound.size(); i++) {
const auto & p_new = bound.at(i);
const auto duplicated_points_itr = std::find_if(
ret.begin(), ret.end(),
[&p_new](const auto & p) { return calcDistance2d(p, p_new) < 0.1; });

for (size_t i = 0; i < bound.size() - 2; i++) {
try {
motion_utils::validateNonSharpAngle(bound.at(i), bound.at(i + 1), bound.at(i + 2));
ret.push_back(bound.at(i + 1));
} catch (const std::exception & e) {
continue;
if (duplicated_points_itr != ret.end() && std::next(duplicated_points_itr, 2) == ret.end()) {
ret.erase(duplicated_points_itr, ret.end());
}
}

ret.push_back(bound.back());
ret.push_back(p_new);
}

return ret;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ using motion_utils::calcLateralOffset;
using motion_utils::calcLongitudinalOffsetPoint;
using motion_utils::calcLongitudinalOffsetPose;
using motion_utils::calcSignedArcLength;
using motion_utils::calcSignedArcLengthPartialSum;
using motion_utils::findNearestSegmentIndex;
using motion_utils::insertTargetPoint;
using motion_utils::resamplePath;
Expand Down Expand Up @@ -231,9 +232,12 @@ bool CrosswalkModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto

// Calculate stop point with margin
const auto p_stop_line = getStopPointWithMargin(*path, path_intersects);
// TODO(murooka) add a guard of p_stop_line
const auto default_stop_pose = toStdOptional(
calcLongitudinalOffsetPose(path->points, p_stop_line->first, p_stop_line->second));

std::optional<geometry_msgs::msg::Pose> default_stop_pose = std::nullopt;
if (p_stop_line.has_value()) {
default_stop_pose = toStdOptional(
calcLongitudinalOffsetPose(path->points, p_stop_line->first, p_stop_line->second));
}

// Resample path sparsely for less computation cost
constexpr double resample_interval = 4.0;
Expand Down Expand Up @@ -748,15 +752,15 @@ Polygon2d CrosswalkModule::getAttentionArea(
{
const auto & ego_pos = planner_data_->current_odometry->pose.position;
const auto ego_polygon = createVehiclePolygon(planner_data_->vehicle_info_);
const auto backward_path_length =
calcSignedArcLength(sparse_resample_path.points, size_t(0), ego_pos);
const auto length_sum = calcSignedArcLengthPartialSum(
sparse_resample_path.points, size_t(0), sparse_resample_path.points.size());

Polygon2d attention_area;
for (size_t j = 0; j < sparse_resample_path.points.size() - 1; ++j) {
const auto & p_ego_front = sparse_resample_path.points.at(j).point.pose;
const auto & p_ego_back = sparse_resample_path.points.at(j + 1).point.pose;
const auto front_length =
calcSignedArcLength(sparse_resample_path.points, ego_pos, p_ego_front.position);
const auto back_length =
calcSignedArcLength(sparse_resample_path.points, ego_pos, p_ego_back.position);
const auto front_length = length_sum.at(j) - backward_path_length;
const auto back_length = length_sum.at(j + 1) - backward_path_length;

if (back_length < crosswalk_attention_range.first) {
continue;
Expand Down Expand Up @@ -1065,6 +1069,8 @@ void CrosswalkModule::setDistanceToStop(
const auto & ego_pos = planner_data_->current_odometry->pose.position;
const double dist_ego2stop = calcSignedArcLength(ego_path.points, ego_pos, *stop_pos);
setDistance(dist_ego2stop);
} else {
setDistance(std::numeric_limits<double>::lowest());
}
}

Expand Down
47 changes: 19 additions & 28 deletions planning/behavior_velocity_walkway_module/src/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,8 @@ WalkwayModuleManager::WalkwayModuleManager(rclcpp::Node & node)
void WalkwayModuleManager::launchNewModules(const PathWithLaneId & path)
{
const auto rh = planner_data_->route_handler_;
if (!opt_use_regulatory_element_) {
opt_use_regulatory_element_ = checkRegulatoryElementExistence(rh->getLaneletMapPtr());
}

const auto launch = [this, &path](const auto & lanelet) {
const auto launch = [this, &path](const auto & lanelet, const auto use_regulatory_element) {
const auto attribute =
lanelet.attributeOr(lanelet::AttributeNamesString::Subtype, std::string(""));
if (attribute != lanelet::AttributeValueString::Walkway) {
Expand All @@ -64,24 +61,21 @@ void WalkwayModuleManager::launchNewModules(const PathWithLaneId & path)
const auto lanelet_map_ptr = planner_data_->route_handler_->getLaneletMapPtr();

registerModule(std::make_shared<WalkwayModule>(
lanelet.id(), lanelet_map_ptr, p, *opt_use_regulatory_element_, logger, clock_));
lanelet.id(), lanelet_map_ptr, p, use_regulatory_element, logger, clock_));
};

if (*opt_use_regulatory_element_) {
const auto crosswalk_leg_elem_map = planning_utils::getRegElemMapOnPath<Crosswalk>(
path, rh->getLaneletMapPtr(), planner_data_->current_odometry->pose);
const auto crosswalk_leg_elem_map = planning_utils::getRegElemMapOnPath<Crosswalk>(
path, rh->getLaneletMapPtr(), planner_data_->current_odometry->pose);

for (const auto & crosswalk : crosswalk_leg_elem_map) {
launch(crosswalk.first->crosswalkLanelet());
}
} else {
const auto crosswalk_lanelets = getCrosswalksOnPath(
planner_data_->current_odometry->pose, path, rh->getLaneletMapPtr(),
rh->getOverallGraphPtr());
for (const auto & crosswalk : crosswalk_leg_elem_map) {
launch(crosswalk.first->crosswalkLanelet(), true);
}

for (const auto & crosswalk : crosswalk_lanelets) {
launch(crosswalk);
}
const auto crosswalk_lanelets = getCrosswalksOnPath(
planner_data_->current_odometry->pose, path, rh->getLaneletMapPtr(), rh->getOverallGraphPtr());

for (const auto & crosswalk : crosswalk_lanelets) {
launch(crosswalk, false);
}
}

Expand All @@ -92,17 +86,14 @@ WalkwayModuleManager::getModuleExpiredFunction(const PathWithLaneId & path)

std::set<int64_t> walkway_id_set;

if (*opt_use_regulatory_element_) {
const auto crosswalk_leg_elem_map = planning_utils::getRegElemMapOnPath<Crosswalk>(
path, rh->getLaneletMapPtr(), planner_data_->current_odometry->pose);
walkway_id_set = getCrosswalkIdSetOnPath(
planner_data_->current_odometry->pose, path, rh->getLaneletMapPtr(), rh->getOverallGraphPtr());

for (const auto & crosswalk : crosswalk_leg_elem_map) {
walkway_id_set.insert(crosswalk.first->id());
}
} else {
walkway_id_set = getCrosswalkIdSetOnPath(
planner_data_->current_odometry->pose, path, rh->getLaneletMapPtr(),
rh->getOverallGraphPtr());
const auto crosswalk_leg_elem_map = planning_utils::getRegElemMapOnPath<Crosswalk>(
path, rh->getLaneletMapPtr(), planner_data_->current_odometry->pose);

for (const auto & crosswalk : crosswalk_leg_elem_map) {
walkway_id_set.insert(crosswalk.first->id());
}

return [walkway_id_set](const std::shared_ptr<SceneModuleInterface> & scene_module) {
Expand Down

0 comments on commit 898aa9e

Please sign in to comment.