18
18
19
19
#include " gtest/gtest.h"
20
20
#include " geometry_msgs/msg/pose_stamped.hpp"
21
+ #include " geometry_msgs/msg/pose.hpp"
21
22
#include " nav_msgs/msg/path.hpp"
22
23
#include " nav2_util/path_utils.hpp"
23
24
@@ -168,20 +169,20 @@ TEST(PathUtilsTest, EmptyAndSinglePointPaths)
168
169
auto robot_pose = createPose (5.0 , 5.0 );
169
170
nav_msgs::msg::Path empty_path;
170
171
171
- auto result = nav2_util::distanceFromPath (empty_path, robot_pose);
172
- EXPECT_EQ (result.distance , std::numeric_limits<double >::infinity ());
172
+ auto result = nav2_util::distance_from_path (empty_path, robot_pose);
173
+ EXPECT_EQ (result.distance , std::numeric_limits<double >::max ());
173
174
174
175
nav_msgs::msg::Path single_point_path;
175
176
single_point_path.poses .push_back (createPose (0.0 , 0.0 ));
176
- result = nav2_util::distanceFromPath (single_point_path, robot_pose);
177
+ result = nav2_util::distance_from_path (single_point_path, robot_pose);
177
178
EXPECT_NEAR (result.distance , 7.071 , 0.01 );
178
179
}
179
180
180
181
TEST_F (CuttingCornerTest, TrajectoryCutsCorner)
181
182
{
182
183
for (size_t i = 0 ; i < robot_trajectory.size (); ++i) {
183
184
const auto & robot_pose = robot_trajectory[i];
184
- auto result = nav2_util::distanceFromPath (target_path, robot_pose);
185
+ auto result = nav2_util::distance_from_path (target_path, robot_pose);
185
186
EXPECT_NEAR (result.distance , expected_distances[i], 0.1 );
186
187
}
187
188
}
@@ -191,15 +192,15 @@ TEST_F(RetracingPathTest, TrajectoryFollowsRetracingPath)
191
192
const double expected_distance = 0.5 ;
192
193
193
194
for (const auto & robot_pose : robot_trajectory) {
194
- auto result = nav2_util::distanceFromPath (target_path, robot_pose);
195
+ auto result = nav2_util::distance_from_path (target_path, robot_pose);
195
196
EXPECT_NEAR (result.distance , expected_distance, 1e-6 );
196
197
}
197
198
}
198
199
199
200
TEST_F (CloverleafPathTest, TrajectoryFollowsCloverleafLoop)
200
201
{
201
202
for (const auto & robot_pose : robot_trajectory) {
202
- auto result = nav2_util::distanceFromPath (target_path, robot_pose);
203
+ auto result = nav2_util::distance_from_path (target_path, robot_pose);
203
204
EXPECT_LT (result.distance , 0.25 );
204
205
}
205
206
}
@@ -209,23 +210,23 @@ TEST_F(RetracingCircleTest, TrajectoryFollowsRetracingCircle)
209
210
const double expected_distance = 0.2 ;
210
211
211
212
for (const auto & robot_pose : robot_trajectory) {
212
- auto result = nav2_util::distanceFromPath (target_path, robot_pose);
213
+ auto result = nav2_util::distance_from_path (target_path, robot_pose);
213
214
EXPECT_NEAR (result.distance , expected_distance, 0.01 );
214
215
}
215
216
}
216
217
217
218
TEST_F (ZigZagPathTest, TrajectoryFollowsZigZagPath)
218
219
{
219
220
for (const auto & robot_pose : robot_trajectory) {
220
- auto result = nav2_util::distanceFromPath (target_path, robot_pose);
221
+ auto result = nav2_util::distance_from_path (target_path, robot_pose);
221
222
EXPECT_LT (result.distance , 1.0 );
222
223
}
223
224
}
224
225
225
226
TEST_F (HairpinTurnTest, TrajectoryFollowsHairpinTurn)
226
227
{
227
228
for (const auto & robot_pose : robot_trajectory) {
228
- auto result = nav2_util::distanceFromPath (target_path, robot_pose);
229
+ auto result = nav2_util::distance_from_path (target_path, robot_pose);
229
230
EXPECT_LT (result.distance , 1.5 );
230
231
}
231
232
}
@@ -239,7 +240,8 @@ TEST_F(CuttingCornerWindowedTest, WindowedSearch)
239
240
240
241
for (size_t i = 0 ; i < robot_trajectory.size (); ++i) {
241
242
const auto & robot_pose = robot_trajectory[i];
242
- auto result = nav2_util::distanceFromPath (target_path, robot_pose, start_index, search_window);
243
+ auto result = nav2_util::distance_from_path (target_path, robot_pose, start_index,
244
+ search_window);
243
245
start_index = result.closest_segment_index ;
244
246
EXPECT_NEAR (result.distance , expected_distances[i], 0.15 );
245
247
}
@@ -255,7 +257,8 @@ TEST_F(RetracingPathWindowedTest, WindowedSearch)
255
257
256
258
for (size_t i = 0 ; i < robot_trajectory.size (); ++i) {
257
259
const auto & robot_pose = robot_trajectory[i];
258
- auto result = nav2_util::distanceFromPath (target_path, robot_pose, start_index, search_window);
260
+ auto result = nav2_util::distance_from_path (target_path, robot_pose, start_index,
261
+ search_window);
259
262
start_index = result.closest_segment_index ;
260
263
EXPECT_NEAR (result.distance , expected_distance, 1e-6 );
261
264
}
@@ -270,7 +273,8 @@ TEST_F(ZigZagPathWindowedTest, WindowedSearch)
270
273
271
274
for (size_t i = 0 ; i < robot_trajectory.size (); ++i) {
272
275
const auto & robot_pose = robot_trajectory[i];
273
- auto result = nav2_util::distanceFromPath (target_path, robot_pose, start_index, search_window);
276
+ auto result = nav2_util::distance_from_path (target_path, robot_pose, start_index,
277
+ search_window);
274
278
start_index = result.closest_segment_index ;
275
279
EXPECT_LT (result.distance , 1.0 );
276
280
}
@@ -285,7 +289,8 @@ TEST_F(HairpinTurnWindowedTest, WindowedSearch)
285
289
286
290
for (size_t i = 0 ; i < robot_trajectory.size (); ++i) {
287
291
const auto & robot_pose = robot_trajectory[i];
288
- auto result = nav2_util::distanceFromPath (target_path, robot_pose, start_index, search_window);
292
+ auto result = nav2_util::distance_from_path (target_path, robot_pose, start_index,
293
+ search_window);
289
294
start_index = result.closest_segment_index ;
290
295
EXPECT_LT (result.distance , 1.5 );
291
296
}
@@ -298,12 +303,6 @@ TEST(PathUtilsWindowedTest, EdgeCases)
298
303
test_path.poses .push_back (createPose (0.0 , 0.0 ));
299
304
test_path.poses .push_back (createPose (10.0 , 0.0 ));
300
305
301
- auto result = nav2_util::distanceFromPath (test_path, robot_pose, 1 , 5.0 );
306
+ auto result = nav2_util::distance_from_path (test_path, robot_pose, 1 , 5.0 );
302
307
EXPECT_NEAR (result.distance , 7.071 , 0.01 );
303
-
304
- result = nav2_util::distanceFromPath (test_path, robot_pose, 0 , 0.0 );
305
- EXPECT_NEAR (result.distance , 7.071 , 0.01 );
306
-
307
- result = nav2_util::distanceFromPath (test_path, robot_pose, 10 , 5.0 );
308
- EXPECT_EQ (result.distance , std::numeric_limits<double >::infinity ());
309
308
}
0 commit comments