repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
PythonRobotics
Localization/unscented_kalman_filter/unscented_kalman_filter.py
.py
""" Unscented kalman filter (UKF) localization sample author: Atsushi Sakai (@Atsushi_twi) """ import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.parent)) import math import matplotlib.pyplot as plt import numpy as np import scipy.linalg from utils.angle import rot_mat_2d # Covar...
342
8,638
PythonRobotics
PathTracking/rear_wheel_feedback_control/rear_wheel_feedback_control.py
.py
""" Path tracking simulation with rear wheel feedback steering control and PID speed control. author: Atsushi Sakai(@Atsushi_twi) """ import matplotlib.pyplot as plt import math import numpy as np import sys import pathlib from scipy import interpolate from scipy import optimize sys.path.append(str(pathlib.Path(__f...
235
6,415
PythonRobotics
PathTracking/lqr_speed_steer_control/lqr_speed_steer_control.py
.py
""" Path tracking simulation with LQR speed and steering control author Atsushi Sakai (@Atsushi_twi) """ import math import sys import matplotlib.pyplot as plt import numpy as np import scipy.linalg as la import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.parent)) from utils.angle import angle_...
322
7,741
PythonRobotics
PathTracking/move_to_pose/move_to_pose.py
.py
""" Move to specified pose Author: Daniel Ingram (daniel-s-ingram) Atsushi Sakai (@Atsushi_twi) Seied Muhammad Yazdian (@Muhammad-Yazdian) Wang Zheng (@Aglargil) P. I. Corke, "Robotics, Vision & Control", Springer 2017, ISBN 978-3-319-54413-7 """ import matplotlib.pyplot as plt import numpy...
224
6,768
PythonRobotics
PathTracking/move_to_pose/move_to_pose_robot.py
.py
""" Move to specified pose (with Robot class) Author: Daniel Ingram (daniel-s-ingram) Atsushi Sakai (@Atsushi_twi) Seied Muhammad Yazdian (@Muhammad-Yazdian) P.I. Corke, "Robotics, Vision & Control", Springer 2017, ISBN 978-3-319-54413-7 """ import matplotlib.pyplot as plt import numpy as np import...
241
7,387
PythonRobotics
PathTracking/lqr_steer_control/lqr_steer_control.py
.py
""" Path tracking simulation with LQR steering control and PID speed control. author Atsushi Sakai (@Atsushi_twi) """ import scipy.linalg as la import matplotlib.pyplot as plt import math import numpy as np import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.parent)) from utils.angle ...
292
6,687
PythonRobotics
PathTracking/pure_pursuit/pure_pursuit.py
.py
""" Path tracking simulation with pure pursuit steering and PID speed control. author: Atsushi Sakai (@Atsushi_twi) Guillaume Jacquenot (@Gjacquenot) """ import numpy as np import math import matplotlib.pyplot as plt import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.parent))...
350
10,821
PythonRobotics
PathTracking/stanley_control/stanley_control.py
.py
""" Path tracking simulation with Stanley steering control and PID speed control. author: Atsushi Sakai (@Atsushi_twi) Reference: - [Stanley: The robot that won the DARPA grand challenge](http://isl.ecst.csuchico.edu/DOCS/darpa2005/DARPA%202005%20Stanley.pdf) - [Autonomous Automobile Path Tracking](https://w...
213
5,859
PythonRobotics
PathTracking/cgmres_nmpc/cgmres_nmpc.py
.py
""" Nonlinear MPC simulation with CGMRES author Atsushi Sakai (@Atsushi_twi) Reference: Shunichi09/nonlinear_control: Implementing the nonlinear model predictive control, sliding mode control https://github.com/Shunichi09/PythonLinearNonlinearControl """ from math import cos, sin, radians, atan2 import matplotlib...
617
20,208
PythonRobotics
PathTracking/model_predictive_speed_and_steer_control/model_predictive_speed_and_steer_control.py
.py
""" Path tracking simulation with iterative linear model predictive control for speed and steer control author: Atsushi Sakai (@Atsushi_twi) """ import matplotlib.pyplot as plt import time import cvxpy import math import numpy as np import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.p...
629
16,795
PythonRobotics
Bipedal/bipedal_planner/bipedal_planner.py
.py
""" Bipedal Walking with modifying designated footsteps author: Takayuki Murooka (takayuki5168) """ import numpy as np import math from matplotlib import pyplot as plt import matplotlib.patches as pat from mpl_toolkits.mplot3d import Axes3D import mpl_toolkits.mplot3d.art3d as art3d class BipedalPlanner(object): ...
206
8,048
PythonRobotics
InvertedPendulum/inverted_pendulum_mpc_control.py
.py
""" Inverted Pendulum MPC control author: Atsushi Sakai """ import math import time import cvxpy import matplotlib.pyplot as plt import numpy as np # Model parameters l_bar = 2.0 # length of bar M = 1.0 # [kg] m = 0.3 # [kg] g = 9.8 # [m/s^2] nx = 4 # number of state nu = 1 # number of input Q = np.diag([0.0...
188
4,345
PythonRobotics
InvertedPendulum/inverted_pendulum_lqr_control.py
.py
""" Inverted Pendulum LQR control author: Trung Kien - letrungkien.k53.hut@gmail.com """ import math import time import matplotlib.pyplot as plt import numpy as np from numpy.linalg import inv, eig # Model parameters l_bar = 2.0 # length of bar M = 1.0 # [kg] m = 0.3 # [kg] g = 9.8 # [m/s^2] nx = 4 # number o...
193
4,187
PythonRobotics
PathPlanning/ProbabilisticRoadMap/probabilistic_road_map.py
.py
""" Probabilistic Road Map (PRM) Planner author: Atsushi Sakai (@Atsushi_twi) """ import math import numpy as np import matplotlib.pyplot as plt from scipy.spatial import KDTree # parameter N_SAMPLE = 500 # number of sample_points N_KNN = 10 # number of edge from one sampled point MAX_EDGE_LEN = 30.0 # [m] Maxi...
313
8,230
PythonRobotics
PathPlanning/DubinsPath/dubins_path_planner.py
.py
""" Dubins path planner sample code author Atsushi Sakai(@Atsushi_twi) """ import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.parent)) from math import sin, cos, atan2, sqrt, acos, pi, hypot import numpy as np from utils.angle import angle_mod, rot_mat_2d show_animation = True def...
318
10,216
PythonRobotics
PathPlanning/BidirectionalAStar/bidirectional_a_star.py
.py
""" Bidirectional A* grid planning author: Erwin Lejeune (@spida_rwin) See Wikipedia article (https://en.wikipedia.org/wiki/Bidirectional_search) """ import math import matplotlib.pyplot as plt show_animation = True class BidirectionalAStarPlanner: def __init__(self, ox, oy, resolution, rr): """ ...
348
11,287
PythonRobotics
PathPlanning/VoronoiRoadMap/voronoi_road_map.py
.py
""" Voronoi Road Map Planner author: Atsushi Sakai (@Atsushi_twi) """ import math import numpy as np import matplotlib.pyplot as plt from scipy.spatial import cKDTree, Voronoi import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent)) from VoronoiRoadMap.dijkstra_search import DijkstraSea...
187
4,858
PythonRobotics
PathPlanning/VoronoiRoadMap/dijkstra_search.py
.py
""" Dijkstra Search library author: Atsushi Sakai (@Atsushi_twi) """ import matplotlib.pyplot as plt import math import numpy as np class DijkstraSearch: class Node: """ Node class for dijkstra search """ def __init__(self, x, y, cost=None, parent=None, edge_ids=None): ...
141
4,504
PythonRobotics
PathPlanning/BugPlanning/bug.py
.py
""" Bug Planning author: Sarim Mehdi(muhammadsarim.mehdi@studio.unibo.it) Source: https://web.archive.org/web/20201103052224/https://sites.google.com/site/ece452bugalgorithms/ """ import numpy as np import matplotlib.pyplot as plt show_animation = True class BugPlanner: def __init__(self, start_x, start_y, goal...
334
12,679
PythonRobotics
PathPlanning/GridBasedSweepCPP/grid_based_sweep_coverage_path_planner.py
.py
""" Grid based sweep planner author: Atsushi Sakai """ import math from enum import IntEnum import numpy as np import matplotlib.pyplot as plt import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.parent)) from utils.angle import rot_mat_2d from Mapping.grid_map_lib.grid_map_lib import G...
322
10,460
PythonRobotics
PathPlanning/BatchInformedRRTStar/batch_informed_rrt_star.py
.py
""" Batch Informed Trees based path planning: Uses a heuristic to efficiently search increasingly dense RGGs while reusing previous information. Provides faster convergence that RRT*, Informed RRT* and other sampling based methods. Uses lazy connecting by combining sampling based methods and A* like incremental graph ...
636
23,993
PythonRobotics
PathPlanning/BezierPath/bezier_path.py
.py
""" Path planning with Bezier curve. author: Atsushi Sakai(@Atsushi_twi) """ import matplotlib.pyplot as plt import numpy as np import scipy.special show_animation = True def calc_4points_bezier_path(sx, sy, syaw, ex, ey, eyaw, offset): """ Compute control points and path given start and end position. ...
216
6,811
PythonRobotics
PathPlanning/Dijkstra/dijkstra.py
.py
""" Grid based Dijkstra planning author: Atsushi Sakai(@Atsushi_twi) """ import matplotlib.pyplot as plt import math show_animation = True class DijkstraPlanner: def __init__(self, ox, oy, resolution, robot_radius): """ Initialize map for a star planning ox: x position list of Obsta...
260
7,902
PythonRobotics
PathPlanning/ModelPredictiveTrajectoryGenerator/trajectory_generator.py
.py
""" Model trajectory generator author: Atsushi Sakai(@Atsushi_twi) """ import math import matplotlib.pyplot as plt import numpy as np import sys import pathlib path_planning_dir = pathlib.Path(__file__).parent.parent sys.path.append(str(path_planning_dir)) import ModelPredictiveTrajectoryGenerator.motion_model as ...
163
4,407
PythonRobotics
PathPlanning/ModelPredictiveTrajectoryGenerator/lookup_table_generator.py
.py
""" Lookup Table generation for model predictive trajectory generator author: Atsushi Sakai """ import sys import pathlib path_planning_dir = pathlib.Path(__file__).parent.parent sys.path.append(str(path_planning_dir)) from matplotlib import pyplot as plt import numpy as np import math from ModelPredictiveTrajecto...
111
2,775
PythonRobotics
PathPlanning/ModelPredictiveTrajectoryGenerator/motion_model.py
.py
import math import numpy as np from scipy.interpolate import interp1d from utils.angle import angle_mod # motion parameter L = 1.0 # wheel base ds = 0.1 # course distance v = 10.0 / 3.6 # velocity [m/s] class State: def __init__(self, x=0.0, y=0.0, yaw=0.0, v=0.0): self.x = x self.y = y ...
96
2,166
PythonRobotics
PathPlanning/TimeBasedPathPlanning/PriorityBasedPlanner.py
.py
""" Priority Based Planner for multi agent path planning. The planner generates an order to plan in, and generates plans for the robots in that order. Each planned path is reserved in the grid, and all future plans must avoid that path. Algorithm outlined in section III of this paper: https://pure.tudelft.nl/ws/portal...
95
3,660
PythonRobotics
PathPlanning/TimeBasedPathPlanning/SafeInterval.py
.py
""" Safe interval path planner This script implements a safe-interval path planner for a 2d grid with dynamic obstacles. It is faster than SpaceTime A* because it reduces the number of redundant node expansions by pre-computing regions of adjacent time steps that are safe ("safe intervals") at each position...
213
8,582
PythonRobotics
PathPlanning/TimeBasedPathPlanning/Plotting.py
.py
import numpy as np import matplotlib.pyplot as plt from matplotlib.backend_bases import KeyEvent from PathPlanning.TimeBasedPathPlanning.GridWithDynamicObstacles import ( Grid, Position, ) from PathPlanning.TimeBasedPathPlanning.BaseClasses import StartAndGoal from PathPlanning.TimeBasedPathPlanning.Node import...
135
4,807
PythonRobotics
PathPlanning/TimeBasedPathPlanning/BaseClasses.py
.py
from abc import ABC, abstractmethod from dataclasses import dataclass from PathPlanning.TimeBasedPathPlanning.GridWithDynamicObstacles import ( Grid, Position, ) from PathPlanning.TimeBasedPathPlanning.Node import NodePath import random import numpy.random as numpy_random # Seed randomness for reproducibility ...
49
1,425
PythonRobotics
PathPlanning/TimeBasedPathPlanning/GridWithDynamicObstacles.py
.py
""" This file implements a grid with a 3d reservation matrix with dimensions for x, y, and time. There is also infrastructure to generate dynamic obstacles that move around the grid. The obstacles' paths are stored in the reservation matrix on creation. """ import numpy as np import matplotlib.pyplot as plt from enum i...
371
14,062
PythonRobotics
PathPlanning/TimeBasedPathPlanning/SpaceTimeAStar.py
.py
""" Space-time A* Algorithm This script demonstrates the Space-time A* algorithm for path planning in a grid world with moving obstacles. This algorithm is different from normal 2D A* in one key way - the cost (often notated as g(n)) is the number of time steps it took to get to a given node, instead of the...
140
4,695
PythonRobotics
PathPlanning/TimeBasedPathPlanning/Node.py
.py
from dataclasses import dataclass from functools import total_ordering import numpy as np from typing import Sequence @dataclass(order=True) class Position: x: int y: int def as_ndarray(self) -> np.ndarray: return np.array([self.x, self.y]) def __add__(self, other): if isinstance(othe...
99
3,413
PythonRobotics
PathPlanning/AStar/a_star_searching_from_two_side.py
.py
""" A* algorithm Author: Weicent randomly generate obstacles, start and goal point searching path from start and end simultaneously """ import numpy as np import matplotlib.pyplot as plt import math show_animation = True class Node: """node with properties of g, h, coordinate and parent node""" def __init_...
370
13,741
PythonRobotics
PathPlanning/AStar/a_star_variants.py
.py
""" a star variants author: Sarim Mehdi(muhammadsarim.mehdi@studio.unibo.it) Source: http://theory.stanford.edu/~amitp/GameProgramming/Variations.html """ import numpy as np import matplotlib.pyplot as plt show_animation = True use_beam_search = False use_iterative_deepening = False use_dynamic_weighting = False use_...
484
18,918
PythonRobotics
PathPlanning/AStar/a_star.py
.py
""" A* grid planning author: Atsushi Sakai(@Atsushi_twi) Nikos Kanargias (nkana@tee.gr) See Wikipedia article (https://en.wikipedia.org/wiki/A*_search_algorithm) """ import math import matplotlib.pyplot as plt show_animation = True class AStarPlanner: def __init__(self, ox, oy, resolution, rr): ...
283
8,717
PythonRobotics
PathPlanning/ClothoidPath/clothoid_path_planner.py
.py
""" Clothoid Path Planner Author: Daniel Ingram (daniel-s-ingram) Atsushi Sakai (AtsushiSakai) Reference paper: Fast and accurate G1 fitting of clothoid curves https://www.researchgate.net/publication/237062806 """ from collections import namedtuple import matplotlib.pyplot as plt import numpy as np import sci...
193
5,742
PythonRobotics
PathPlanning/CubicSpline/spline_continuity.py
.py
import numpy as np import matplotlib.pyplot as plt from scipy import interpolate class Spline2D: def __init__(self, x, y, kind="cubic"): self.s = self.__calc_s(x, y) self.sx = interpolate.interp1d(self.s, x, kind=kind) self.sy = interpolate.interp1d(self.s, y, kind=kind) def __calc_...
56
1,408
PythonRobotics
PathPlanning/CubicSpline/cubic_spline_planner.py
.py
""" Cubic spline planner Author: Atsushi Sakai(@Atsushi_twi) """ import math import numpy as np import bisect class CubicSpline1D: """ 1D Cubic Spline class Parameters ---------- x : list x coordinates for data points. This x coordinates must be sorted in ascending order...
456
11,362
PythonRobotics
PathPlanning/Eta3SplinePath/eta3_spline_path.py
.py
""" eta^3 polynomials planner author: Joe Dinius, Ph.D (https://jwdinius.github.io) Atsushi Sakai (@Atsushi_twi) Reference: - [eta^3-Splines for the Smooth Path Generation of Wheeled Mobile Robots] (https://ieeexplore.ieee.org/document/4339545/) """ import numpy as np import matplotlib.pyplot as plt from s...
362
13,655
PythonRobotics
PathPlanning/GreedyBestFirstSearch/greedy_best_first_search.py
.py
""" Greedy Best-First grid planning author: Erwin Lejeune (@spida_rwin) See Wikipedia article (https://en.wikipedia.org/wiki/Best-first_search) """ import math import matplotlib.pyplot as plt show_animation = True class BestFirstSearchPlanner: def __init__(self, ox, oy, reso, rr): """ Init...
279
8,238
PythonRobotics
PathPlanning/SpiralSpanningTreeCPP/spiral_spanning_tree_coverage_path_planner.py
.py
""" Spiral Spanning Tree Coverage Path Planner author: Todd Tang paper: Spiral-STC: An On-Line Coverage Algorithm of Grid Environments by a Mobile Robot - Gabriely et.al. link: https://ieeexplore.ieee.org/abstract/document/1013479 """ import os import sys import math import numpy as np import matplotlib.pyp...
314
10,836
PythonRobotics
PathPlanning/FlowField/flowfield.py
.py
""" flowfield pathfinding author: Sarim Mehdi (muhammadsarim.mehdi@studio.unibo.it) Source: https://leifnode.com/2013/12/flow-field-pathfinding/ """ import numpy as np import matplotlib.pyplot as plt show_animation = True def draw_horizontal_line(start_x, start_y, length, o_x, o_y, o_dict, path): for i in range...
228
8,876
PythonRobotics
PathPlanning/WavefrontCPP/wavefront_coverage_path_planner.py
.py
""" Distance/Path Transform Wavefront Coverage Path Planner author: Todd Tang paper: Planning paths of complete coverage of an unstructured environment by a mobile robot - Zelinsky et.al. link: https://pinkwink.kr/attachment/cfile3.uf@1354654A4E8945BD13FE77.pdf """ import os import sys import matplotlib.pyp...
219
6,927
PythonRobotics
PathPlanning/VisibilityRoadMap/visibility_road_map.py
.py
""" Visibility Road Map Planner author: Atsushi Sakai (@Atsushi_twi) """ import sys import math import numpy as np import matplotlib.pyplot as plt import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent)) from VisibilityRoadMap.geometry import Geometry from VoronoiRoadMap.dijkstra_search import Dij...
223
6,606
PythonRobotics
PathPlanning/VisibilityRoadMap/geometry.py
.py
class Geometry: class Point: def __init__(self, x, y): self.x = x self.y = y @staticmethod def is_seg_intersect(p1, q1, p2, q2): def on_segment(p, q, r): if ((q.x <= max(p.x, r.x)) and (q.x >= min(p.x, r.x)) and (q.y <= max(p.y, r.y)...
45
1,278
PythonRobotics
PathPlanning/RRTStarDubins/rrt_star_dubins.py
.py
""" Path planning Sample Code with RRT and Dubins path author: AtsushiSakai(@Atsushi_twi) """ import copy import math import random import matplotlib.pyplot as plt import numpy as np import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.parent)) # root dir sys.path.append(str(pathlib.Pat...
247
7,673
PythonRobotics
PathPlanning/DynamicMovementPrimitives/dynamic_movement_primitives.py
.py
""" Author: Jonathan Schwartz (github.com/SchwartzCode) This code provides a simple implementation of Dynamic Movement Primitives, which is an approach to learning curves by modelling them as a weighted sum of gaussian distributions. This approach can be used to dampen noise in a curve, and can also be used to stretch...
261
8,508
PythonRobotics
PathPlanning/RRTStar/rrt_star.py
.py
""" Path planning Sample Code with RRT* author: Atsushi Sakai(@Atsushi_twi) """ import math import sys import matplotlib.pyplot as plt import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent)) from RRT.rrt import RRT show_animation = True class RRTStar(RRT): """ Class for RRT Star planni...
290
9,512
PythonRobotics
PathPlanning/BreadthFirstSearch/breadth_first_search.py
.py
""" Breadth-First grid planning author: Erwin Lejeune (@spida_rwin) See Wikipedia article (https://en.wikipedia.org/wiki/Breadth-first_search) """ import math import matplotlib.pyplot as plt show_animation = True class BreadthFirstSearchPlanner: def __init__(self, ox, oy, reso, rr): """ In...
259
7,736
PythonRobotics
PathPlanning/BidirectionalBreadthFirstSearch/bidirectional_breadth_first_search.py
.py
""" Bidirectional Breadth-First grid planning author: Erwin Lejeune (@spida_rwin) See Wikipedia article (https://en.wikipedia.org/wiki/Breadth-first_search) """ import math import matplotlib.pyplot as plt show_animation = True class BidirectionalBreadthFirstSearchPlanner: def __init__(self, ox, oy, resolu...
318
10,126
PythonRobotics
PathPlanning/InformedRRTStar/informed_rrt_star.py
.py
""" Informed RRT* path planning author: Karan Chawla Atsushi Sakai(@Atsushi_twi) Reference: Informed RRT*: Optimal Sampling-based Path planning Focused via Direct Sampling of an Admissible Ellipsoidal Heuristic https://arxiv.org/pdf/1404.2334 """ import sys import pathlib sys.path.append(str(pathlib.Path(__...
351
12,157
PythonRobotics
PathPlanning/RRTStarReedsShepp/rrt_star_reeds_shepp.py
.py
""" Path planning Sample Code with RRT with Reeds-Shepp path author: AtsushiSakai(@Atsushi_twi) """ import copy import math import random import sys import pathlib import matplotlib.pyplot as plt import numpy as np sys.path.append(str(pathlib.Path(__file__).parent.parent)) from ReedsSheppPath import reeds_shepp_pat...
266
8,265
PythonRobotics
PathPlanning/ClosedLoopRRTStar/pure_pursuit.py
.py
""" Path tracking simulation with pure pursuit steering control and PID speed control. author: Atsushi Sakai """ import math import matplotlib.pyplot as plt import numpy as np import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent)) from ClosedLoopRRTStar import unicycle_model Kp = 2....
301
7,679
PythonRobotics
PathPlanning/ClosedLoopRRTStar/closed_loop_rrt_star_car.py
.py
""" Path planning Sample Code with Closed loop RRT for car like robot. author: AtsushiSakai(@Atsushi_twi) """ import matplotlib.pyplot as plt import numpy as np import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent)) from ClosedLoopRRTStar import pure_pursuit from ClosedLoopRRTStar imp...
217
6,222
PythonRobotics
PathPlanning/ClosedLoopRRTStar/unicycle_model.py
.py
""" Unicycle model class author Atsushi Sakai """ import math import numpy as np from utils.angle import angle_mod dt = 0.05 # [s] L = 0.9 # [m] steer_max = np.deg2rad(40.0) curvature_max = math.tan(steer_max) / L curvature_max = 1.0 / curvature_max + 1.0 accel_max = 5.0 class State: def __init__(self, x...
81
1,413
PythonRobotics
PathPlanning/LQRRRTStar/lqr_rrt_star.py
.py
""" Path planning code with LQR RRT* author: AtsushiSakai(@Atsushi_twi) """ import copy import math import random import matplotlib.pyplot as plt import numpy as np import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent)) from LQRPlanner.lqr_planner import LQRPlanner from RRTStar.rrt_sta...
242
7,130
PythonRobotics
PathPlanning/BSplinePath/bspline_path.py
.py
""" Path Planner with B-Spline author: Atsushi Sakai (@Atsushi_twi) """ import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.parent)) import numpy as np import matplotlib.pyplot as plt import scipy.interpolate as interpolate from utils.plot import plot_curvature def approximate_b_sp...
153
4,404
PythonRobotics
PathPlanning/DStar/dstar.py
.py
""" D* grid planning author: Nirnay Roy See Wikipedia article (https://en.wikipedia.org/wiki/D*) """ import math from sys import maxsize import matplotlib.pyplot as plt show_animation = True class State: def __init__(self, x, y): self.x = x self.y = y self.parent = None se...
254
6,432
PythonRobotics
PathPlanning/FrenetOptimalTrajectory/frenet_optimal_trajectory.py
.py
""" Frenet optimal trajectory generator author: Atsushi Sakai (@Atsushi_twi) Reference: - [Optimal Trajectory Generation for Dynamic Street Scenarios in a Frenet Frame] (https://www.researchgate.net/profile/Moritz_Werling/publication/224156269_Optimal_Trajectory_Generation_for_Dynamic_Street_Scenarios_in_a_Frenet_F...
569
18,228
PythonRobotics
PathPlanning/FrenetOptimalTrajectory/cartesian_frenet_converter.py
.py
""" A converter between Cartesian and Frenet coordinate systems author: Wang Zheng (@Aglargil) Reference: - [Optimal Trajectory Generation for Dynamic Street Scenarios in a Frenet Frame] (https://www.researchgate.net/profile/Moritz_Werling/publication/224156269_Optimal_Trajectory_Generation_for_Dynamic_Street_Scena...
145
4,834
PythonRobotics
PathPlanning/ElasticBands/elastic_bands.py
.py
""" Elastic Bands author: Wang Zheng (@Aglargil) Reference: - [Elastic Bands: Connecting Path Planning and Control] (http://www8.cs.umu.se/research/ifor/dl/Control/elastic%20bands.pdf) """ import numpy as np import sys import pathlib import matplotlib.pyplot as plt from matplotlib.patches import Circle sys.path.ap...
301
10,545
PythonRobotics
PathPlanning/LQRPlanner/lqr_planner.py
.py
""" LQR local path planning author: Atsushi Sakai (@Atsushi_twi) """ import math import random import matplotlib.pyplot as plt import numpy as np import scipy.linalg as la SHOW_ANIMATION = True class LQRPlanner: def __init__(self): self.MAX_TIME = 100.0 # Maximum simulation time self.DT = ...
147
3,455
PythonRobotics
PathPlanning/HybridAStar/__init__.py
.py
import os import sys sys.path.append(os.path.dirname(os.path.abspath(__file__)))
5
82
PythonRobotics
PathPlanning/HybridAStar/dynamic_programming_heuristic.py
.py
""" A* grid based planning author: Nikos Kanargias (nkana@tee.gr) See Wikipedia article (https://en.wikipedia.org/wiki/A*_search_algorithm) """ import heapq import math import matplotlib.pyplot as plt show_animation = False class Node: def __init__(self, x, y, cost, parent_index): self.x = x ...
177
5,030
PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
.py
""" Hybrid A* path planning author: Zheng Zh (@Zhengzh) """ import heapq import math import matplotlib.pyplot as plt import numpy as np from scipy.spatial import cKDTree import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent)) from dynamic_programming_heuristic import calc_distance_heur...
442
12,978
PythonRobotics
PathPlanning/HybridAStar/car.py
.py
""" Car model for Hybrid A* path planning author: Zheng Zh (@Zhengzh) """ import sys import pathlib root_dir = pathlib.Path(__file__).parent.parent.parent sys.path.append(str(root_dir)) from math import cos, sin, tan, pi import matplotlib.pyplot as plt import numpy as np from utils.angle import rot_mat_2d WB = ...
114
2,957
PythonRobotics
PathPlanning/ParticleSwarmOptimization/particle_swarm_optimization.py
.py
""" Particle Swarm Optimization (PSO) Path Planning author: Anish (@anishk85) See Wikipedia article (https://en.wikipedia.org/wiki/Particle_swarm_optimization) References: - Kennedy, J.; Eberhart, R. (1995). "Particle Swarm Optimization" - Shi, Y.; Eberhart, R. (1998). "A Modified Particle Swarm Optimizer" ...
335
13,333
PythonRobotics
PathPlanning/DepthFirstSearch/depth_first_search.py
.py
""" Depth-First grid planning author: Erwin Lejeune (@spida_rwin) See Wikipedia article (https://en.wikipedia.org/wiki/Depth-first_search) """ import math import matplotlib.pyplot as plt show_animation = True class DepthFirstSearchPlanner: def __init__(self, ox, oy, reso, rr): """ Initiali...
256
7,601
PythonRobotics
PathPlanning/RRT/rrt.py
.py
""" Path planning Sample Code with Randomized Rapidly-Exploring Random Trees (RRT) author: AtsushiSakai(@Atsushi_twi) """ import math import random import matplotlib.pyplot as plt import numpy as np show_animation = True class RRT: """ Class for RRT planning """ class Node: """ ...
292
9,047
PythonRobotics
PathPlanning/RRT/rrt_with_sobol_sampler.py
.py
""" Path planning Sample Code with Randomized Rapidly-Exploring Random Trees with sobol low discrepancy sampler(RRTSobol). Sobol wiki https://en.wikipedia.org/wiki/Sobol_sequence The goal of low discrepancy samplers is to generate a sequence of points that optimizes a criterion called dispersion. Intuitively, the id...
279
8,762
PythonRobotics
PathPlanning/RRT/rrt_with_pathsmoothing.py
.py
""" Path planning Sample Code with RRT with path smoothing @author: AtsushiSakai(@Atsushi_twi) """ import math import random import matplotlib.pyplot as plt import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent)) from rrt import RRT show_animation = True def get_path_length(path): le =...
211
6,296
PythonRobotics
PathPlanning/RRT/sobol/sobol.py
.py
""" Licensing: This code is distributed under the MIT license. Authors: Original FORTRAN77 version of i4_sobol by Bennett Fox. MATLAB version by John Burkardt. PYTHON version by Corrado Chisari Original Python version of is_prime by Corrado Chisari Original MATLAB versions of other functi...
912
21,899
PythonRobotics
PathPlanning/RRTDubins/rrt_dubins.py
.py
""" Path planning Sample Code with RRT with Dubins path author: AtsushiSakai(@Atsushi_twi) """ import copy import math import random import numpy as np import matplotlib.pyplot as plt import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.parent)) # root dir sys.path.append(str(pathlib.Pa...
239
7,263
PythonRobotics
PathPlanning/Catmull_RomSplinePath/blending_functions.py
.py
import numpy as np import matplotlib.pyplot as plt def blending_function_1(t): return -t + 2*t**2 - t**3 def blending_function_2(t): return 2 - 5*t**2 + 3*t**3 def blending_function_3(t): return t + 4*t**2 - 3*t**3 def blending_function_4(t): return -t**2 + t**3 def plot_blending_functions(): t...
34
860
PythonRobotics
PathPlanning/Catmull_RomSplinePath/catmull_rom_spline_path.py
.py
""" Path Planner with Catmull-Rom Spline Author: Surabhi Gupta (@this_is_surabhi) Source: http://graphics.cs.cmu.edu/nsp/course/15-462/Fall04/assts/catmullRom.pdf """ import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.parent)) import numpy as np import matplotlib.pyplot as plt def cat...
86
2,292
PythonRobotics
PathPlanning/ThetaStar/theta_star.py
.py
""" Theta* grid planning author: Musab Kasbati (@Musab1Blaser) See Wikipedia article (https://cdn.aaai.org/AAAI/2007/AAAI07-187.pdf) """ import math import matplotlib.pyplot as plt show_animation = True use_theta_star = True class ThetaStarPlanner: def __init__(self, ox, oy, resolution, rr): """ ...
346
10,881
PythonRobotics
PathPlanning/PotentialFieldPlanning/potential_field_planning.py
.py
""" Potential Field based path planner author: Atsushi Sakai (@Atsushi_twi) Reference: https://www.cs.cmu.edu/~motionplanning/lecture/Chap4-Potential-Field_howie.pdf """ from collections import deque import numpy as np import matplotlib.pyplot as plt # Parameters KP = 5.0 # attractive potential gain ETA = 100.0 ...
200
5,132
PythonRobotics
PathPlanning/Eta3SplineTrajectory/eta3_spline_trajectory.py
.py
""" eta^3 polynomials trajectory planner author: Joe Dinius, Ph.D (https://jwdinius.github.io) Atsushi Sakai (@Atsushi_twi) Refs: - https://jwdinius.github.io/blog/2018/eta3traj/ - [eta^3-Splines for the Smooth Path Generation of Wheeled Mobile Robots] (https://ieeexplore.ieee.org/document/4339545/) """ im...
457
18,685
PythonRobotics
PathPlanning/StateLatticePlanner/state_lattice_planner.py
.py
""" State lattice planner with model predictive trajectory generator author: Atsushi Sakai (@Atsushi_twi) - plookuptable.csv is generated with this script: https://github.com/AtsushiSakai/PythonRobotics/blob/master/PathPlanning /ModelPredictiveTrajectoryGenerator/lookup_table_generator.py Reference: - State Space ...
346
8,831
PythonRobotics
PathPlanning/DynamicWindowApproach/dynamic_window_approach.py
.py
""" Mobile robot motion planning sample with Dynamic Window Approach author: Atsushi Sakai (@Atsushi_twi), Göktuğ Karakaşlı """ import math from enum import Enum import matplotlib.pyplot as plt import numpy as np show_animation = True def dwa_control(x, config, goal, ob): """ Dynamic Window Approach con...
309
10,138
PythonRobotics
PathPlanning/ReedsSheppPath/reeds_shepp_path_planning.py
.py
""" Reeds Shepp path planner sample code author Atsushi Sakai(@Atsushi_twi) co-author Videh Patel(@videh25) : Added the missing RS paths """ import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent.parent.parent)) import math import matplotlib.pyplot as plt import numpy as np from utils.angle im...
479
14,855
PythonRobotics
PathPlanning/DStarLite/d_star_lite.py
.py
""" D* Lite grid planning author: vss2sn (28676655+vss2sn@users.noreply.github.com) Link to papers: D* Lite (Link: http://idm-lab.org/bib/abstracts/papers/aaai02b.pdf) Improved Fast Replanning for Robot Navigation in Unknown Terrain (Link: http://www.cs.cmu.edu/~maxim/files/dlite_icra02.pdf) Implemented maintaining sim...
406
16,563
PythonRobotics
PathPlanning/QuinticPolynomialsPlanner/quintic_polynomials_planner.py
.py
""" Quintic Polynomials Planner author: Atsushi Sakai (@Atsushi_twi) Reference: - [Local Path planning And Motion Control For Agv In Positioning](https://ieeexplore.ieee.org/document/637936/) """ import math import matplotlib.pyplot as plt import numpy as np # parameter MAX_T = 100.0 # maximum time to the goal...
231
6,687
PythonRobotics
AerialNavigation/drone_3d_trajectory_following/drone_3d_trajectory_following.py
.py
""" Simulate a quadrotor following a 3D trajectory Author: Daniel Ingram (daniel-s-ingram) """ from math import cos, sin import numpy as np from Quadrotor import Quadrotor from TrajectoryGenerator import TrajectoryGenerator show_animation = True # Simulation parameters g = 9.81 m = 0.2 Ixx = 1 Iyy = 1 Izz = 1 T = 5...
214
5,588
PythonRobotics
AerialNavigation/drone_3d_trajectory_following/Quadrotor.py
.py
""" Class for plotting a quadrotor Author: Daniel Ingram (daniel-s-ingram) """ from math import cos, sin import numpy as np import matplotlib.pyplot as plt class Quadrotor(): def __init__(self, x=0, y=0, z=0, roll=0, pitch=0, yaw=0, size=0.25, show_animation=True): self.p1 = np.array([size / 2, 0, 0, 1])...
88
2,766
PythonRobotics
AerialNavigation/drone_3d_trajectory_following/__init__.py
.py
import sys import pathlib sys.path.append(str(pathlib.Path(__file__).parent))
4
78
PythonRobotics
AerialNavigation/drone_3d_trajectory_following/TrajectoryGenerator.py
.py
""" Generates a quintic polynomial trajectory. Author: Daniel Ingram (daniel-s-ingram) """ import numpy as np class TrajectoryGenerator(): def __init__(self, start_pos, des_pos, T, start_vel=[0,0,0], des_vel=[0,0,0], start_acc=[0,0,0], des_acc=[0,0,0]): self.start_x = start_pos[0] self.start_y = ...
76
2,103
PythonRobotics
AerialNavigation/rocket_powered_landing/rocket_powered_landing.py
.py
""" A rocket powered landing with successive convexification author: Sven Niederberger Atsushi Sakai Reference: - Python implementation of 'Successive Convexification for 6-DoF Mars Rocket Powered Landing with Free-Final-Time' paper by Michael Szmuk and Behcet Acıkmese. - EmbersArc/SuccessiveConvexification...
675
24,849
PythonRobotics
docs/conf.py
.py
# # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # https://www.sphinx-doc.org/en/master/config # -- Path setup -------------------------------------------------------------- # If extensions (or...
231
6,862
PythonRobotics
tests/test_extended_kalman_filter.py
.py
import conftest from Localization.extended_kalman_filter import extended_kalman_filter as m def test_1(): m.show_animation = False m.main() if __name__ == '__main__': conftest.run_this_test(__file__)
12
216
PythonRobotics
tests/test_rrt_star_seven_joint_arm.py
.py
import conftest # Add root path to sys.path from ArmNavigation.rrt_star_seven_joint_arm_control \ import rrt_star_seven_joint_arm_control as m def test1(): m.show_animation = False m.main() if __name__ == '__main__': conftest.run_this_test(__file__)
13
271
PythonRobotics
tests/test_a_star_variants.py
.py
import PathPlanning.AStar.a_star_variants as a_star import conftest def test_1(): # A* with beam search a_star.show_animation = False a_star.use_beam_search = True a_star.main() reset_all() # A* with iterative deepening a_star.use_iterative_deepening = True a_star.main() reset_al...
45
911
PythonRobotics
tests/test_bspline_path.py
.py
import conftest import numpy as np import pytest from PathPlanning.BSplinePath import bspline_path def test_list_input(): way_point_x = [-1.0, 3.0, 4.0, 2.0, 1.0] way_point_y = [0.0, -3.0, 1.0, 1.0, 3.0] n_course_point = 50 # sampling number rax, ray, heading, curvature = bspline_path.approximate_b_...
75
2,600
PythonRobotics
tests/test_bezier_path.py
.py
import conftest from PathPlanning.BezierPath import bezier_path as m def test_1(): m.show_animation = False m.main() def test_2(): m.show_animation = False m.main2() if __name__ == '__main__': conftest.run_this_test(__file__)
17
252
PythonRobotics
tests/test_lqr_rrt_star.py
.py
import conftest # Add root path to sys.path from PathPlanning.LQRRRTStar import lqr_rrt_star as m import random random.seed(12345) def test1(): m.show_animation = False m.main(maxIter=5) if __name__ == '__main__': conftest.run_this_test(__file__)
15
265
PythonRobotics
tests/test_probabilistic_road_map.py
.py
import conftest # Add root path to sys.path import numpy as np from PathPlanning.ProbabilisticRoadMap import probabilistic_road_map def test1(): probabilistic_road_map.show_animation = False probabilistic_road_map.main(rng=np.random.default_rng(1233)) if __name__ == '__main__': conftest.run_this_test(_...
13
329
PythonRobotics
tests/test_dynamic_movement_primitives.py
.py
import conftest import numpy as np from PathPlanning.DynamicMovementPrimitives import \ dynamic_movement_primitives def test_1(): # test that trajectory can be learned from user-passed data T = 5 t = np.arange(0, T, 0.01) sin_t = np.sin(t) train_data = np.array([t, sin_t]).T DMP_c...
50
1,489
PythonRobotics
tests/test_eta3_spline_path.py
.py
import conftest from PathPlanning.Eta3SplinePath import eta3_spline_path as m def test_1(): m.show_animation = False m.main() if __name__ == '__main__': conftest.run_this_test(__file__)
12
202
PythonRobotics
tests/test_graph_based_slam.py
.py
import conftest from SLAM.GraphBasedSLAM import graph_based_slam as m def test_1(): m.show_animation = False m.SIM_TIME = 20.0 m.main() if __name__ == '__main__': conftest.run_this_test(__file__)
13
216