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: add error handling when path is invalid #934

Merged
merged 4 commits into from
Oct 13, 2023
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
23 changes: 0 additions & 23 deletions planning/behavior_path_planner/src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,6 @@
#include <string>
#include <vector>

namespace tier4_autoware_utils
h-ohta marked this conversation as resolved.
Show resolved Hide resolved
{
template <class T>
double calcLateralOffset(
const T & points, const geometry_msgs::msg::Point & p_target, const size_t seg_idx)
{
validateNonEmpty(points);

const auto p_front = getPoint(points.at(seg_idx));
const auto p_back = getPoint(points.at(seg_idx + 1));

const Eigen::Vector3d segment_vec{p_back.x - p_front.x, p_back.y - p_front.y, 0.0};
const Eigen::Vector3d target_vec{p_target.x - p_front.x, p_target.y - p_front.y, 0.0};

if (segment_vec.norm() == 0.0) {
throw std::runtime_error("Same points are given.");
}

const Eigen::Vector3d cross_vec = segment_vec.cross(target_vec);
return cross_vec(2) / segment_vec.norm();
}
} // namespace tier4_autoware_utils

namespace drivable_area_utils
{
double quantize(const double val, const double resolution)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ template <typename T>
boost::optional<geometry_msgs::msg::Pose> lerpPose(
const T & points, const geometry_msgs::msg::Point & target_pos, const size_t closest_seg_idx)
{
if (points.size() < 2) {
h-ohta marked this conversation as resolved.
Show resolved Hide resolved
return {};
}

constexpr double epsilon = 1e-6;

const double closest_to_target_dist =
Expand Down Expand Up @@ -94,6 +98,10 @@ template <typename T>
double lerpTwistX(
const T & points, const geometry_msgs::msg::Point & target_pos, const size_t closest_seg_idx)
{
if (points.size() < 2) {
h-ohta marked this conversation as resolved.
Show resolved Hide resolved
return 0.0;
}

constexpr double epsilon = 1e-6;

const double closest_to_target_dist =
Expand All @@ -116,6 +124,10 @@ template <typename T>
double lerpPoseZ(
const T & points, const geometry_msgs::msg::Point & target_pos, const size_t closest_seg_idx)
{
if (points.size() < 2) {
h-ohta marked this conversation as resolved.
Show resolved Hide resolved
return 0.0;
}

constexpr double epsilon = 1e-6;

const double closest_to_target_dist =
Expand Down
3 changes: 3 additions & 0 deletions planning/obstacle_avoidance_planner/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,9 @@ void ObstacleAvoidancePlanner::calcVelocity(
const std::vector<autoware_auto_planning_msgs::msg::PathPoint> & path_points,
std::vector<autoware_auto_planning_msgs::msg::TrajectoryPoint> & traj_points) const
{
if (path_points.size() < 2) {
h-ohta marked this conversation as resolved.
Show resolved Hide resolved
return;
}
for (size_t i = 0; i < traj_points.size(); i++) {
const size_t nearest_seg_idx = [&]() {
const auto opt_seg_idx = tier4_autoware_utils::findNearestSegmentIndex(
Expand Down
4 changes: 4 additions & 0 deletions planning/obstacle_stop_planner/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,10 @@ void ObstacleStopPlannerNode::insertVelocity(
const std_msgs::msg::Header & trajectory_header, const VehicleInfo & vehicle_info,
const double current_acc, const double current_vel, const StopParam & stop_param)
{
if (output.size() < 3) {
h-ohta marked this conversation as resolved.
Show resolved Hide resolved
return;
}

if (planner_data.stop_require) {
// insert stop point
const auto traj_end_idx = output.size() - 1;
Expand Down
Loading