Skip to content

Commit 922e1c7

Browse files
committed
minor changes in tests
Signed-off-by: silanus23 <[email protected]>
1 parent c25fc31 commit 922e1c7

File tree

1 file changed

+8
-29
lines changed

1 file changed

+8
-29
lines changed

nav2_util/test/test_path_utils.cpp

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ class CloverleafPathTest : public ::testing::Test
5151
protected:
5252
void SetUp() override
5353
{
54+
// Target path has three leaves with a radius of 5.0
5455
generateCirclePath(target_path, 5.0, 0.0, 5.0, 50);
5556
generateCirclePath(target_path, -5.0, 0.0, 5.0, 50);
5657
generateCirclePath(target_path, 0.0, 5.0, 5.0, 50);
5758

59+
// Robot trajectory now also travels all three leaves, but with a radius of 4.8
5860
nav_msgs::msg::Path robot_path;
5961
generateCirclePath(robot_path, 5.0, 0.0, 4.8, 50);
62+
generateCirclePath(robot_path, -5.0, 0.0, 4.8, 50);
63+
generateCirclePath(robot_path, 0.0, 5.0, 4.8, 50);
6064
robot_trajectory = robot_path.poses;
6165
}
6266
nav_msgs::msg::Path target_path;
@@ -236,6 +240,7 @@ TEST_F(CuttingCornerWindowedTest, WindowedSearch)
236240
for (size_t i = 0; i < robot_trajectory.size(); ++i) {
237241
const auto & robot_pose = robot_trajectory[i];
238242
auto result = nav2_util::distanceFromPath(target_path, robot_pose, start_index, search_window);
243+
start_index = result.closest_segment_index;
239244
EXPECT_NEAR(result.distance, expected_distances[i], 0.15);
240245
}
241246
}
@@ -251,39 +256,11 @@ TEST_F(RetracingPathWindowedTest, WindowedSearch)
251256
for (size_t i = 0; i < robot_trajectory.size(); ++i) {
252257
const auto & robot_pose = robot_trajectory[i];
253258
auto result = nav2_util::distanceFromPath(target_path, robot_pose, start_index, search_window);
259+
start_index = result.closest_segment_index;
254260
EXPECT_NEAR(result.distance, expected_distance, 1e-6);
255261
}
256262
}
257263

258-
class CloverleafPathWindowedTest : public CloverleafPathTest {};
259-
260-
TEST_F(CloverleafPathWindowedTest, WindowedSearch)
261-
{
262-
const double search_window = 50.0;
263-
size_t start_index = 0;
264-
265-
for (size_t i = 0; i < robot_trajectory.size(); ++i) {
266-
const auto & robot_pose = robot_trajectory[i];
267-
auto result = nav2_util::distanceFromPath(target_path, robot_pose, start_index, search_window);
268-
EXPECT_LT(result.distance, 0.25);
269-
}
270-
}
271-
272-
class RetracingCircleWindowedTest : public RetracingCircleTest {};
273-
274-
TEST_F(RetracingCircleWindowedTest, WindowedSearch)
275-
{
276-
const double expected_distance = 0.2;
277-
const double search_window = 100.0;
278-
size_t start_index = 0;
279-
280-
for (size_t i = 0; i < robot_trajectory.size(); ++i) {
281-
const auto & robot_pose = robot_trajectory[i];
282-
auto result = nav2_util::distanceFromPath(target_path, robot_pose, start_index, search_window);
283-
EXPECT_NEAR(result.distance, expected_distance, 0.05);
284-
}
285-
}
286-
287264
class ZigZagPathWindowedTest : public ZigZagPathTest {};
288265

289266
TEST_F(ZigZagPathWindowedTest, WindowedSearch)
@@ -294,6 +271,7 @@ TEST_F(ZigZagPathWindowedTest, WindowedSearch)
294271
for (size_t i = 0; i < robot_trajectory.size(); ++i) {
295272
const auto & robot_pose = robot_trajectory[i];
296273
auto result = nav2_util::distanceFromPath(target_path, robot_pose, start_index, search_window);
274+
start_index = result.closest_segment_index;
297275
EXPECT_LT(result.distance, 1.0);
298276
}
299277
}
@@ -308,6 +286,7 @@ TEST_F(HairpinTurnWindowedTest, WindowedSearch)
308286
for (size_t i = 0; i < robot_trajectory.size(); ++i) {
309287
const auto & robot_pose = robot_trajectory[i];
310288
auto result = nav2_util::distanceFromPath(target_path, robot_pose, start_index, search_window);
289+
start_index = result.closest_segment_index;
311290
EXPECT_LT(result.distance, 1.5);
312291
}
313292
}

0 commit comments

Comments
 (0)