1
- // Copyright 2021 Tier IV, Inc. All rights reserved.
1
+ // Copyright 2024 Tier IV, Inc. All rights reserved.
2
2
//
3
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
4
// you may not use this file except in compliance with the License.
@@ -240,16 +240,35 @@ std::unique_ptr<fpa::AbstractPlanningAlgorithm> configure_astar(bool use_multi,
240
240
return algo;
241
241
}
242
242
243
+ std::unique_ptr<fpa::AbstractPlanningAlgorithm> configure_rrtstar (bool informed, bool update)
244
+ {
245
+ auto planner_common_param = get_default_planner_params ();
246
+
247
+ // configure rrtstar param
248
+ const double mu = 12.0 ;
249
+ const double margin = 0.2 ;
250
+ const double max_planning_time = 200 ;
251
+ const auto rrtstar_param = fpa::RRTStarParam{update, informed, max_planning_time, mu, margin};
252
+ auto algo = std::make_unique<fpa::RRTStar>(planner_common_param, vehicle_shape, rrtstar_param);
253
+ return algo;
254
+ }
255
+
243
256
enum AlgorithmType {
244
257
ASTAR_SINGLE,
245
258
ASTAR_MULTI,
246
259
ASTAR_MULTI_NOCW,
260
+ RRTSTAR_FASTEST,
261
+ RRTSTAR_UPDATE,
262
+ RRTSTAR_INFORMED_UPDATE,
247
263
};
248
264
// cspell: ignore fpalgos
249
265
std::unordered_map<AlgorithmType, std::string> rosbag_dir_prefix_table (
250
266
{{ASTAR_SINGLE, " fpalgos-astar_single" },
251
267
{ASTAR_MULTI, " fpalgos-astar_multi" },
252
268
{ASTAR_MULTI_NOCW, " fpalgos-astar_multi_nocw" },
269
+ {RRTSTAR_FASTEST, " fpalgos-rrtstar_fastest" },
270
+ {RRTSTAR_UPDATE, " fpalgos-rrtstar_update" },
271
+ {RRTSTAR_INFORMED_UPDATE, " fpalgos-rrtstar_informed_update" }
253
272
});
254
273
255
274
bool test_algorithm (enum AlgorithmType algo_type, bool dump_rosbag = false )
@@ -261,6 +280,12 @@ bool test_algorithm(enum AlgorithmType algo_type, bool dump_rosbag = false)
261
280
algo = configure_astar (true , true );
262
281
} else if (algo_type == AlgorithmType::ASTAR_MULTI_NOCW) {
263
282
algo = configure_astar (true , false );
283
+ } else if (algo_type == AlgorithmType::RRTSTAR_FASTEST) {
284
+ algo = configure_rrtstar (false , false );
285
+ } else if (algo_type == AlgorithmType::RRTSTAR_UPDATE) {
286
+ algo = configure_rrtstar (false , true );
287
+ } else if (algo_type == AlgorithmType::RRTSTAR_INFORMED_UPDATE) {
288
+ algo = configure_rrtstar (true , true );
264
289
} else {
265
290
throw std::runtime_error (" invalid algorithm time" );
266
291
}
@@ -277,7 +302,26 @@ bool test_algorithm(enum AlgorithmType algo_type, bool dump_rosbag = false)
277
302
double msec;
278
303
double cost;
279
304
280
- {
305
+ if (algo_type == RRTSTAR_FASTEST || algo_type == RRTSTAR_UPDATE) {
306
+ std::cout << " measuring average performance ..." << std::endl;
307
+ const size_t N_mc = (algo_type == RRTSTAR_UPDATE ? 5 : 100 );
308
+ double time_sum = 0.0 ;
309
+ double cost_sum = 0.0 ;
310
+ for (size_t j = 0 ; j < N_mc; j++) {
311
+ const rclcpp::Time begin = clock .now ();
312
+ if (!algo->makePlan (create_pose_msg (start_pose), create_pose_msg (goal_pose))) {
313
+ success_all = false ;
314
+ std::cout << " plan fail" << std::endl;
315
+ continue ;
316
+ }
317
+ const rclcpp::Time now = clock .now ();
318
+ time_sum += (now - begin).seconds () * 1000.0 ;
319
+ cost_sum += algo->getWaypoints ().compute_length ();
320
+ }
321
+ msec = time_sum / N_mc; // average performance
322
+ cost = cost_sum / N_mc;
323
+
324
+ } else {
281
325
const rclcpp::Time begin = clock .now ();
282
326
if (!algo->makePlan (create_pose_msg (start_pose), create_pose_msg (goal_pose))) {
283
327
success_all = false ;
@@ -352,6 +396,21 @@ TEST(AstarSearchTestSuite, MultiCurvaturenocw)
352
396
EXPECT_TRUE (test_algorithm (AlgorithmType::ASTAR_MULTI_NOCW));
353
397
}
354
398
399
+ TEST (RRTStarTestSuite, Fastest)
400
+ {
401
+ EXPECT_TRUE (test_algorithm (AlgorithmType::RRTSTAR_FASTEST));
402
+ }
403
+
404
+ TEST (RRTStarTestSuite, Update)
405
+ {
406
+ EXPECT_TRUE (test_algorithm (AlgorithmType::RRTSTAR_UPDATE));
407
+ }
408
+
409
+ TEST (RRTStarTestSuite, InformedUpdate)
410
+ {
411
+ EXPECT_TRUE (test_algorithm (AlgorithmType::RRTSTAR_INFORMED_UPDATE));
412
+ }
413
+
355
414
int main (int argc, char ** argv)
356
415
{
357
416
testing::InitGoogleTest (&argc, argv);
0 commit comments