Visitar URL original
GitHub - Brian44ki/PythonRobotics: Python sample codes and textbook for robotics algorithms. · GitHub
Skip to content

About

Python sample codes and textbook for robotics algorithms.

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

 
 

Latest commit

 

History

2,244 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

robot-path-planner

A Python collection of robotics algorithms for localization, mapping, SLAM, path planning, path tracking, arm navigation, aerial navigation and bipedal motion. Every algorithm is a small, readable script with an animated simulation, so you can run it, watch it work, and learn how it behaves.

Maintained by Brian Kipruto Chepchieng (@Brian44ki).

This project is built on the open-source PythonRobotics project by Atsushi Sakai and contributors, released under the MIT License. See Acknowledgements and License.


Table of Contents


About

robot-path-planner is a hands-on reference for how robots find out where they are, build maps, plan routes and follow them.

Goals:

  1. Easy to read. Each algorithm's core idea is visible in the code.
  2. Practical. Widely used, well-established algorithms.
  3. Minimal dependencies. NumPy, SciPy, Matplotlib and cvxpy.

For the mathematics behind many of the algorithms, see the original textbook: PythonRobotics documentation.


Requirements

To run the sample code:

For development:


Getting Started

  1. Clone this repository:

    git clone https://github.com/Brian44ki/robot-path-planner.git
    cd robot-path-planner
  2. Install the required libraries.

    Using conda:

    conda env create -f requirements/environment.yml

    Using pip:

    pip install -r requirements/requirements.txt
  3. Run the Python script inside any algorithm's folder, for example:

    python PathPlanning/AStar/a_star.py
  4. If you find this useful, a ⭐ on the repo is appreciated.


Localization

Extended Kalman Filter localization

EKF localization

Reference: documentation

GPS/IMU Fusion Localization with Bias Estimation

GPS/IMU Fusion Localization with Bias Estimation

An extended Kalman filter fuses body-frame accelerometer and gyroscope readings with lower-rate GPS positions, estimates sensor biases, and keeps predicting from inertial data during a temporary GPS outage. The animation compares it with an EKF without bias estimation and with IMU-only dead reckoning on the same measurements. It also plots the accelerometer and gyroscope bias estimates against their true values, with covariance-derived 3σ position ellipses and bias uncertainty bands.

Particle filter localization

Particle filter localization

Sensor-fusion localization with a particle filter (PF). The blue line is the true trajectory, the black line is dead reckoning, and the red line is the PF estimate. The robot measures its distance to landmarks (RFID tags), and those measurements drive the filter.

Reference: Probabilistic Robotics

Histogram filter localization

Histogram filter localization

2D localization with a histogram filter. The red cross is the true position, the black points are RFID positions, and the blue grid shows the position probability. In this simulation x and y are unknown while yaw is known. The filter integrates speed input and RFID range observations, and no initial position is needed.

Reference: Probabilistic Robotics


Mapping

Gaussian grid map

2D Gaussian grid mapping.

Gaussian grid map

Ray casting grid map

2D ray casting grid mapping.

Ray casting grid map

Lidar to grid map

Converting 2D range measurements into a grid map.

Lidar to grid map

k-means object clustering

2D object clustering with the k-means algorithm.

k-means clustering

Rectangle fitting

2D rectangle fitting for vehicle detection.

Rectangle fitting


SLAM

Simultaneous Localization and Mapping examples.

Iterative Closest Point (ICP) Matching

2D ICP matching using singular value decomposition. It computes the rotation matrix and translation vector between two point sets.

ICP matching

Reference: Introduction to Mobile Robotics: Iterative Closest Point Algorithm

FastSLAM 1.0

Feature-based SLAM using FastSLAM 1.0. The blue line is ground truth, the black line is dead reckoning, and the red line is the FastSLAM trajectory estimate. Red points are particles, black points are landmarks, and blue crosses are estimated landmark positions.

FastSLAM 1.0

References:


Path Planning

Dynamic Window Approach

2D navigation with the Dynamic Window Approach.

Dynamic Window Approach

Reference: The Dynamic Window Approach to Collision Avoidance

Grid-based search

Dijkstra algorithm

2D grid-based shortest path planning with Dijkstra's algorithm. In the animation, cyan points are searched nodes.

Dijkstra

A* algorithm

2D grid-based shortest path planning with A*. Cyan points are searched nodes, and the heuristic is the 2D Euclidean distance.

A*

D* algorithm

2D grid-based path planning with D*. The animation shows a robot finding its path while avoiding an obstacle.

D*

Reference: D* algorithm (Wikipedia)

