Skip to content

Commit

Permalink
fix(behavior_path_planner): fix/frenet coordinate 3d (autowarefoundat…
Browse files Browse the repository at this point in the history
…ion#230)

* fix function of convertToFrenetCoordinate3d

* deleted no used valiable

Co-authored-by: taikitanaka3 <[email protected]>
  • Loading branch information
k-obitsu and taikitanaka3 authored Jan 11, 2022
1 parent c8fe977 commit 0280de1
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions planning/behavior_path_planner/src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ bool convertToFrenetCoordinate3d(
}

const auto search_pt = tier4_autoware_utils::fromMsg(search_point_geom);
bool found = false;
double min_distance = std::numeric_limits<double>::max();

// get frenet coordinate based on points
Expand All @@ -88,15 +87,17 @@ bool convertToFrenetCoordinate3d(

const double tmp_distance = current2search_pt.norm();
if (tmp_distance < min_distance) {
found = true;
min_distance = tmp_distance;
frenet_coordinate->distance = tmp_distance;
frenet_coordinate->length = accumulated_length;
} else {
break;
}
}
}

// get frenet coordinate based on lines
bool found_on_line = false;
{
auto prev_geom_pt = linestring.front();
double accumulated_length = 0;
Expand All @@ -113,17 +114,26 @@ bool convertToFrenetCoordinate3d(
if (tmp_length >= 0 && tmp_length <= line_segment_length) {
double tmp_distance = direction.cross(start2search_pt).norm();
if (tmp_distance < min_distance) {
found = true;
min_distance = tmp_distance;
frenet_coordinate->distance = tmp_distance;
frenet_coordinate->length = accumulated_length + tmp_length;

if (found_on_line) {
break;
}

found_on_line = true;
} else if (found_on_line) {
break;
}
} else if (found_on_line) {
break;
}
accumulated_length += line_segment_length;
prev_geom_pt = geom_pt;
}
}
return found;
return found_on_line;
}

std::vector<Point> convertToGeometryPointArray(const PathWithLaneId & path)
Expand Down

0 comments on commit 0280de1

Please sign in to comment.