86 const std::shared_ptr<Node3d> start_node,
87 const std::shared_ptr<Node3d> end_node,
88 std::shared_ptr<ReedSheppPath> optimal_path) {
89 std::vector<ReedSheppPath> all_possible_paths;
90 if (!
GenerateRSPs(start_node, end_node, &all_possible_paths)) {
91 ADEBUG <<
"Fail to generate different combination of Reed Shepp "
96 double start_dire = 1;
97 if (start_node->GetDirec() ==
false)
100 size_t optimal_path_index = 0;
101 size_t paths_size = all_possible_paths.size();
102 double min_cost = std::numeric_limits<double>::max();
103 for (
size_t i = 0; i < paths_size; ++i) {
105 auto& path = all_possible_paths[i];
106 double steering_radius = path.radius /
max_kappa_;
107 double steer_change_penalty_cost
109 for (
size_t j = 0; j < path.segs_lengths.size(); j++) {
110 if (path.segs_types[j] !=
'S') {
112 if (j > 0 && (path.segs_types[j - 1] !=
'S') && (path.segs_types[j - 1] != path.segs_types[j])) {
113 cost += steer_change_penalty_cost;
119 if (path.segs_lengths[j] < 0) {
129 if (j > 0 && path.segs_lengths[j] * path.segs_lengths[j - 1] < 0) {
132 if (j == 0 && start_dire * path.segs_lengths[j] < 0) {
136 if (cost < min_cost) {
137 optimal_path_index = i;
143 ADEBUG <<
"Fail to generate local configurations(x, y, phi) in SetRSP";
154 if (std::abs(all_possible_paths[optimal_path_index].x.back() - end_node->GetX()) > 1e-3
155 || std::abs(all_possible_paths[optimal_path_index].y.back() - end_node->GetY()) > 1e-3
158 ADEBUG <<
"RSP end position not right";
159 for (
size_t i = 0; i < all_possible_paths[optimal_path_index].segs_types.size(); ++i) {
160 ADEBUG <<
"types are " << all_possible_paths[optimal_path_index].segs_types[i];
162 ADEBUG <<
"x, y, phi are: " << all_possible_paths[optimal_path_index].x.back() <<
", "
163 << all_possible_paths[optimal_path_index].y.back() <<
", "
164 << all_possible_paths[optimal_path_index].phi.back();
165 ADEBUG <<
"end x, y, phi are: " << end_node->GetX() <<
", " << end_node->GetY() <<
", " << end_node->GetPhi();
168 (*optimal_path).cost = min_cost;
169 (*optimal_path).x = all_possible_paths[optimal_path_index].x;
170 (*optimal_path).y = all_possible_paths[optimal_path_index].y;
171 (*optimal_path).phi = all_possible_paths[optimal_path_index].phi;
172 (*optimal_path).gear = all_possible_paths[optimal_path_index].gear;
173 (*optimal_path).total_length = all_possible_paths[optimal_path_index].total_length;
174 (*optimal_path).segs_types = all_possible_paths[optimal_path_index].segs_types;
175 (*optimal_path).segs_lengths = all_possible_paths[optimal_path_index].segs_lengths;
199 const std::shared_ptr<Node3d> start_node,
200 const std::shared_ptr<Node3d> end_node,
201 std::vector<ReedSheppPath>* all_possible_paths) {
202 double dx = end_node->GetX() - start_node->GetX();
203 double dy = end_node->GetY() - start_node->GetY();
204 double dphi = end_node->GetPhi() - start_node->GetPhi();
205 double c = std::cos(start_node->GetPhi());
206 double s = std::sin(start_node->GetPhi());
213 if (!
SCS(x, y, dphi, all_possible_paths)) {
218 if (all_possible_paths->empty()) {
219 ADEBUG <<
"No path generated by certain two configurations";
226 if (!
CSC(x, y, dphi, all_possible_paths)) {
229 if (!
CCC(x, y, dphi, all_possible_paths)) {
232 if (!
CCCC(x, y, dphi, all_possible_paths)) {
235 if (!
CCSC(x, y, dphi, all_possible_paths)) {
238 if (!
CCSCC(x, y, dphi, all_possible_paths)) {
239 ADEBUG <<
"Fail at CCSCC";
241 if (all_possible_paths->empty()) {
242 ADEBUG <<
"No path generated by certain two configurations";
269bool ReedShepp::CS(
const double x,
const double y,
const double phi, std::vector<ReedSheppPath>* all_possible_paths) {
271 LS(x, y, phi, &LS1_param);
272 double LS1_lengths[2] = {LS1_param.
t, LS1_param.
u};
273 char LS1_types[] =
"LS";
274 if (LS1_param.
flag && !
SetRSP(2, LS1_lengths, LS1_types, all_possible_paths, LS1_param.
v)) {
275 ADEBUG <<
"Fail at SetRSP with LS_param";
279 LS(-x, y, -phi, &LS2_param);
280 double LS2_lengths[2] = {-LS2_param.
t, -LS2_param.
u};
281 char LS2_types[] =
"LS";
282 if (LS2_param.
flag && !
SetRSP(2, LS2_lengths, LS2_types, all_possible_paths, LS2_param.
v)) {
283 ADEBUG <<
"Fail at SetRSP with LS_param";
287 LS(x, -y, -phi, &RS1_param);
288 double RS1_lengths[2] = {RS1_param.
t, RS1_param.
u};
289 char RS1_types[] =
"RS";
290 if (RS1_param.
flag && !
SetRSP(2, RS1_lengths, RS1_types, all_possible_paths, RS1_param.
v)) {
291 ADEBUG <<
"Fail at SetRSP with SLS_param";
296 LS(-x, -y, phi, &RS2_param);
297 double RS2_lengths[2] = {-RS2_param.
t, -RS2_param.
u};
298 char RS2_types[] =
"RS";
299 if (RS2_param.
flag && !
SetRSP(2, RS2_lengths, RS2_types, all_possible_paths, RS2_param.
v)) {
300 ADEBUG <<
"Fail at SetRSP with SLS_param";
306bool ReedShepp::CSC(
const double x,
const double y,
const double phi, std::vector<ReedSheppPath>* all_possible_paths) {
308 LSL(x, y, phi, &LSL1_param);
309 double LSL1_lengths[3] = {LSL1_param.
t, LSL1_param.
u, LSL1_param.
v};
310 char LSL1_types[] =
"LSL";
311 if (LSL1_param.
flag && !
SetRSP(3, LSL1_lengths, LSL1_types, all_possible_paths)) {
312 ADEBUG <<
"Fail at SetRSP with LSL_param";
317 LSL(-x, y, -phi, &LSL2_param);
318 double LSL2_lengths[3] = {-LSL2_param.
t, -LSL2_param.
u, -LSL2_param.
v};
319 char LSL2_types[] =
"LSL";
320 if (LSL2_param.
flag && !
SetRSP(3, LSL2_lengths, LSL2_types, all_possible_paths)) {
321 ADEBUG <<
"Fail at SetRSP with LSL2_param";
326 LSL(x, -y, -phi, &LSL3_param);
327 double LSL3_lengths[3] = {LSL3_param.
t, LSL3_param.
u, LSL3_param.
v};
328 char LSL3_types[] =
"RSR";
329 if (LSL3_param.
flag && !
SetRSP(3, LSL3_lengths, LSL3_types, all_possible_paths)) {
330 ADEBUG <<
"Fail at SetRSP with LSL3_param";
335 LSL(-x, -y, phi, &LSL4_param);
336 double LSL4_lengths[3] = {-LSL4_param.
t, -LSL4_param.
u, -LSL4_param.
v};
337 char LSL4_types[] =
"RSR";
338 if (LSL4_param.
flag && !
SetRSP(3, LSL4_lengths, LSL4_types, all_possible_paths)) {
339 ADEBUG <<
"Fail at SetRSP with LSL4_param";
344 LSR(x, y, phi, &LSR1_param);
345 double LSR1_lengths[3] = {LSR1_param.
t, LSR1_param.
u, LSR1_param.
v};
346 char LSR1_types[] =
"LSR";
347 if (LSR1_param.
flag && !
SetRSP(3, LSR1_lengths, LSR1_types, all_possible_paths)) {
348 ADEBUG <<
"Fail at SetRSP with LSR1_param";
353 LSR(-x, y, -phi, &LSR2_param);
354 double LSR2_lengths[3] = {-LSR2_param.
t, -LSR2_param.
u, -LSR2_param.
v};
355 char LSR2_types[] =
"LSR";
356 if (LSR2_param.
flag && !
SetRSP(3, LSR2_lengths, LSR2_types, all_possible_paths)) {
357 ADEBUG <<
"Fail at SetRSP with LSR2_param";
362 LSR(x, -y, -phi, &LSR3_param);
363 double LSR3_lengths[3] = {LSR3_param.
t, LSR3_param.
u, LSR3_param.
v};
364 char LSR3_types[] =
"RSL";
365 if (LSR3_param.
flag && !
SetRSP(3, LSR3_lengths, LSR3_types, all_possible_paths)) {
366 ADEBUG <<
"Fail at SetRSP with LSR3_param";
371 LSR(-x, -y, phi, &LSR4_param);
372 double LSR4_lengths[3] = {-LSR4_param.
t, -LSR4_param.
u, -LSR4_param.
v};
373 char LSR4_types[] =
"RSL";
374 if (LSR4_param.
flag && !
SetRSP(3, LSR4_lengths, LSR4_types, all_possible_paths)) {
375 ADEBUG <<
"Fail at SetRSP with LSR4_param";
381bool ReedShepp::CCC(
const double x,
const double y,
const double phi, std::vector<ReedSheppPath>* all_possible_paths) {
383 LRL(x, y, phi, &LRL1_param);
384 double LRL1_lengths[3] = {LRL1_param.
t, LRL1_param.
u, LRL1_param.
v};
385 char LRL1_types[] =
"LRL";
386 if (LRL1_param.
flag && !
SetRSP(3, LRL1_lengths, LRL1_types, all_possible_paths)) {
387 ADEBUG <<
"Fail at SetRSP with LRL_param";
392 LRL(-x, y, -phi, &LRL2_param);
393 double LRL2_lengths[3] = {-LRL2_param.
t, -LRL2_param.
u, -LRL2_param.
v};
394 char LRL2_types[] =
"LRL";
395 if (LRL2_param.
flag && !
SetRSP(3, LRL2_lengths, LRL2_types, all_possible_paths)) {
396 ADEBUG <<
"Fail at SetRSP with LRL2_param";
401 LRL(x, -y, -phi, &LRL3_param);
402 double LRL3_lengths[3] = {LRL3_param.
t, LRL3_param.
u, LRL3_param.
v};
403 char LRL3_types[] =
"RLR";
404 if (LRL3_param.
flag && !
SetRSP(3, LRL3_lengths, LRL3_types, all_possible_paths)) {
405 ADEBUG <<
"Fail at SetRSP with LRL3_param";
410 LRL(-x, -y, phi, &LRL4_param);
411 double LRL4_lengths[3] = {-LRL4_param.
t, -LRL4_param.
u, -LRL4_param.
v};
412 char LRL4_types[] =
"RLR";
413 if (LRL4_param.
flag && !
SetRSP(3, LRL4_lengths, LRL4_types, all_possible_paths)) {
414 ADEBUG <<
"Fail at SetRSP with LRL4_param";
419 double xb = x * std::cos(phi) + y * std::sin(phi);
420 double yb = x * std::sin(phi) - y * std::cos(phi);
423 LRL(xb, yb, phi, &LRL5_param);
424 double LRL5_lengths[3] = {LRL5_param.
v, LRL5_param.
u, LRL5_param.
t};
425 char LRL5_types[] =
"LRL";
426 if (LRL5_param.
flag && !
SetRSP(3, LRL5_lengths, LRL5_types, all_possible_paths)) {
427 ADEBUG <<
"Fail at SetRSP with LRL5_param";
432 LRL(-xb, yb, -phi, &LRL6_param);
433 double LRL6_lengths[3] = {-LRL6_param.
v, -LRL6_param.
u, -LRL6_param.
t};
434 char LRL6_types[] =
"LRL";
435 if (LRL6_param.
flag && !
SetRSP(3, LRL6_lengths, LRL6_types, all_possible_paths)) {
436 ADEBUG <<
"Fail at SetRSP with LRL6_param";
441 LRL(xb, -yb, -phi, &LRL7_param);
442 double LRL7_lengths[3] = {LRL7_param.
v, LRL7_param.
u, LRL7_param.
t};
443 char LRL7_types[] =
"RLR";
444 if (LRL7_param.
flag && !
SetRSP(3, LRL7_lengths, LRL7_types, all_possible_paths)) {
445 ADEBUG <<
"Fail at SetRSP with LRL7_param";
450 LRL(-xb, -yb, phi, &LRL8_param);
451 double LRL8_lengths[3] = {-LRL8_param.
v, -LRL8_param.
u, -LRL8_param.
t};
452 char LRL8_types[] =
"RLR";
453 if (LRL8_param.
flag && !
SetRSP(3, LRL8_lengths, LRL8_types, all_possible_paths)) {
454 ADEBUG <<
"Fail at SetRSP with LRL8_param";
460bool ReedShepp::CCCC(
const double x,
const double y,
const double phi, std::vector<ReedSheppPath>* all_possible_paths) {
462 LRLRn(x, y, phi, &LRLRn1_param);
463 double LRLRn1_lengths[4] = {LRLRn1_param.
t, LRLRn1_param.
u, -LRLRn1_param.
u, LRLRn1_param.
v};
464 char LRLRn1_types[] =
"LRLR";
465 if (LRLRn1_param.
flag && !
SetRSP(4, LRLRn1_lengths, LRLRn1_types, all_possible_paths)) {
466 ADEBUG <<
"Fail at SetRSP with LRLRn_param";
471 LRLRn(-x, y, -phi, &LRLRn2_param);
472 double LRLRn2_lengths[4] = {-LRLRn2_param.
t, -LRLRn2_param.
u, LRLRn2_param.
u, -LRLRn2_param.
v};
473 char LRLRn2_types[] =
"LRLR";
474 if (LRLRn2_param.
flag && !
SetRSP(4, LRLRn2_lengths, LRLRn2_types, all_possible_paths)) {
475 ADEBUG <<
"Fail at SetRSP with LRLRn2_param";
480 LRLRn(x, -y, -phi, &LRLRn3_param);
481 double LRLRn3_lengths[4] = {LRLRn3_param.
t, LRLRn3_param.
u, -LRLRn3_param.
u, LRLRn3_param.
v};
482 char LRLRn3_types[] =
"RLRL";
483 if (LRLRn3_param.
flag && !
SetRSP(4, LRLRn3_lengths, LRLRn3_types, all_possible_paths)) {
484 ADEBUG <<
"Fail at SetRSP with LRLRn3_param";
489 LRLRn(-x, -y, phi, &LRLRn4_param);
490 double LRLRn4_lengths[4] = {-LRLRn4_param.
t, -LRLRn4_param.
u, LRLRn4_param.
u, -LRLRn4_param.
v};
491 char LRLRn4_types[] =
"RLRL";
492 if (LRLRn4_param.
flag && !
SetRSP(4, LRLRn4_lengths, LRLRn4_types, all_possible_paths)) {
493 ADEBUG <<
"Fail at SetRSP with LRLRn4_param";
498 LRLRp(x, y, phi, &LRLRp1_param);
499 double LRLRp1_lengths[4] = {LRLRp1_param.
t, LRLRp1_param.
u, LRLRp1_param.
u, LRLRp1_param.
v};
500 char LRLRp1_types[] =
"LRLR";
501 if (LRLRp1_param.
flag && !
SetRSP(4, LRLRp1_lengths, LRLRp1_types, all_possible_paths)) {
502 ADEBUG <<
"Fail at SetRSP with LRLRp1_param";
507 LRLRp(-x, y, -phi, &LRLRp2_param);
508 double LRLRp2_lengths[4] = {-LRLRp2_param.
t, -LRLRp2_param.
u, -LRLRp2_param.
u, -LRLRp2_param.
v};
509 char LRLRp2_types[] =
"LRLR";
510 if (LRLRp2_param.
flag && !
SetRSP(4, LRLRp2_lengths, LRLRp2_types, all_possible_paths)) {
511 ADEBUG <<
"Fail at SetRSP with LRLRp2_param";
516 LRLRp(x, -y, -phi, &LRLRp3_param);
517 double LRLRp3_lengths[4] = {LRLRp3_param.
t, LRLRp3_param.
u, LRLRp3_param.
u, LRLRp3_param.
v};
518 char LRLRp3_types[] =
"RLRL";
519 if (LRLRp3_param.
flag && !
SetRSP(4, LRLRp3_lengths, LRLRp3_types, all_possible_paths)) {
520 ADEBUG <<
"Fail at SetRSP with LRLRp3_param";
525 LRLRp(-x, -y, phi, &LRLRp4_param);
526 double LRLRp4_lengths[4] = {-LRLRp4_param.
t, -LRLRp4_param.
u, -LRLRp4_param.
u, -LRLRp4_param.
v};
527 char LRLRp4_types[] =
"RLRL";
528 if (LRLRp4_param.
flag && !
SetRSP(4, LRLRp4_lengths, LRLRp4_types, all_possible_paths)) {
529 ADEBUG <<
"Fail at SetRSP with LRLRp4_param";
535bool ReedShepp::CCSC(
const double x,
const double y,
const double phi, std::vector<ReedSheppPath>* all_possible_paths) {
537 LRSL(x, y, phi, &LRSL1_param);
538 double LRSL1_lengths[4] = {LRSL1_param.
t, -0.5 * M_PI, LRSL1_param.
u, LRSL1_param.
v};
539 char LRSL1_types[] =
"LRSL";
540 if (LRSL1_param.
flag && !
SetRSP(4, LRSL1_lengths, LRSL1_types, all_possible_paths)) {
541 ADEBUG <<
"Fail at SetRSP with LRSL1_param";
546 LRSL(-x, y, -phi, &LRSL2_param);
547 double LRSL2_lengths[4] = {-LRSL2_param.
t, 0.5 * M_PI, -LRSL2_param.
u, -LRSL2_param.
v};
548 char LRSL2_types[] =
"LRSL";
549 if (LRSL2_param.
flag && !
SetRSP(4, LRSL2_lengths, LRSL2_types, all_possible_paths)) {
550 ADEBUG <<
"Fail at SetRSP with LRSL2_param";
555 LRSL(x, -y, -phi, &LRSL3_param);
556 double LRSL3_lengths[4] = {LRSL3_param.
t, -0.5 * M_PI, LRSL3_param.
u, LRSL3_param.
v};
557 char LRSL3_types[] =
"RLSR";
558 if (LRSL3_param.
flag && !
SetRSP(4, LRSL3_lengths, LRSL3_types, all_possible_paths)) {
559 ADEBUG <<
"Fail at SetRSP with LRSL3_param";
564 LRSL(-x, -y, phi, &LRSL4_param);
565 double LRSL4_lengths[4] = {-LRSL4_param.
t, 0.5 * M_PI, -LRSL4_param.
u, -LRSL4_param.
v};
566 char LRSL4_types[] =
"RLSR";
567 if (LRSL4_param.
flag && !
SetRSP(4, LRSL4_lengths, LRSL4_types, all_possible_paths)) {
568 ADEBUG <<
"Fail at SetRSP with LRSL4_param";
573 LRSR(x, y, phi, &LRSR1_param);
574 double LRSR1_lengths[4] = {LRSR1_param.
t, -0.5 * M_PI, LRSR1_param.
u, LRSR1_param.
v};
575 char LRSR1_types[] =
"LRSR";
576 if (LRSR1_param.
flag && !
SetRSP(4, LRSR1_lengths, LRSR1_types, all_possible_paths)) {
577 ADEBUG <<
"Fail at SetRSP with LRSR1_param";
582 LRSR(-x, y, -phi, &LRSR2_param);
583 double LRSR2_lengths[4] = {-LRSR2_param.
t, 0.5 * M_PI, -LRSR2_param.
u, -LRSR2_param.
v};
584 char LRSR2_types[] =
"LRSR";
585 if (LRSR2_param.
flag && !
SetRSP(4, LRSR2_lengths, LRSR2_types, all_possible_paths)) {
586 ADEBUG <<
"Fail at SetRSP with LRSR2_param";
591 LRSR(x, -y, -phi, &LRSR3_param);
592 double LRSR3_lengths[4] = {LRSR3_param.
t, -0.5 * M_PI, LRSR3_param.
u, LRSR3_param.
v};
593 char LRSR3_types[] =
"RLSL";
594 if (LRSR3_param.
flag && !
SetRSP(4, LRSR3_lengths, LRSR3_types, all_possible_paths)) {
595 ADEBUG <<
"Fail at SetRSP with LRSR3_param";
600 LRSR(-x, -y, phi, &LRSR4_param);
601 double LRSR4_lengths[4] = {-LRSR4_param.
t, 0.5 * M_PI, -LRSR4_param.
u, -LRSR4_param.
v};
602 char LRSR4_types[] =
"RLSL";
603 if (LRSR4_param.
flag && !
SetRSP(4, LRSR4_lengths, LRSR4_types, all_possible_paths)) {
604 ADEBUG <<
"Fail at SetRSP with LRSR4_param";
609 double xb = x * std::cos(phi) + y * std::sin(phi);
610 double yb = x * std::sin(phi) - y * std::cos(phi);
613 LRSL(xb, yb, phi, &LRSL5_param);
614 double LRSL5_lengths[4] = {LRSL5_param.
v, LRSL5_param.
u, -0.5 * M_PI, LRSL5_param.
t};
615 char LRSL5_types[] =
"LSRL";
616 if (LRSL5_param.
flag && !
SetRSP(4, LRSL5_lengths, LRSL5_types, all_possible_paths)) {
617 ADEBUG <<
"Fail at SetRSP with LRLRn_param";
622 LRSL(-xb, yb, -phi, &LRSL6_param);
623 double LRSL6_lengths[4] = {-LRSL6_param.
v, -LRSL6_param.
u, 0.5 * M_PI, -LRSL6_param.
t};
624 char LRSL6_types[] =
"LSRL";
625 if (LRSL6_param.
flag && !
SetRSP(4, LRSL6_lengths, LRSL6_types, all_possible_paths)) {
626 ADEBUG <<
"Fail at SetRSP with LRSL6_param";
631 LRSL(xb, -yb, -phi, &LRSL7_param);
632 double LRSL7_lengths[4] = {LRSL7_param.
v, LRSL7_param.
u, -0.5 * M_PI, LRSL7_param.
t};
633 char LRSL7_types[] =
"RSLR";
634 if (LRSL7_param.
flag && !
SetRSP(4, LRSL7_lengths, LRSL7_types, all_possible_paths)) {
635 ADEBUG <<
"Fail at SetRSP with LRSL7_param";
640 LRSL(-xb, -yb, phi, &LRSL8_param);
641 double LRSL8_lengths[4] = {-LRSL8_param.
v, -LRSL8_param.
u, 0.5 * M_PI, -LRSL8_param.
t};
642 char LRSL8_types[] =
"RSLR";
643 if (LRSL8_param.
flag && !
SetRSP(4, LRSL8_lengths, LRSL8_types, all_possible_paths)) {
644 ADEBUG <<
"Fail at SetRSP with LRSL8_param";
649 LRSR(xb, yb, phi, &LRSR5_param);
650 double LRSR5_lengths[4] = {LRSR5_param.
v, LRSR5_param.
u, -0.5 * M_PI, LRSR5_param.
t};
651 char LRSR5_types[] =
"RSRL";
652 if (LRSR5_param.
flag && !
SetRSP(4, LRSR5_lengths, LRSR5_types, all_possible_paths)) {
653 ADEBUG <<
"Fail at SetRSP with LRSR5_param";
658 LRSR(-xb, yb, -phi, &LRSR6_param);
659 double LRSR6_lengths[4] = {-LRSR6_param.
v, -LRSR6_param.
u, 0.5 * M_PI, -LRSR6_param.
t};
660 char LRSR6_types[] =
"RSRL";
661 if (LRSR6_param.
flag && !
SetRSP(4, LRSR6_lengths, LRSR6_types, all_possible_paths)) {
662 ADEBUG <<
"Fail at SetRSP with LRSR6_param";
667 LRSR(xb, -yb, -phi, &LRSR7_param);
668 double LRSR7_lengths[4] = {LRSR7_param.
v, LRSR7_param.
u, -0.5 * M_PI, LRSR7_param.
t};
669 char LRSR7_types[] =
"LSLR";
670 if (LRSR7_param.
flag && !
SetRSP(4, LRSR7_lengths, LRSR7_types, all_possible_paths)) {
671 ADEBUG <<
"Fail at SetRSP with LRSR7_param";
676 LRSR(-xb, -yb, phi, &LRSR8_param);
677 double LRSR8_lengths[4] = {-LRSR8_param.
v, -LRSR8_param.
u, 0.5 * M_PI, -LRSR8_param.
t};
678 char LRSR8_types[] =
"LSLR";
679 if (LRSR8_param.
flag && !
SetRSP(4, LRSR8_lengths, LRSR8_types, all_possible_paths)) {
680 ADEBUG <<
"Fail at SetRSP with LRSR8_param";
690 std::vector<ReedSheppPath>* all_possible_paths) {
692 LRSLR(x, y, phi, &LRSLR1_param);
693 double LRSLR1_lengths[5] = {LRSLR1_param.
t, -0.5 * M_PI, LRSLR1_param.
u, -0.5 * M_PI, LRSLR1_param.
v};
694 char LRSLR1_types[] =
"LRSLR";
695 if (LRSLR1_param.
flag && !
SetRSP(5, LRSLR1_lengths, LRSLR1_types, all_possible_paths)) {
696 ADEBUG <<
"Fail at SetRSP with LRSLR1_param";
701 LRSLR(-x, y, -phi, &LRSLR2_param);
702 double LRSLR2_lengths[5] = {-LRSLR2_param.
t, 0.5 * M_PI, -LRSLR2_param.
u, 0.5 * M_PI, -LRSLR2_param.
v};
703 char LRSLR2_types[] =
"LRSLR";
704 if (LRSLR2_param.
flag && !
SetRSP(5, LRSLR2_lengths, LRSLR2_types, all_possible_paths)) {
705 ADEBUG <<
"Fail at SetRSP with LRSLR2_param";
710 LRSLR(x, -y, -phi, &LRSLR3_param);
711 double LRSLR3_lengths[5] = {LRSLR3_param.
t, -0.5 * M_PI, LRSLR3_param.
u, -0.5 * M_PI, LRSLR3_param.
v};
712 char LRSLR3_types[] =
"RLSRL";
713 if (LRSLR3_param.
flag && !
SetRSP(5, LRSLR3_lengths, LRSLR3_types, all_possible_paths)) {
714 ADEBUG <<
"Fail at SetRSP with LRSLR3_param";
719 LRSLR(-x, -y, phi, &LRSLR4_param);
720 double LRSLR4_lengths[5] = {-LRSLR4_param.
t, 0.5 * M_PI, -LRSLR4_param.
u, 0.5 * M_PI, -LRSLR4_param.
v};
721 char LRSLR4_types[] =
"RLSRL";
722 if (LRSLR4_param.
flag && !
SetRSP(5, LRSLR4_lengths, LRSLR4_types, all_possible_paths)) {
723 ADEBUG <<
"Fail at SetRSP with LRSLR4_param";
974 const std::shared_ptr<Node3d> start_node,
975 const std::shared_ptr<Node3d> end_node,
977 double radius = shortest_path->
radius;
980 size_t point_num =
static_cast<size_t>(std::floor(
983 ADEBUG <<
"point_num" << point_num;
984 std::vector<double> px(point_num, 0.0);
985 std::vector<double> py(point_num, 0.0);
986 std::vector<double> pphi(point_num, 0.0);
987 std::vector<bool> pgear(point_num,
true);
1001 for (
size_t i = 0; i < shortest_path->
segs_types.size(); ++i) {
1004 d = l > 0.0 ? step_scaled : -step_scaled;
1005 d = m ==
'S' ? d : d / radius;
1006 double ox = px.at(index);
1007 double oy = py.at(index);
1008 double ophi = pphi.at(index);
1015 while (std::abs(pd) <= std::abs(l)) {
1017 Interpolation(index, pd, m, ox, oy, ophi, radius, &px, &py, &pphi, &pgear);
1022 Interpolation(index, l, m, ox, oy, ophi, radius, &px, &py, &pphi, &pgear);
1024 double epsilon = 1e-15;
1025 while (std::fabs(px.back()) < epsilon && std::fabs(py.back()) < epsilon && std::fabs(pphi.back()) < epsilon
1032 for (
size_t i = 0; i < px.size(); ++i) {
1033 shortest_path->
x.push_back(
1034 std::cos(-start_node->GetPhi()) * px.at(i) + std::sin(-start_node->GetPhi()) * py.at(i)
1035 + start_node->GetX());
1036 shortest_path->
y.push_back(
1037 -std::sin(-start_node->GetPhi()) * px.at(i) + std::cos(-start_node->GetPhi()) * py.at(i)
1038 + start_node->GetY());
1041 shortest_path->
gear = pgear;
1042 for (
size_t i = 0; i < shortest_path->
segs_lengths.size(); ++i) {
1121 const std::shared_ptr<Node3d> start_node,
1122 const std::shared_ptr<Node3d> end_node,
1123 std::vector<ReedSheppPath>* all_possible_paths) {
1124 double dx = end_node->GetX() - start_node->GetX();
1125 double dy = end_node->GetY() - start_node->GetY();
1126 double dphi = end_node->GetPhi() - start_node->GetPhi();
1127 double c = std::cos(start_node->GetPhi());
1128 double s = std::sin(start_node->GetPhi());
1130 double x = (c * dx + s * dy) * this->
max_kappa_;
1131 double y = (-s * dx + c * dy) * this->
max_kappa_;
1133 double xb = x * std::cos(dphi) + y * std::sin(dphi);
1134 double yb = x * std::sin(dphi) - y * std::cos(dphi);
1137 all_possible_paths->resize(RSP_nums);
1139#pragma omp parallel for schedule(dynamic, 2) num_threads(8)
1140 for (
int i = 0; i < RSP_nums; ++i) {
1143 double RSP_lengths[5] = {0.0, 0.0, 0.0, 0.0, 0.0};
1144 double x_param = 1.0;
1145 double y_param = 1.0;
1146 std::string rd_type;
1148 if (i > 2 && i % 2) {
1151 if (i > 2 && i % 4 < 2) {
1162 SLS(x, y_param * y, y_param * dphi, &RSP_param);
1164 RSP_lengths[0] = RSP_param.
t;
1165 RSP_lengths[1] = RSP_param.
u;
1166 RSP_lengths[2] = RSP_param.
v;
1168 LSL(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1175 RSP_lengths[0] = x_param * RSP_param.
t;
1176 RSP_lengths[1] = x_param * RSP_param.
u;
1177 RSP_lengths[2] = x_param * RSP_param.
v;
1178 }
else if (i < 10) {
1179 LSR(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1186 RSP_lengths[0] = x_param * RSP_param.
t;
1187 RSP_lengths[1] = x_param * RSP_param.
u;
1188 RSP_lengths[2] = x_param * RSP_param.
v;
1189 }
else if (i < 14) {
1190 LRL(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1197 RSP_lengths[0] = x_param * RSP_param.
t;
1198 RSP_lengths[1] = x_param * RSP_param.
u;
1199 RSP_lengths[2] = x_param * RSP_param.
v;
1200 }
else if (i < 18) {
1201 LRL(x_param * xb, y_param * yb, x_param * y_param * dphi, &RSP_param);
1208 RSP_lengths[0] = x_param * RSP_param.
v;
1209 RSP_lengths[1] = x_param * RSP_param.
u;
1210 RSP_lengths[2] = x_param * RSP_param.
t;
1211 }
else if (i < 22) {
1212 LRLRn(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1213 if (y_param > 0.0) {
1219 RSP_lengths[0] = x_param * RSP_param.
t;
1220 RSP_lengths[1] = x_param * RSP_param.
u;
1221 RSP_lengths[2] = -x_param * RSP_param.
u;
1222 RSP_lengths[3] = x_param * RSP_param.
v;
1223 }
else if (i < 26) {
1224 LRLRp(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1225 if (y_param > 0.0) {
1231 RSP_lengths[0] = x_param * RSP_param.
t;
1232 RSP_lengths[1] = x_param * RSP_param.
u;
1233 RSP_lengths[2] = -x_param * RSP_param.
u;
1234 RSP_lengths[3] = x_param * RSP_param.
v;
1235 }
else if (i < 30) {
1237 LRLRn(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1238 if (y_param > 0.0) {
1243 RSP_lengths[0] = x_param * RSP_param.
t;
1244 if (x_param < 0 && y_param > 0) {
1245 RSP_lengths[1] = 0.5 * M_PI;
1247 RSP_lengths[1] = -0.5 * M_PI;
1249 if (x_param > 0 && y_param < 0) {
1250 RSP_lengths[2] = RSP_param.
u;
1252 RSP_lengths[2] = -RSP_param.
u;
1254 RSP_lengths[3] = x_param * RSP_param.
v;
1255 }
else if (i < 34) {
1257 LRLRp(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1263 RSP_lengths[0] = x_param * RSP_param.
t;
1264 if (x_param < 0 && y_param > 0) {
1265 RSP_lengths[1] = 0.5 * M_PI;
1267 RSP_lengths[1] = -0.5 * M_PI;
1269 RSP_lengths[2] = x_param * RSP_param.
u;
1270 RSP_lengths[3] = x_param * RSP_param.
v;
1271 }
else if (i < 38) {
1273 LRLRn(x_param * xb, y_param * yb, x_param * y_param * dphi, &RSP_param);
1279 RSP_lengths[0] = x_param * RSP_param.
v;
1280 RSP_lengths[1] = x_param * RSP_param.
u;
1281 RSP_lengths[2] = -x_param * 0.5 * M_PI;
1282 RSP_lengths[3] = x_param * RSP_param.
t;
1283 }
else if (i < 42) {
1285 LRLRp(x_param * xb, y_param * yb, x_param * y_param * dphi, &RSP_param);
1291 RSP_lengths[0] = x_param * RSP_param.
v;
1292 RSP_lengths[1] = x_param * RSP_param.
u;
1293 RSP_lengths[2] = -x_param * M_PI * 0.5;
1294 RSP_lengths[3] = x_param * RSP_param.
t;
1297 LRSLR(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1298 if (y_param > 0.0) {
1303 RSP_lengths[0] = x_param * RSP_param.
t;
1304 RSP_lengths[1] = -x_param * 0.5 * M_PI;
1305 RSP_lengths[2] = x_param * RSP_param.
u;
1306 RSP_lengths[3] = -x_param * 0.5 * M_PI;
1307 RSP_lengths[4] = x_param * RSP_param.
v;
1310 if (tmp_length > 0) {
1311 if (RSP_param.
flag && !
SetRSPPar(tmp_length, RSP_lengths, rd_type, all_possible_paths, i)) {
1312 AERROR <<
"Fail at SetRSP, idx#: " << i;
1319 AERROR <<
"RSP parallel fails";
1322 if (all_possible_paths->size() == 0) {
1323 AERROR <<
"No path generated by certain two configurations";