D* Lite algorithm

Finds the shortest path between two points and reroutes when new obstacles are discovered, implemented for a 2D grid.

D* Lite

References:

Potential Field algorithm

2D grid-based path planning with potential fields. The blue heat map shows the potential value of each grid cell.

Potential Field

Reference: Robotic Motion Planning: Potential Functions

Grid-based coverage path planning

2D grid-based coverage path planning simulation.

Coverage path planning

Particle Swarm Optimization (PSO)

2D path planning with Particle Swarm Optimization, a metaheuristic inspired by bird flocking. Particles explore the search space to find collision-free paths. In the animation, particles (blue dots) converge on the optimal path (yellow line) from the start (green area) to the goal (red star).

PSO

References:

State Lattice Planning

Path planning with state lattices, using a model predictive trajectory generator to solve the boundary problem.

References:

Biased polar sampling

Biased polar sampling

Lane sampling

Lane sampling

Probabilistic Road-Map (PRM) planning

PRM

This PRM planner uses Dijkstra's method for graph search. Blue points are sampled points, cyan crosses are points searched by Dijkstra, and the red line is the final path.

Reference: Probabilistic roadmap (Wikipedia)

Rapidly-Exploring Random Trees (RRT)

RRT*

RRT*

Path planning with RRT*. Black circles are obstacles, the green line is the search tree, and red crosses are the start and goal.

References:

RRT* with Reeds-Shepp path

RRT* with Reeds-Shepp

Path planning for a car-like robot with RRT* and the Reeds-Shepp path planner.

LQR-RRT*

Path planning with LQR-RRT*, using a double integrator motion model for the LQR local planner.

LQR-RRT*

References:

Quintic polynomials planning

Motion planning with quintic polynomials. It computes a 2D path along with velocity and acceleration profiles.

Quintic polynomials

Reference: Local Path Planning And Motion Control For AGV In Positioning

Reeds-Shepp planning

Reeds-Shepp planning

References:

LQR-based path planning

LQR-based path planning for a double integrator model.

LQR planner

Optimal Trajectory in a Frenet Frame

Frenet optimal trajectory

Optimal trajectory generation in a Frenet frame. The cyan line is the target course, black crosses are obstacles, and the red line is the predicted path.

References:


Path Tracking

Move to a pose control

Move to pose

Reference: P. I. Corke, Robotics, Vision and Control, p. 102

Stanley control

Path tracking with Stanley steering control and PID speed control.

Stanley controller

References:

Rear wheel feedback control

Path tracking with rear wheel feedback steering control and PID speed control.

Rear wheel feedback

Reference: A Survey of Motion Planning and Control Techniques for Self-driving Urban Vehicles

Linear-quadratic regulator (LQR) speed and steering control

Path tracking with LQR speed and steering control.

LQR speed and steering

Reference: Towards fully autonomous driving: Systems and algorithms

Model predictive speed and steering control

Path tracking with iterative linear model predictive speed and steering control.

MPC

References:

Nonlinear Model Predictive Control with C-GMRES

Motion planning and path tracking with nonlinear MPC using C-GMRES.

C-GMRES NMPC

Reference: documentation


Arm Navigation

N-joint arm to point control

Interactive N-joint arm control. Left-click on the plot to set the goal position of the end effector. Here N = 10, but you can change it.

N-joint arm

Arm navigation with obstacle avoidance

Arm obstacle navigation


Aerial Navigation

Drone 3D trajectory following

3D trajectory following for a quadrotor.

Drone trajectory following

Rocket powered landing

3D trajectory generation for a rocket powered landing.

Rocket powered landing

Reference: documentation


Bipedal

Bipedal planner with inverted pendulum

A bipedal planner that modifies footsteps for an inverted pendulum. Set the footsteps and the planner adjusts them automatically.

Bipedal planner


Contributing

Issues and pull requests are welcome. If you spot a bug, have an improvement, or want to add an algorithm:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-change)
  3. Commit your changes and open a pull request

Acknowledgements and License

This project is built on PythonRobotics by Atsushi Sakai and its contributors. Their work provides the algorithm implementations and animations used here, and the animation GIFs are hosted in PythonRoboticsGifs.

If you use this code in academic work, please cite the original paper:

Atsushi Sakai et al., PythonRobotics: a Python code collection of robotics algorithms, arXiv:1808.10703

License: MIT. The original copyright notice and license text are retained in the LICENSE file, as the license requires.


Author

Brian Kipruto Chepchieng GitHub: @Brian44ki

About

Python sample codes and textbook for robotics algorithms.

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages