Skip to content

Commit 6b0daa9

Browse files
changes to avoid improper mapping
Signed-off-by: Arjun Jagdish Ram <arjun.ram@tier4.jp>
1 parent 22bcb40 commit 6b0daa9

File tree

1 file changed

+32
-0
lines changed
  • common/autoware_motion_utils/include/autoware/motion_utils/trajectory

1 file changed

+32
-0
lines changed

common/autoware_motion_utils/include/autoware/motion_utils/trajectory/trajectory.hpp

+32
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,38 @@ size_t findFirstNearestIndexWithSoftConstraints(
21492149
}
21502150
}
21512151

2152+
{ // with yaw threshold
2153+
double min_squared_dist = std::numeric_limits<double>::max();
2154+
size_t min_idx = 0;
2155+
bool is_within_constraints = false;
2156+
for (size_t i = 0; i < points.size(); ++i) {
2157+
const auto yaw =
2158+
autoware_utils::calc_yaw_deviation(autoware_utils::get_pose(points.at(i)), pose);
2159+
const auto squared_dist =
2160+
autoware_utils::calc_squared_distance2d(points.at(i), pose.position);
2161+
2162+
if (yaw_threshold < std::abs(yaw)) {
2163+
if (is_within_constraints) {
2164+
break;
2165+
}
2166+
continue;
2167+
}
2168+
2169+
if (min_squared_dist <= squared_dist) {
2170+
continue;
2171+
}
2172+
2173+
min_squared_dist = squared_dist;
2174+
min_idx = i;
2175+
is_within_constraints = true;
2176+
}
2177+
2178+
// nearest index is found
2179+
if (is_within_constraints) {
2180+
return min_idx;
2181+
}
2182+
}
2183+
21522184
// without any threshold
21532185
return findNearestIndex(points, pose.position);
21542186
}

0 commit comments

Comments
 (0)