78 const std::shared_ptr<Node3d> start_node,
79 const std::shared_ptr<Node3d> end_node,
80 std::shared_ptr<ReedSheppPath> optimal_path) {
81 std::vector<ReedSheppPath> all_possible_paths;
82 if (!
GenerateRSPs(start_node, end_node, &all_possible_paths)) {
83 ADEBUG <<
"Fail to generate different combination of Reed Shepp "
88 double start_dire = 1;
89 if (start_node->GetDirec() ==
false)
92 size_t optimal_path_index = 0;
93 size_t paths_size = all_possible_paths.size();
94 double min_cost = std::numeric_limits<double>::max();
95 for (
size_t i = 0; i < paths_size; ++i) {
97 auto& path = all_possible_paths[i];
98 double steering_radius = path.radius /
max_kappa_;
99 double steer_change_penalty_cost =
102 for (
size_t j = 0; j < path.segs_lengths.size(); j++) {
103 if (path.segs_types[j] !=
'S') {
106 if (j > 0 && (path.segs_types[j - 1] !=
'S') &&
107 (path.segs_types[j - 1] != path.segs_types[j])) {
108 cost += steer_change_penalty_cost;
110 if (std::fabs(path.segs_lengths[j]) /
max_kappa_ * path.radius <
115 if (path.segs_lengths[j] < 0) {
120 if (std::fabs(path.segs_lengths[j]) /
max_kappa_ <
126 if (j > 0 && path.segs_lengths[j] * path.segs_lengths[j - 1] < 0) {
129 if (j == 0 && start_dire * path.segs_lengths[j] < 0) {
133 if (cost < min_cost) {
134 optimal_path_index = i;
141 [optimal_path_index]))) {
142 ADEBUG <<
"Fail to generate local configurations(x, y, phi) in SetRSP";
153 if (std::abs(all_possible_paths[optimal_path_index].x.back() -
154 end_node->GetX()) > 1e-3 ||
155 std::abs(all_possible_paths[optimal_path_index].y.back() -
156 end_node->GetY()) > 1e-3 ||
158 all_possible_paths[optimal_path_index].phi.back() -
159 end_node->GetPhi()) > 1e-3) {
160 ADEBUG <<
"RSP end position not right";
162 i < all_possible_paths[optimal_path_index].segs_types.size(); ++i) {
164 << all_possible_paths[optimal_path_index].segs_types[i];
166 ADEBUG <<
"x, y, phi are: "
167 << all_possible_paths[optimal_path_index].x.back() <<
", "
168 << all_possible_paths[optimal_path_index].y.back() <<
", "
169 << all_possible_paths[optimal_path_index].phi.back();
170 ADEBUG <<
"end x, y, phi are: " << end_node->GetX() <<
", "
171 << end_node->GetY() <<
", " << end_node->GetPhi();
174 (*optimal_path).cost = min_cost;
175 (*optimal_path).x = all_possible_paths[optimal_path_index].x;
176 (*optimal_path).y = all_possible_paths[optimal_path_index].y;
177 (*optimal_path).phi = all_possible_paths[optimal_path_index].phi;
178 (*optimal_path).gear = all_possible_paths[optimal_path_index].gear;
179 (*optimal_path).total_length =
180 all_possible_paths[optimal_path_index].total_length;
181 (*optimal_path).segs_types =
182 all_possible_paths[optimal_path_index].segs_types;
183 (*optimal_path).segs_lengths =
184 all_possible_paths[optimal_path_index].segs_lengths;
208 const std::shared_ptr<Node3d> start_node,
209 const std::shared_ptr<Node3d> end_node,
210 std::vector<ReedSheppPath>* all_possible_paths) {
211 double dx = end_node->GetX() - start_node->GetX();
212 double dy = end_node->GetY() - start_node->GetY();
213 double dphi = end_node->GetPhi() - start_node->GetPhi();
214 double c = std::cos(start_node->GetPhi());
215 double s = std::sin(start_node->GetPhi());
222 if (!
SCS(x, y, dphi, all_possible_paths)) {
225 if (!
CSC(x, y, dphi, all_possible_paths)) {
228 if (!
CCC(x, y, dphi, all_possible_paths)) {
231 if (!
CCCC(x, y, dphi, all_possible_paths)) {
234 if (!
CCSC(x, y, dphi, all_possible_paths)) {
237 if (!
CCSCC(x, y, dphi, all_possible_paths)) {
238 ADEBUG <<
"Fail at CCSCC";
240 if (all_possible_paths->empty()) {
241 ADEBUG <<
"No path generated by certain two configurations";
272 std::vector<ReedSheppPath>* all_possible_paths) {
274 LS(x, y, phi, &LS1_param);
275 double LS1_lengths[2] = {LS1_param.
t, LS1_param.
u};
276 char LS1_types[] =
"LS";
277 if (LS1_param.
flag &&
278 !
SetRSP(2, LS1_lengths, LS1_types, all_possible_paths, LS1_param.
v)) {
279 ADEBUG <<
"Fail at SetRSP with LS_param";
283 LS(-x, y, -phi, &LS2_param);
284 double LS2_lengths[2] = {-LS2_param.
t, -LS2_param.
u};
285 char LS2_types[] =
"LS";
286 if (LS2_param.
flag &&
287 !
SetRSP(2, LS2_lengths, LS2_types, all_possible_paths, LS2_param.
v)) {
288 ADEBUG <<
"Fail at SetRSP with LS_param";
292 LS(x, -y, -phi, &RS1_param);
293 double RS1_lengths[2] = {RS1_param.
t, RS1_param.
u};
294 char RS1_types[] =
"RS";
295 if (RS1_param.
flag &&
296 !
SetRSP(2, RS1_lengths, RS1_types, all_possible_paths, RS1_param.
v)) {
297 ADEBUG <<
"Fail at SetRSP with SLS_param";
302 LS(-x, -y, phi, &RS2_param);
303 double RS2_lengths[2] = {-RS2_param.
t, -RS2_param.
u};
304 char RS2_types[] =
"RS";
305 if (RS2_param.
flag &&
306 !
SetRSP(2, RS2_lengths, RS2_types, all_possible_paths, RS2_param.
v)) {
307 ADEBUG <<
"Fail at SetRSP with SLS_param";
314 std::vector<ReedSheppPath>* all_possible_paths) {
316 LSL(x, y, phi, &LSL1_param);
317 double LSL1_lengths[3] = {LSL1_param.
t, LSL1_param.
u, LSL1_param.
v};
318 char LSL1_types[] =
"LSL";
319 if (LSL1_param.
flag &&
320 !
SetRSP(3, LSL1_lengths, LSL1_types, all_possible_paths)) {
321 ADEBUG <<
"Fail at SetRSP with LSL_param";
326 LSL(-x, y, -phi, &LSL2_param);
327 double LSL2_lengths[3] = {-LSL2_param.
t, -LSL2_param.
u, -LSL2_param.
v};
328 char LSL2_types[] =
"LSL";
329 if (LSL2_param.
flag &&
330 !
SetRSP(3, LSL2_lengths, LSL2_types, all_possible_paths)) {
331 ADEBUG <<
"Fail at SetRSP with LSL2_param";
336 LSL(x, -y, -phi, &LSL3_param);
337 double LSL3_lengths[3] = {LSL3_param.
t, LSL3_param.
u, LSL3_param.
v};
338 char LSL3_types[] =
"RSR";
339 if (LSL3_param.
flag &&
340 !
SetRSP(3, LSL3_lengths, LSL3_types, all_possible_paths)) {
341 ADEBUG <<
"Fail at SetRSP with LSL3_param";
346 LSL(-x, -y, phi, &LSL4_param);
347 double LSL4_lengths[3] = {-LSL4_param.
t, -LSL4_param.
u, -LSL4_param.
v};
348 char LSL4_types[] =
"RSR";
349 if (LSL4_param.
flag &&
350 !
SetRSP(3, LSL4_lengths, LSL4_types, all_possible_paths)) {
351 ADEBUG <<
"Fail at SetRSP with LSL4_param";
356 LSR(x, y, phi, &LSR1_param);
357 double LSR1_lengths[3] = {LSR1_param.
t, LSR1_param.
u, LSR1_param.
v};
358 char LSR1_types[] =
"LSR";
359 if (LSR1_param.
flag &&
360 !
SetRSP(3, LSR1_lengths, LSR1_types, all_possible_paths)) {
361 ADEBUG <<
"Fail at SetRSP with LSR1_param";
366 LSR(-x, y, -phi, &LSR2_param);
367 double LSR2_lengths[3] = {-LSR2_param.
t, -LSR2_param.
u, -LSR2_param.
v};
368 char LSR2_types[] =
"LSR";
369 if (LSR2_param.
flag &&
370 !
SetRSP(3, LSR2_lengths, LSR2_types, all_possible_paths)) {
371 ADEBUG <<
"Fail at SetRSP with LSR2_param";
376 LSR(x, -y, -phi, &LSR3_param);
377 double LSR3_lengths[3] = {LSR3_param.
t, LSR3_param.
u, LSR3_param.
v};
378 char LSR3_types[] =
"RSL";
379 if (LSR3_param.
flag &&
380 !
SetRSP(3, LSR3_lengths, LSR3_types, all_possible_paths)) {
381 ADEBUG <<
"Fail at SetRSP with LSR3_param";
386 LSR(-x, -y, phi, &LSR4_param);
387 double LSR4_lengths[3] = {-LSR4_param.
t, -LSR4_param.
u, -LSR4_param.
v};
388 char LSR4_types[] =
"RSL";
389 if (LSR4_param.
flag &&
390 !
SetRSP(3, LSR4_lengths, LSR4_types, all_possible_paths)) {
391 ADEBUG <<
"Fail at SetRSP with LSR4_param";
398 std::vector<ReedSheppPath>* all_possible_paths) {
400 LRL(x, y, phi, &LRL1_param);
401 double LRL1_lengths[3] = {LRL1_param.
t, LRL1_param.
u, LRL1_param.
v};
402 char LRL1_types[] =
"LRL";
403 if (LRL1_param.
flag &&
404 !
SetRSP(3, LRL1_lengths, LRL1_types, all_possible_paths)) {
405 ADEBUG <<
"Fail at SetRSP with LRL_param";
410 LRL(-x, y, -phi, &LRL2_param);
411 double LRL2_lengths[3] = {-LRL2_param.
t, -LRL2_param.
u, -LRL2_param.
v};
412 char LRL2_types[] =
"LRL";
413 if (LRL2_param.
flag &&
414 !
SetRSP(3, LRL2_lengths, LRL2_types, all_possible_paths)) {
415 ADEBUG <<
"Fail at SetRSP with LRL2_param";
420 LRL(x, -y, -phi, &LRL3_param);
421 double LRL3_lengths[3] = {LRL3_param.
t, LRL3_param.
u, LRL3_param.
v};
422 char LRL3_types[] =
"RLR";
423 if (LRL3_param.
flag &&
424 !
SetRSP(3, LRL3_lengths, LRL3_types, all_possible_paths)) {
425 ADEBUG <<
"Fail at SetRSP with LRL3_param";
430 LRL(-x, -y, phi, &LRL4_param);
431 double LRL4_lengths[3] = {-LRL4_param.
t, -LRL4_param.
u, -LRL4_param.
v};
432 char LRL4_types[] =
"RLR";
433 if (LRL4_param.
flag &&
434 !
SetRSP(3, LRL4_lengths, LRL4_types, all_possible_paths)) {
435 ADEBUG <<
"Fail at SetRSP with LRL4_param";
440 double xb = x * std::cos(phi) + y * std::sin(phi);
441 double yb = x * std::sin(phi) - y * std::cos(phi);
444 LRL(xb, yb, phi, &LRL5_param);
445 double LRL5_lengths[3] = {LRL5_param.
v, LRL5_param.
u, LRL5_param.
t};
446 char LRL5_types[] =
"LRL";
447 if (LRL5_param.
flag &&
448 !
SetRSP(3, LRL5_lengths, LRL5_types, all_possible_paths)) {
449 ADEBUG <<
"Fail at SetRSP with LRL5_param";
454 LRL(-xb, yb, -phi, &LRL6_param);
455 double LRL6_lengths[3] = {-LRL6_param.
v, -LRL6_param.
u, -LRL6_param.
t};
456 char LRL6_types[] =
"LRL";
457 if (LRL6_param.
flag &&
458 !
SetRSP(3, LRL6_lengths, LRL6_types, all_possible_paths)) {
459 ADEBUG <<
"Fail at SetRSP with LRL6_param";
464 LRL(xb, -yb, -phi, &LRL7_param);
465 double LRL7_lengths[3] = {LRL7_param.
v, LRL7_param.
u, LRL7_param.
t};
466 char LRL7_types[] =
"RLR";
467 if (LRL7_param.
flag &&
468 !
SetRSP(3, LRL7_lengths, LRL7_types, all_possible_paths)) {
469 ADEBUG <<
"Fail at SetRSP with LRL7_param";
474 LRL(-xb, -yb, phi, &LRL8_param);
475 double LRL8_lengths[3] = {-LRL8_param.
v, -LRL8_param.
u, -LRL8_param.
t};
476 char LRL8_types[] =
"RLR";
477 if (LRL8_param.
flag &&
478 !
SetRSP(3, LRL8_lengths, LRL8_types, all_possible_paths)) {
479 ADEBUG <<
"Fail at SetRSP with LRL8_param";
486 std::vector<ReedSheppPath>* all_possible_paths) {
488 LRLRn(x, y, phi, &LRLRn1_param);
489 double LRLRn1_lengths[4] = {LRLRn1_param.
t, LRLRn1_param.
u, -LRLRn1_param.
u,
491 char LRLRn1_types[] =
"LRLR";
492 if (LRLRn1_param.
flag &&
493 !
SetRSP(4, LRLRn1_lengths, LRLRn1_types, all_possible_paths)) {
494 ADEBUG <<
"Fail at SetRSP with LRLRn_param";
499 LRLRn(-x, y, -phi, &LRLRn2_param);
500 double LRLRn2_lengths[4] = {-LRLRn2_param.
t, -LRLRn2_param.
u, LRLRn2_param.
u,
502 char LRLRn2_types[] =
"LRLR";
503 if (LRLRn2_param.
flag &&
504 !
SetRSP(4, LRLRn2_lengths, LRLRn2_types, all_possible_paths)) {
505 ADEBUG <<
"Fail at SetRSP with LRLRn2_param";
510 LRLRn(x, -y, -phi, &LRLRn3_param);
511 double LRLRn3_lengths[4] = {LRLRn3_param.
t, LRLRn3_param.
u, -LRLRn3_param.
u,
513 char LRLRn3_types[] =
"RLRL";
514 if (LRLRn3_param.
flag &&
515 !
SetRSP(4, LRLRn3_lengths, LRLRn3_types, all_possible_paths)) {
516 ADEBUG <<
"Fail at SetRSP with LRLRn3_param";
521 LRLRn(-x, -y, phi, &LRLRn4_param);
522 double LRLRn4_lengths[4] = {-LRLRn4_param.
t, -LRLRn4_param.
u, LRLRn4_param.
u,
524 char LRLRn4_types[] =
"RLRL";
525 if (LRLRn4_param.
flag &&
526 !
SetRSP(4, LRLRn4_lengths, LRLRn4_types, all_possible_paths)) {
527 ADEBUG <<
"Fail at SetRSP with LRLRn4_param";
532 LRLRp(x, y, phi, &LRLRp1_param);
533 double LRLRp1_lengths[4] = {LRLRp1_param.
t, LRLRp1_param.
u, LRLRp1_param.
u,
535 char LRLRp1_types[] =
"LRLR";
536 if (LRLRp1_param.
flag &&
537 !
SetRSP(4, LRLRp1_lengths, LRLRp1_types, all_possible_paths)) {
538 ADEBUG <<
"Fail at SetRSP with LRLRp1_param";
543 LRLRp(-x, y, -phi, &LRLRp2_param);
544 double LRLRp2_lengths[4] = {-LRLRp2_param.
t, -LRLRp2_param.
u, -LRLRp2_param.
u,
546 char LRLRp2_types[] =
"LRLR";
547 if (LRLRp2_param.
flag &&
548 !
SetRSP(4, LRLRp2_lengths, LRLRp2_types, all_possible_paths)) {
549 ADEBUG <<
"Fail at SetRSP with LRLRp2_param";
554 LRLRp(x, -y, -phi, &LRLRp3_param);
555 double LRLRp3_lengths[4] = {LRLRp3_param.
t, LRLRp3_param.
u, LRLRp3_param.
u,
557 char LRLRp3_types[] =
"RLRL";
558 if (LRLRp3_param.
flag &&
559 !
SetRSP(4, LRLRp3_lengths, LRLRp3_types, all_possible_paths)) {
560 ADEBUG <<
"Fail at SetRSP with LRLRp3_param";
565 LRLRp(-x, -y, phi, &LRLRp4_param);
566 double LRLRp4_lengths[4] = {-LRLRp4_param.
t, -LRLRp4_param.
u, -LRLRp4_param.
u,
568 char LRLRp4_types[] =
"RLRL";
569 if (LRLRp4_param.
flag &&
570 !
SetRSP(4, LRLRp4_lengths, LRLRp4_types, all_possible_paths)) {
571 ADEBUG <<
"Fail at SetRSP with LRLRp4_param";
578 std::vector<ReedSheppPath>* all_possible_paths) {
580 LRSL(x, y, phi, &LRSL1_param);
581 double LRSL1_lengths[4] = {LRSL1_param.
t, -0.5 * M_PI, LRSL1_param.
u,
583 char LRSL1_types[] =
"LRSL";
584 if (LRSL1_param.
flag &&
585 !
SetRSP(4, LRSL1_lengths, LRSL1_types, all_possible_paths)) {
586 ADEBUG <<
"Fail at SetRSP with LRSL1_param";
591 LRSL(-x, y, -phi, &LRSL2_param);
592 double LRSL2_lengths[4] = {-LRSL2_param.
t, 0.5 * M_PI, -LRSL2_param.
u,
594 char LRSL2_types[] =
"LRSL";
595 if (LRSL2_param.
flag &&
596 !
SetRSP(4, LRSL2_lengths, LRSL2_types, all_possible_paths)) {
597 ADEBUG <<
"Fail at SetRSP with LRSL2_param";
602 LRSL(x, -y, -phi, &LRSL3_param);
603 double LRSL3_lengths[4] = {LRSL3_param.
t, -0.5 * M_PI, LRSL3_param.
u,
605 char LRSL3_types[] =
"RLSR";
606 if (LRSL3_param.
flag &&
607 !
SetRSP(4, LRSL3_lengths, LRSL3_types, all_possible_paths)) {
608 ADEBUG <<
"Fail at SetRSP with LRSL3_param";
613 LRSL(-x, -y, phi, &LRSL4_param);
614 double LRSL4_lengths[4] = {-LRSL4_param.
t, 0.5 * M_PI, -LRSL4_param.
u,
616 char LRSL4_types[] =
"RLSR";
617 if (LRSL4_param.
flag &&
618 !
SetRSP(4, LRSL4_lengths, LRSL4_types, all_possible_paths)) {
619 ADEBUG <<
"Fail at SetRSP with LRSL4_param";
624 LRSR(x, y, phi, &LRSR1_param);
625 double LRSR1_lengths[4] = {LRSR1_param.
t, -0.5 * M_PI, LRSR1_param.
u,
627 char LRSR1_types[] =
"LRSR";
628 if (LRSR1_param.
flag &&
629 !
SetRSP(4, LRSR1_lengths, LRSR1_types, all_possible_paths)) {
630 ADEBUG <<
"Fail at SetRSP with LRSR1_param";
635 LRSR(-x, y, -phi, &LRSR2_param);
636 double LRSR2_lengths[4] = {-LRSR2_param.
t, 0.5 * M_PI, -LRSR2_param.
u,
638 char LRSR2_types[] =
"LRSR";
639 if (LRSR2_param.
flag &&
640 !
SetRSP(4, LRSR2_lengths, LRSR2_types, all_possible_paths)) {
641 ADEBUG <<
"Fail at SetRSP with LRSR2_param";
646 LRSR(x, -y, -phi, &LRSR3_param);
647 double LRSR3_lengths[4] = {LRSR3_param.
t, -0.5 * M_PI, LRSR3_param.
u,
649 char LRSR3_types[] =
"RLSL";
650 if (LRSR3_param.
flag &&
651 !
SetRSP(4, LRSR3_lengths, LRSR3_types, all_possible_paths)) {
652 ADEBUG <<
"Fail at SetRSP with LRSR3_param";
657 LRSR(-x, -y, phi, &LRSR4_param);
658 double LRSR4_lengths[4] = {-LRSR4_param.
t, 0.5 * M_PI, -LRSR4_param.
u,
660 char LRSR4_types[] =
"RLSL";
661 if (LRSR4_param.
flag &&
662 !
SetRSP(4, LRSR4_lengths, LRSR4_types, all_possible_paths)) {
663 ADEBUG <<
"Fail at SetRSP with LRSR4_param";
668 double xb = x * std::cos(phi) + y * std::sin(phi);
669 double yb = x * std::sin(phi) - y * std::cos(phi);
672 LRSL(xb, yb, phi, &LRSL5_param);
673 double LRSL5_lengths[4] = {LRSL5_param.
v, LRSL5_param.
u, -0.5 * M_PI,
675 char LRSL5_types[] =
"LSRL";
676 if (LRSL5_param.
flag &&
677 !
SetRSP(4, LRSL5_lengths, LRSL5_types, all_possible_paths)) {
678 ADEBUG <<
"Fail at SetRSP with LRLRn_param";
683 LRSL(-xb, yb, -phi, &LRSL6_param);
684 double LRSL6_lengths[4] = {-LRSL6_param.
v, -LRSL6_param.
u, 0.5 * M_PI,
686 char LRSL6_types[] =
"LSRL";
687 if (LRSL6_param.
flag &&
688 !
SetRSP(4, LRSL6_lengths, LRSL6_types, all_possible_paths)) {
689 ADEBUG <<
"Fail at SetRSP with LRSL6_param";
694 LRSL(xb, -yb, -phi, &LRSL7_param);
695 double LRSL7_lengths[4] = {LRSL7_param.
v, LRSL7_param.
u, -0.5 * M_PI,
697 char LRSL7_types[] =
"RSLR";
698 if (LRSL7_param.
flag &&
699 !
SetRSP(4, LRSL7_lengths, LRSL7_types, all_possible_paths)) {
700 ADEBUG <<
"Fail at SetRSP with LRSL7_param";
705 LRSL(-xb, -yb, phi, &LRSL8_param);
706 double LRSL8_lengths[4] = {-LRSL8_param.
v, -LRSL8_param.
u, 0.5 * M_PI,
708 char LRSL8_types[] =
"RSLR";
709 if (LRSL8_param.
flag &&
710 !
SetRSP(4, LRSL8_lengths, LRSL8_types, all_possible_paths)) {
711 ADEBUG <<
"Fail at SetRSP with LRSL8_param";
716 LRSR(xb, yb, phi, &LRSR5_param);
717 double LRSR5_lengths[4] = {LRSR5_param.
v, LRSR5_param.
u, -0.5 * M_PI,
719 char LRSR5_types[] =
"RSRL";
720 if (LRSR5_param.
flag &&
721 !
SetRSP(4, LRSR5_lengths, LRSR5_types, all_possible_paths)) {
722 ADEBUG <<
"Fail at SetRSP with LRSR5_param";
727 LRSR(-xb, yb, -phi, &LRSR6_param);
728 double LRSR6_lengths[4] = {-LRSR6_param.
v, -LRSR6_param.
u, 0.5 * M_PI,
730 char LRSR6_types[] =
"RSRL";
731 if (LRSR6_param.
flag &&
732 !
SetRSP(4, LRSR6_lengths, LRSR6_types, all_possible_paths)) {
733 ADEBUG <<
"Fail at SetRSP with LRSR6_param";
738 LRSR(xb, -yb, -phi, &LRSR7_param);
739 double LRSR7_lengths[4] = {LRSR7_param.
v, LRSR7_param.
u, -0.5 * M_PI,
741 char LRSR7_types[] =
"LSLR";
742 if (LRSR7_param.
flag &&
743 !
SetRSP(4, LRSR7_lengths, LRSR7_types, all_possible_paths)) {
744 ADEBUG <<
"Fail at SetRSP with LRSR7_param";
749 LRSR(-xb, -yb, phi, &LRSR8_param);
750 double LRSR8_lengths[4] = {-LRSR8_param.
v, -LRSR8_param.
u, 0.5 * M_PI,
752 char LRSR8_types[] =
"LSLR";
753 if (LRSR8_param.
flag &&
754 !
SetRSP(4, LRSR8_lengths, LRSR8_types, all_possible_paths)) {
755 ADEBUG <<
"Fail at SetRSP with LRSR8_param";
762 std::vector<ReedSheppPath>* all_possible_paths) {
764 LRSLR(x, y, phi, &LRSLR1_param);
765 double LRSLR1_lengths[5] = {LRSLR1_param.
t, -0.5 * M_PI, LRSLR1_param.
u,
766 -0.5 * M_PI, LRSLR1_param.
v};
767 char LRSLR1_types[] =
"LRSLR";
768 if (LRSLR1_param.
flag &&
769 !
SetRSP(5, LRSLR1_lengths, LRSLR1_types, all_possible_paths)) {
770 ADEBUG <<
"Fail at SetRSP with LRSLR1_param";
775 LRSLR(-x, y, -phi, &LRSLR2_param);
776 double LRSLR2_lengths[5] = {-LRSLR2_param.
t, 0.5 * M_PI, -LRSLR2_param.
u,
777 0.5 * M_PI, -LRSLR2_param.
v};
778 char LRSLR2_types[] =
"LRSLR";
779 if (LRSLR2_param.
flag &&
780 !
SetRSP(5, LRSLR2_lengths, LRSLR2_types, all_possible_paths)) {
781 ADEBUG <<
"Fail at SetRSP with LRSLR2_param";
786 LRSLR(x, -y, -phi, &LRSLR3_param);
787 double LRSLR3_lengths[5] = {LRSLR3_param.
t, -0.5 * M_PI, LRSLR3_param.
u,
788 -0.5 * M_PI, LRSLR3_param.
v};
789 char LRSLR3_types[] =
"RLSRL";
790 if (LRSLR3_param.
flag &&
791 !
SetRSP(5, LRSLR3_lengths, LRSLR3_types, all_possible_paths)) {
792 ADEBUG <<
"Fail at SetRSP with LRSLR3_param";
797 LRSLR(-x, -y, phi, &LRSLR4_param);
798 double LRSLR4_lengths[5] = {-LRSLR4_param.
t, 0.5 * M_PI, -LRSLR4_param.
u,
799 0.5 * M_PI, -LRSLR4_param.
v};
800 char LRSLR4_types[] =
"RLSRL";
801 if (LRSLR4_param.
flag &&
802 !
SetRSP(5, LRSLR4_lengths, LRSLR4_types, all_possible_paths)) {
803 ADEBUG <<
"Fail at SetRSP with LRSLR4_param";
1066 const std::shared_ptr<Node3d> start_node,
1067 const std::shared_ptr<Node3d> end_node,
ReedSheppPath* shortest_path) {
1068 double radius = shortest_path->
radius;
1069 double step_scaled =
1072 size_t point_num =
static_cast<size_t>(
1073 std::floor(shortest_path->
total_length / step_scaled * radius +
1074 static_cast<double>(shortest_path->
segs_lengths.size()) + 4));
1075 ADEBUG <<
"point_num" << point_num;
1076 std::vector<double> px(point_num, 0.0);
1077 std::vector<double> py(point_num, 0.0);
1078 std::vector<double> pphi(point_num, 0.0);
1079 std::vector<bool> pgear(point_num,
true);
1089 pgear.at(0) =
false;
1093 for (
size_t i = 0; i < shortest_path->
segs_types.size(); ++i) {
1096 d = l > 0.0 ? step_scaled : -step_scaled;
1097 d = m ==
'S' ? d : d / radius;
1098 double ox = px.at(index);
1099 double oy = py.at(index);
1100 double ophi = pphi.at(index);
1109 while (std::abs(pd) <= std::abs(l)) {
1111 Interpolation(index, pd, m, ox, oy, ophi, radius, &px, &py, &pphi,
1117 Interpolation(index, l, m, ox, oy, ophi, radius, &px, &py, &pphi, &pgear);
1119 double epsilon = 1e-15;
1120 while (std::fabs(px.back()) < epsilon && std::fabs(py.back()) < epsilon &&
1121 std::fabs(pphi.back()) < epsilon && pgear.back()) {
1127 for (
size_t i = 0; i < px.size(); ++i) {
1128 shortest_path->
x.push_back(std::cos(-start_node->GetPhi()) * px.at(i) +
1129 std::sin(-start_node->GetPhi()) * py.at(i) +
1130 start_node->GetX());
1131 shortest_path->
y.push_back(-std::sin(-start_node->GetPhi()) * px.at(i) +
1132 std::cos(-start_node->GetPhi()) * py.at(i) +
1133 start_node->GetY());
1134 shortest_path->
phi.push_back(
1137 shortest_path->
gear = pgear;
1138 for (
size_t i = 0; i < shortest_path->
segs_lengths.size(); ++i) {
1210 const std::shared_ptr<Node3d> end_node,
1211 std::vector<ReedSheppPath>* all_possible_paths) {
1212 double dx = end_node->GetX() - start_node->GetX();
1213 double dy = end_node->GetY() - start_node->GetY();
1214 double dphi = end_node->GetPhi() - start_node->GetPhi();
1215 double c = std::cos(start_node->GetPhi());
1216 double s = std::sin(start_node->GetPhi());
1218 double x = (c * dx + s * dy) * this->
max_kappa_;
1219 double y = (-s * dx + c * dy) * this->
max_kappa_;
1221 double xb = x * std::cos(dphi) + y * std::sin(dphi);
1222 double yb = x * std::sin(dphi) - y * std::cos(dphi);
1225 all_possible_paths->resize(RSP_nums);
1227#pragma omp parallel for schedule(dynamic, 2) num_threads(8)
1228 for (
int i = 0; i < RSP_nums; ++i) {
1231 double RSP_lengths[5] = {0.0, 0.0, 0.0, 0.0, 0.0};
1232 double x_param = 1.0;
1233 double y_param = 1.0;
1234 std::string rd_type;
1236 if (i > 2 && i % 2) {
1239 if (i > 2 && i % 4 < 2) {
1250 SLS(x, y_param * y, y_param * dphi, &RSP_param);
1252 RSP_lengths[0] = RSP_param.
t;
1253 RSP_lengths[1] = RSP_param.
u;
1254 RSP_lengths[2] = RSP_param.
v;
1256 LSL(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1263 RSP_lengths[0] = x_param * RSP_param.
t;
1264 RSP_lengths[1] = x_param * RSP_param.
u;
1265 RSP_lengths[2] = x_param * RSP_param.
v;
1266 }
else if (i < 10) {
1267 LSR(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1274 RSP_lengths[0] = x_param * RSP_param.
t;
1275 RSP_lengths[1] = x_param * RSP_param.
u;
1276 RSP_lengths[2] = x_param * RSP_param.
v;
1277 }
else if (i < 14) {
1278 LRL(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1285 RSP_lengths[0] = x_param * RSP_param.
t;
1286 RSP_lengths[1] = x_param * RSP_param.
u;
1287 RSP_lengths[2] = x_param * RSP_param.
v;
1288 }
else if (i < 18) {
1289 LRL(x_param * xb, y_param * yb, x_param * y_param * dphi, &RSP_param);
1296 RSP_lengths[0] = x_param * RSP_param.
v;
1297 RSP_lengths[1] = x_param * RSP_param.
u;
1298 RSP_lengths[2] = x_param * RSP_param.
t;
1299 }
else if (i < 22) {
1300 LRLRn(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1301 if (y_param > 0.0) {
1307 RSP_lengths[0] = x_param * RSP_param.
t;
1308 RSP_lengths[1] = x_param * RSP_param.
u;
1309 RSP_lengths[2] = -x_param * RSP_param.
u;
1310 RSP_lengths[3] = x_param * RSP_param.
v;
1311 }
else if (i < 26) {
1312 LRLRp(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1313 if (y_param > 0.0) {
1319 RSP_lengths[0] = x_param * RSP_param.
t;
1320 RSP_lengths[1] = x_param * RSP_param.
u;
1321 RSP_lengths[2] = -x_param * RSP_param.
u;
1322 RSP_lengths[3] = x_param * RSP_param.
v;
1323 }
else if (i < 30) {
1325 LRLRn(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1326 if (y_param > 0.0) {
1331 RSP_lengths[0] = x_param * RSP_param.
t;
1332 if (x_param < 0 && y_param > 0) {
1333 RSP_lengths[1] = 0.5 * M_PI;
1335 RSP_lengths[1] = -0.5 * M_PI;
1337 if (x_param > 0 && y_param < 0) {
1338 RSP_lengths[2] = RSP_param.
u;
1340 RSP_lengths[2] = -RSP_param.
u;
1342 RSP_lengths[3] = x_param * RSP_param.
v;
1343 }
else if (i < 34) {
1345 LRLRp(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1351 RSP_lengths[0] = x_param * RSP_param.
t;
1352 if (x_param < 0 && y_param > 0) {
1353 RSP_lengths[1] = 0.5 * M_PI;
1355 RSP_lengths[1] = -0.5 * M_PI;
1357 RSP_lengths[2] = x_param * RSP_param.
u;
1358 RSP_lengths[3] = x_param * RSP_param.
v;
1359 }
else if (i < 38) {
1361 LRLRn(x_param * xb, y_param * yb, x_param * y_param * dphi, &RSP_param);
1367 RSP_lengths[0] = x_param * RSP_param.
v;
1368 RSP_lengths[1] = x_param * RSP_param.
u;
1369 RSP_lengths[2] = -x_param * 0.5 * M_PI;
1370 RSP_lengths[3] = x_param * RSP_param.
t;
1371 }
else if (i < 42) {
1373 LRLRp(x_param * xb, y_param * yb, x_param * y_param * dphi, &RSP_param);
1379 RSP_lengths[0] = x_param * RSP_param.
v;
1380 RSP_lengths[1] = x_param * RSP_param.
u;
1381 RSP_lengths[2] = -x_param * M_PI * 0.5;
1382 RSP_lengths[3] = x_param * RSP_param.
t;
1385 LRSLR(x_param * x, y_param * y, x_param * y_param * dphi, &RSP_param);
1386 if (y_param > 0.0) {
1391 RSP_lengths[0] = x_param * RSP_param.
t;
1392 RSP_lengths[1] = -x_param * 0.5 * M_PI;
1393 RSP_lengths[2] = x_param * RSP_param.
u;
1394 RSP_lengths[3] = -x_param * 0.5 * M_PI;
1395 RSP_lengths[4] = x_param * RSP_param.
v;
1398 if (tmp_length > 0) {
1399 if (RSP_param.
flag &&
1400 !
SetRSPPar(tmp_length, RSP_lengths, rd_type, all_possible_paths, i)) {
1401 AERROR <<
"Fail at SetRSP, idx#: " << i;
1408 AERROR <<
"RSP parallel fails";
1411 if (all_possible_paths->size() == 0) {
1412 AERROR <<
"No path generated by certain two configurations";