Skip to content

Commit

Permalink
solve bugs when merging with lane
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Sanchez <[email protected]>
  • Loading branch information
danielsanchezaran committed Feb 2, 2024
1 parent e5f6309 commit 765e17f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,9 @@ class SamplingPlannerModule : public SceneModuleInterface
const auto ego_arc = lanelet::utils::getArcCoordinates(current_lanes, ego_pose);
const auto goal_arc = lanelet::utils::getArcCoordinates(current_lanes, goal_pose);
const double length_to_goal = std::abs(goal_arc.length - ego_arc.length);

Check warning on line 207 in planning/behavior_path_sampling_planner_module/include/behavior_path_sampling_planner_module/sampling_planner_module.hpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/include/behavior_path_sampling_planner_module/sampling_planner_module.hpp#L205-L207

Added lines #L205 - L207 were not covered by tests
const double min_target_length = *std::min_element(
internal_params_->sampling.target_lengths.begin(),
internal_params_->sampling.target_lengths.end());

if (length_to_goal < min_target_length) return isReferencePathSafe();
constexpr double epsilon = 1E-5;
if (length_to_goal < epsilon) return isReferencePathSafe();

Check warning on line 210 in planning/behavior_path_sampling_planner_module/include/behavior_path_sampling_planner_module/sampling_planner_module.hpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/include/behavior_path_sampling_planner_module/sampling_planner_module.hpp#L210

Added line #L210 was not covered by tests

const auto nearest_index =
motion_utils::findNearestIndex(prev_module_reference_path->points, ego_pose);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,44 @@ SamplingPlannerModule::SamplingPlannerModule(

bool SamplingPlannerModule::isExecutionRequested() const

Check warning on line 173 in planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp#L173

Added line #L173 was not covered by tests
{
const auto & p = planner_data_->parameters;
const auto ego_pose = planner_data_->self_odometry->pose.pose;
const auto goal_pose = planner_data_->route_handler->getGoalPose();

Check warning on line 177 in planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp#L176-L177

Added lines #L176 - L177 were not covered by tests

lanelet::ConstLanelet current_lane;

Check warning on line 179 in planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp#L179

Added line #L179 was not covered by tests

if (!planner_data_->route_handler->getClosestLaneletWithinRoute(ego_pose, &current_lane)) {
RCLCPP_ERROR(

Check warning on line 182 in planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp#L181-L182

Added lines #L181 - L182 were not covered by tests
rclcpp::get_logger("behavior_path_planner").get_child("utils"),
"failed to find closest lanelet within route!!!");
return false;

Check warning on line 185 in planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp#L185

Added line #L185 was not covered by tests
}
const auto current_lane_sequence = planner_data_->route_handler->getLaneletSequence(
current_lane, ego_pose, p.backward_path_length, p.forward_path_length);

Check warning on line 188 in planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp#L188

Added line #L188 was not covered by tests
// expand drivable lanes
std::vector<DrivableLanes> drivable_lanes{};

std::for_each(
current_lane_sequence.begin(), current_lane_sequence.end(), [&](const auto & lanelet) {
drivable_lanes.push_back(generateExpandDrivableLanes(lanelet, planner_data_));
});

Check warning on line 195 in planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp#L192-L195

Added lines #L192 - L195 were not covered by tests

lanelet::ConstLanelets current_lanes;

for (auto & d : drivable_lanes) {
current_lanes.push_back(d.right_lane);
current_lanes.push_back(d.left_lane);
current_lanes.insert(current_lanes.end(), d.middle_lanes.begin(), d.middle_lanes.end());

Check warning on line 202 in planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp#L199-L202

Added lines #L199 - L202 were not covered by tests
}
lanelet::ConstLanelet closest_lanelet_to_ego;
lanelet::utils::query::getClosestLanelet(current_lanes, ego_pose, &closest_lanelet_to_ego);
lanelet::ConstLanelet closest_lanelet_to_goal;
lanelet::utils::query::getClosestLanelet(current_lanes, goal_pose, &closest_lanelet_to_goal);

Check warning on line 207 in planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp#L204-L207

Added lines #L204 - L207 were not covered by tests
const bool ego_and_goal_on_same_lanelet =
closest_lanelet_to_goal.id() == closest_lanelet_to_ego.id();

if (!ego_and_goal_on_same_lanelet) return false;

Check warning on line 211 in planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp#L211

Added line #L211 was not covered by tests

if (getPreviousModuleOutput().reference_path.points.empty()) {

Check warning on line 213 in planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_sampling_planner_module/src/sampling_planner_module.cpp#L213

Added line #L213 was not covered by tests
return false;
}
Expand Down

0 comments on commit 765e17f

Please sign in to comment.