unicycle_move_to_pose
Move to specified pose
P. I. Corke, "Robotics, Vision & Control", Springer 2017, ISBN 978-3-319-54413-7
AckermannDrive
DynamicsModel for AckermannDrive
ẋ = v cos(θ) ẏ = v sin(θ) θ̇ = (v/L) tan(ϕ)
L is the distance between front and back wheels state = [x, y, θ] input = [v, v tan(ϕ)]
Source code in bayes_cbf/unicycle_move_to_pose.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
f_func(x)
ṡ = f(s) + G(s) u
s = [x, y, θ] u = [v, v tan(ϕ)]
[ 0 ]
f(s) = [ 0 ] [ 0 ]
Source code in bayes_cbf/unicycle_move_to_pose.py
222 223 224 225 226 227 228 229 230 231 232 233 |
|
g_func(state_in)
ṡ = f(s) + G(s) u
s = [x, y, θ] u = [v, v tan(ϕ)]
[ cos(θ) , 0 ]
G(s)u = [ sin(θ) , 0 ] [ v ] [ 0 1/L] [ v tan(ø) ]
Source code in bayes_cbf/unicycle_move_to_pose.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
|
CLFCartesian
Source code in bayes_cbf/unicycle_move_to_pose.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
|
grad_clf(state, state_goal)
self = CLFCartesian() x0 = torch.rand(3) x0_goal = torch.rand(3) ajac = self.grad_clf(x0, x0_goal) njac = numerical_jac(lambda x: self.clf_terms(x, x0_goal).sum(), x0, 1e-6)[0] testing.assert_allclose(njac, ajac, rtol=1e-3, atol=1e-4)
Source code in bayes_cbf/unicycle_move_to_pose.py
590 591 592 593 594 595 596 597 598 599 |
|
grad_clf_wrt_goal(state, state_goal)
self = CLFCartesian() x0 = torch.rand(3) x0_goal = torch.rand(3) ajac = self.grad_clf_wrt_goal(x0, x0_goal) njac = numerical_jac(lambda xg: self.clf_terms(x0, xg).sum(), x0_goal, 1e-6)[0] testing.assert_allclose(njac, ajac, rtol=1e-3, atol=1e-4)
Source code in bayes_cbf/unicycle_move_to_pose.py
601 602 603 604 605 606 607 608 609 610 |
|
CLFPolar
Source code in bayes_cbf/unicycle_move_to_pose.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
|
grad_clf(polar, state_goal)
self = CLFPolar() x0 = torch.rand(3) state_goal = torch.rand(3) ajac = self.grad_clf(x0, state_goal) njac = numerical_jac(lambda x: self._clf_terms(x, state_goal).sum(), x0, 1e-6)[0] testing.assert_allclose(njac, ajac, rtol=1e-3, atol=1e-4)
Source code in bayes_cbf/unicycle_move_to_pose.py
458 459 460 461 462 463 464 465 466 467 |
|
ControllerCLF
Aicardi, M., Casalino, G., Bicchi, A., & Balestrino, A. (1995). Closed loop steering of unicycle like vehicles via Lyapunov techniques. IEEE Robotics & Automation Magazine, 2(1), 27-35.
Source code in bayes_cbf/unicycle_move_to_pose.py
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 |
|
ObstacleCBF
Source code in bayes_cbf/unicycle_move_to_pose.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
|
grad_cbf(state)
self = ObstacleCBF(torch.rand(2), torch.rand(1)) x0 = torch.rand(3) ajac = self.grad_cbf(x0) njac = numerical_jac(lambda x: self.cbf(x), x0, 1e-6)[0] testing.assert_allclose(njac, ajac, rtol=1e-3, atol=1e-4)
Source code in bayes_cbf/unicycle_move_to_pose.py
683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
|
cartesian2polar(state, state_goal)
rho is the distance between the robot and the goal position : \sqrt((x-x)^2 + (y-y)^2) alpha is the heading of the robot relative the angle to the goal : theta - atan2((y-y),(x-x)) beta is the goal position relative to the angle to the goal : theta - atan2((y-y),(x*-x))
state = torch.rand(3) torch.tensor([2, 2, 2math.pi]) - torch.tensor([1, 1, math.pi]) state_goal = torch.rand(3) torch.tensor([2, 2, 2math.pi]) - torch.tensor([1, 1, math.pi]) polar = cartesian2polar(state, state_goal) statep = polar2cartesian(polar, state_goal) testing.assert_allclose(state, statep)
Source code in bayes_cbf/unicycle_move_to_pose.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
move_to_pose(state_start, state_goal, dt=0.01, show_animation=True, controller=None, dynamics=CartesianDynamics(), visualizer=None)
rho is the distance between the robot and the goal position alpha is the angle to the goal relative to the heading of the robot beta is the angle between the robot's position and the goal position plus the goal angle
Kp_rhorho and Kp_alphaalpha drive the robot along a line towards the goal Kp_beta*beta rotates the line so that it is parallel to the goal angle
Source code in bayes_cbf/unicycle_move_to_pose.py
1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 |
|
numerical_jac(func, x0_in, eps, dtype=torch.float64)
def func(x): return torch.tensor([torch.cos(x[0]), torch.sin(x[1])]) def jacfunc(x): return torch.tensor([[-torch.sin(x[0]), 0], [0, torch.cos(x[1])]]) x0 = torch.rand(2) njac = numerical_jac(func, x0, 1e-6) ajac = jacfunc(x0) testing.assert_allclose(njac, ajac, rtol=1e-3, atol=1e-4)
Source code in bayes_cbf/unicycle_move_to_pose.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
|
polar2cartesian(x, state_goal)
rho is the distance between the robot and the goal position : \sqrt((x-x)^2 + (y-y)^2)
alpha is the heading of the robot relative the angle to the goal : theta - atan2((y-y),(x-x))
beta is the goal position relative to the angle to the goal : theta - atan2((y-y),(x*-x))
polar = (torch.rand(3) * torch.tensor([1, 2math.pi, 2math.pi]) - ... torch.tensor([0, math.pi, math.pi])) state_goal = (torch.rand(3) * torch.tensor([2, 2, 2*math.pi]) - ... torch.tensor([1, 1, math.pi])) state = polar2cartesian(polar, state_goal) polarp = cartesian2polar(state, state_goal) testing.assert_allclose(polar, polarp)
Source code in bayes_cbf/unicycle_move_to_pose.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
track_trajectory_ackerman_clf_bayesian(x, x_g, dt=None, cbfs=None, cbf_gammas=None, numSteps=None, enable_learning=True, mean_dynamics_gen=partial(AckermannDrive, L=10.0), true_dynamics_gen=partial(AckermannDrive, L=1.0), visualizer_class=Visualizer, controller_class=ControllerCLFBayesian, train_every_n_steps=20, **kw)
mean_dynamics is either ZeroDynamicsModel(m = 2, n = 3) or AckermannDrive(L = 10.0)
Source code in bayes_cbf/unicycle_move_to_pose.py
1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 |
|