MCPcopy
hub / github.com/AtsushiSakai/PythonRobotics

github.com/AtsushiSakai/PythonRobotics @v1.0 sqlite

repository ↗ · DeepWiki ↗ · release v1.0 ↗
945 symbols 2,437 edges 130 files 162 documented · 17%
README

PythonRobotics

Build Status Documentation Status Build status Coverage Status Language grade: Python CodeFactor tokei Say Thanks!

Python codes for robotics algorithm.

Table of Contents

What is this?

This is a Python code collection of robotics algorithms, especially for autonomous navigation.

Features:

  1. Easy to read for understanding each algorithm's basic idea.

  2. Widely used and practical algorithms are selected.

  3. Minimum dependency.

See this paper for more details:

Requirements

  • Python 3.6.x (2.7 is not supported)

  • numpy

  • scipy

  • matplotlib

  • pandas

  • cvxpy

Documentation

This README only shows some examples of this project.

If you are interested in other examples or mathematical backgrounds of each algorithm,

You can check the full documentation online: https://pythonrobotics.readthedocs.io/

All animation gifs are stored here: AtsushiSakai/PythonRoboticsGifs: Animation gifs of PythonRobotics

How to use

  1. Clone this repo.

git clone https://github.com/AtsushiSakai/PythonRobotics.git

cd PythonRobotics/

  1. Install the required libraries. You can use environment.yml with conda command.

conda env create -f environment.yml

  1. Execute python script in each directory.

  2. Add star to this repo if you like it :smiley:.

Localization

Extended Kalman Filter localization

Documentation: Notebook

Particle filter localization

2

This is a sensor fusion localization with Particle Filter(PF).

The blue line is true trajectory, the black line is dead reckoning trajectory,

and the red line is estimated trajectory with PF.

It is assumed that the robot can measure a distance from landmarks (RFID).

This measurements are used for PF localization.

Ref:

Histogram filter localization

3

This is a 2D localization example with Histogram filter.

The red cross is true position, black points are RFID positions.

The blue grid shows a position probability of histogram filter.

In this simulation, x,y are unknown, yaw is known.

The filter integrates speed input and range observations from RFID for localization.

Initial position is not needed.

Ref:

Mapping

Gaussian grid map

This is a 2D Gaussian grid mapping example.

2

Ray casting grid map

This is a 2D ray casting grid mapping example.

2

k-means object clustering

This is a 2D object clustering with k-means algorithm.

2

Rectangle fitting

This is a 2D rectangle fitting for vehicle detection.

2

SLAM

Simultaneous Localization and Mapping(SLAM) examples

Iterative Closest Point (ICP) Matching

This is a 2D ICP matching example with singular value decomposition.

It can calculate a rotation matrix and a translation vector between points to points.

3

Ref:

FastSLAM 1.0

This is a feature based SLAM example using FastSLAM 1.0.

The blue line is ground truth, the black line is dead reckoning, the red line is the estimated trajectory with FastSLAM.

The red points are particles of FastSLAM.

Black points are landmarks, blue crosses are estimated landmark positions by FastSLAM.

3

Ref:

Graph based SLAM

This is a graph based SLAM example.

The blue line is ground truth.

The black line is dead reckoning.

The red line is the estimated trajectory with Graph based SLAM.

The black stars are landmarks for graph edge generation.

3

Ref:

Path Planning

Dynamic Window Approach

This is a 2D navigation sample code with Dynamic Window Approach.

2

Grid based search

Dijkstra algorithm

This is a 2D grid based shortest path planning with Dijkstra's algorithm.

PythonRobotics/figure_1.png at master · AtsushiSakai/PythonRobotics

In the animation, cyan points are searched nodes.

A* algorithm

This is a 2D grid based shortest path planning with A star algorithm.

PythonRobotics/figure_1.png at master · AtsushiSakai/PythonRobotics

In the animation, cyan points are searched nodes.

Its heuristic is 2D Euclid distance.

Potential Field algorithm

This is a 2D grid based path planning with Potential Field algorithm.

PotentialField

In the animation, the blue heat map shows potential value on each grid.

Ref:

State Lattice Planning

This script is a path planning code with state lattice planning.

This code uses the model predictive trajectory generator to solve boundary problem.

Ref:

Biased polar sampling

PythonRobotics/figure_1.png at master · AtsushiSakai/PythonRobotics

Lane sampling

PythonRobotics/figure_1.png at master · AtsushiSakai/PythonRobotics

Probabilistic Road-Map (PRM) planning

PRM

This PRM planner uses Dijkstra method for graph search.

In the animation, blue points are sampled points,

Cyan crosses means searched points with Dijkstra method,

The red line is the final path of PRM.

Ref:

Rapidly-Exploring Random Trees (RRT)

RRT*

PythonRobotics/figure_1.png at master · AtsushiSakai/PythonRobotics

This is a path planning code with RRT*

Black circles are obstacles, green line is a searched tree, red crosses are start and goal positions.

Ref:

RRT* with reeds-sheep path

Robotics/animation.gif at master · AtsushiSakai/PythonRobotics)

Path planning for a car robot with RRT* and reeds sheep path planner.

LQR-RRT*

This is a path planning simulation with LQR-RRT*.

A double integrator motion model is used for LQR local planner.

LQRRRT

Ref:

Core symbols most depended-on inside this repo

plot
called by 313
Mapping/rectangle_fitting/simulator.py
mod2pi
called by 22
PathPlanning/RRTStarDubins/dubins_path_planning.py
mod2pi
called by 22
PathPlanning/DubinsPath/dubins_path_planning.py
set_path
called by 18
PathPlanning/ReedsSheppPath/reeds_shepp_path_planning.py
computeDistanceCost
called by 14
PathPlanning/BatchInformedRRTStar/batch_informed_rrtstar.py
computeHeuristicCost
called by 12
PathPlanning/BatchInformedRRTStar/batch_informed_rrtstar.py
realWorldToNodeId
called by 10
PathPlanning/BatchInformedRRTStar/batch_informed_rrtstar.py
pi_2_pi
called by 10
SLAM/FastSLAM2/fast_slam2.py

Shape

Function 451
Method 370
Class 124

Languages

Python100%

Modules by API surface

PathPlanning/BatchInformedRRTStar/batch_informed_rrtstar.py35 symbols
AerialNavigation/rocket_powered_landing/rocket_powered_landing.py24 symbols
PathTracking/model_predictive_speed_and_steer_control/model_predictive_speed_and_steer_control.py23 symbols
PathPlanning/HybridAStar/hybrid_a_star.py23 symbols
PathPlanning/InformedRRTStar/informed_rrt_star.py22 symbols
PathPlanning/ClosedLoopRRTStar/closed_loop_rrt_star_car.py22 symbols
PathPlanning/ReedsSheppPath/reeds_shepp_path_planning.py21 symbols
PathPlanning/FrenetOptimalTrajectory/frenet_optimal_trajectory.py21 symbols
SLAM/FastSLAM2/fast_slam2.py19 symbols
PathPlanning/LQRRRTStar/lqr_rrt_star.py19 symbols
SLAM/FastSLAM1/fast_slam1.py18 symbols
PathTracking/cgmres_nmpc/cgmres_nmpc.py18 symbols

For agents

$ claude mcp add PythonRobotics \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact