@@ -51,12 +51,16 @@ class CloverleafPathTest : public ::testing::Test
51
51
protected:
52
52
void SetUp () override
53
53
{
54
+ // Target path has three leaves with a radius of 5.0
54
55
generateCirclePath (target_path, 5.0 , 0.0 , 5.0 , 50 );
55
56
generateCirclePath (target_path, -5.0 , 0.0 , 5.0 , 50 );
56
57
generateCirclePath (target_path, 0.0 , 5.0 , 5.0 , 50 );
57
58
59
+ // Robot trajectory now also travels all three leaves, but with a radius of 4.8
58
60
nav_msgs::msg::Path robot_path;
59
61
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 );
60
64
robot_trajectory = robot_path.poses ;
61
65
}
62
66
nav_msgs::msg::Path target_path;
@@ -236,6 +240,7 @@ TEST_F(CuttingCornerWindowedTest, WindowedSearch)
236
240
for (size_t i = 0 ; i < robot_trajectory.size (); ++i) {
237
241
const auto & robot_pose = robot_trajectory[i];
238
242
auto result = nav2_util::distanceFromPath (target_path, robot_pose, start_index, search_window);
243
+ start_index = result.closest_segment_index ;
239
244
EXPECT_NEAR (result.distance , expected_distances[i], 0.15 );
240
245
}
241
246
}
@@ -251,39 +256,11 @@ TEST_F(RetracingPathWindowedTest, WindowedSearch)
251
256
for (size_t i = 0 ; i < robot_trajectory.size (); ++i) {
252
257
const auto & robot_pose = robot_trajectory[i];
253
258
auto result = nav2_util::distanceFromPath (target_path, robot_pose, start_index, search_window);
259
+ start_index = result.closest_segment_index ;
254
260
EXPECT_NEAR (result.distance , expected_distance, 1e-6 );
255
261
}
256
262
}
257
263
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
-
287
264
class ZigZagPathWindowedTest : public ZigZagPathTest {};
288
265
289
266
TEST_F (ZigZagPathWindowedTest, WindowedSearch)
@@ -294,6 +271,7 @@ TEST_F(ZigZagPathWindowedTest, WindowedSearch)
294
271
for (size_t i = 0 ; i < robot_trajectory.size (); ++i) {
295
272
const auto & robot_pose = robot_trajectory[i];
296
273
auto result = nav2_util::distanceFromPath (target_path, robot_pose, start_index, search_window);
274
+ start_index = result.closest_segment_index ;
297
275
EXPECT_LT (result.distance , 1.0 );
298
276
}
299
277
}
@@ -308,6 +286,7 @@ TEST_F(HairpinTurnWindowedTest, WindowedSearch)
308
286
for (size_t i = 0 ; i < robot_trajectory.size (); ++i) {
309
287
const auto & robot_pose = robot_trajectory[i];
310
288
auto result = nav2_util::distanceFromPath (target_path, robot_pose, start_index, search_window);
289
+ start_index = result.closest_segment_index ;
311
290
EXPECT_LT (result.distance , 1.5 );
312
291
}
313
292
}
0 commit comments