Skip to content

Commit

Permalink
Fix initial path poses (no longer cropped) and fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime CLEMENT <[email protected]>
  • Loading branch information
maxime-clem committed Oct 16, 2023
1 parent bba9c57 commit 2c16947
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ void reuse_previous_poses(
const auto resampled_path_points =
motion_utils::resamplePath(path, params.resample_interval, true, true, false).points;
for (const auto & p : resampled_path_points) cropped_poses.push_back(p.point.pose);
cropped_poses =
motion_utils::cropForwardPoints(cropped_poses, ego_point, 0LU, params.max_path_arc_length);
} else if (!path.points.empty()) {
const auto initial_arc_length = motion_utils::calcArcLength(cropped_poses);
const auto max_path_arc_length = motion_utils::calcArcLength(path.points);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ TEST(DrivableAreaExpansionProjection, expand_drivable_area)
planner_data.reference_path = std::make_shared<drivable_area_expansion::PathWithLaneId>(path);
planner_data.dynamic_object =
std::make_shared<drivable_area_expansion::PredictedObjects>(dynamic_objects);
planner_data.self_odometry = std::make_shared<nav_msgs::msg::Odometry>();
planner_data.route_handler = std::make_shared<route_handler::RouteHandler>(route_handler);
// we expect the drivable area to be expanded by 1m on each side
drivable_area_expansion::expand_drivable_area(
path, std::make_shared<behavior_path_planner::PlannerData>(planner_data));
// unchanged path points
Expand All @@ -237,23 +237,37 @@ TEST(DrivableAreaExpansionProjection, expand_drivable_area)
EXPECT_NEAR(path.points[i].point.pose.position.x, i, eps);
EXPECT_NEAR(path.points[i].point.pose.position.y, 0.0, eps);
}

// straight path: no expansion
// expanded left bound
ASSERT_EQ(path.left_bound.size(), 4ul);
ASSERT_EQ(path.left_bound.size(), 3ul);
EXPECT_NEAR(path.left_bound[0].x, 0.0, eps);
EXPECT_NEAR(path.left_bound[0].y, 1.0, eps);
EXPECT_NEAR(path.left_bound[1].x, 0.0, eps);
EXPECT_NEAR(path.left_bound[1].y, 2.0, eps);
EXPECT_NEAR(path.left_bound[1].x, 1.0, eps);
EXPECT_NEAR(path.left_bound[1].y, 1.0, eps);
EXPECT_NEAR(path.left_bound[2].x, 2.0, eps);
EXPECT_NEAR(path.left_bound[2].y, 2.0, eps);
EXPECT_NEAR(path.left_bound[3].x, 2.0, eps);
EXPECT_NEAR(path.left_bound[3].y, 1.0, eps);
EXPECT_NEAR(path.left_bound[2].y, 1.0, eps);
// expanded right bound
ASSERT_EQ(path.right_bound.size(), 3ul);
EXPECT_NEAR(path.right_bound[0].x, 0.0, eps);
EXPECT_NEAR(path.right_bound[0].y, -2.0, eps);
EXPECT_NEAR(path.right_bound[1].x, 2.0, eps);
EXPECT_NEAR(path.right_bound[1].y, -2.0, eps);
EXPECT_NEAR(path.right_bound[0].y, -1.0, eps);
EXPECT_NEAR(path.right_bound[1].x, 1.0, eps);
EXPECT_NEAR(path.right_bound[1].y, -1.0, eps);
EXPECT_NEAR(path.right_bound[2].x, 2.0, eps);
EXPECT_NEAR(path.right_bound[2].y, -1.0, eps);

// add some curvature
path.points[1].point.pose.position.y = 0.5;

drivable_area_expansion::expand_drivable_area(
path, std::make_shared<behavior_path_planner::PlannerData>(planner_data));
// expanded left bound
ASSERT_EQ(path.left_bound.size(), 3ul);
EXPECT_GT(path.left_bound[0].y, 1.0);
EXPECT_GT(path.left_bound[1].y, 1.0);
EXPECT_GT(path.left_bound[2].y, 1.0);
// expanded right bound
ASSERT_EQ(path.right_bound.size(), 3ul);
EXPECT_LT(path.right_bound[0].y, -1.0);
EXPECT_LT(path.right_bound[1].y, -1.0);
EXPECT_LT(path.right_bound[2].y, -1.0);
}

0 comments on commit 2c16947

Please sign in to comment.