Skip to content

Commit 5506e4a

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

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

common/autoware_interpolation/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ $$
9191

9292
### Tridiagonal Matrix Algorithm
9393

94-
We solve tridiagonal linear equation according to [this article](https://www.iist.ac.in/sites/default/files/people/tdma.pdf) where variables of linear equation are expressed as follows in the implementation.
94+
We solve tridiagonal linear equation according to [this article](https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm) where variables of linear equation are expressed as follows in the implementation.
9595

9696
$$
9797
\begin{align}

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
}

common/autoware_motion_utils/test/src/trajectory/test_trajectory.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -4872,11 +4872,11 @@ TEST(trajectory, findFirstNearestIndexWithSoftConstraints)
48724872
EXPECT_EQ(
48734873
findFirstNearestIndexWithSoftConstraints(
48744874
poses, createPose(-2.1, 0.1, 0.0, 0.0, 0.0, pi), 0.0, 0.4),
4875-
1U);
4875+
5U);
48764876
EXPECT_EQ(
48774877
findFirstNearestSegmentIndexWithSoftConstraints(
48784878
poses, createPose(-2.1, 0.1, 0.0, 0.0, 0.0, pi), 0.0, 0.4),
4879-
0U);
4879+
5U);
48804880

48814881
// Yaw is out of range
48824882
EXPECT_EQ(

0 commit comments

Comments
 (0)