GithubHelp home page GithubHelp logo

gabrielegilardi / pathplanning Goto Github PK

View Code? Open in Web Editor NEW
67.0 1.0 17.0 724 KB

Implementation of particle swarm optimization (PSO) for path planning when the environment is known.

License: MIT License

Python 100.00%
particle-swarm-optimization path-planning obstacle-violations penalty spline python

pathplanning's Introduction

Path Planning Using Particle Swarm Optimization

Implementation of particle swarm optimization (PSO) for path planning when the environment is known.

Features

  • The code has been written and tested in Python 3.8.5.

  • Four types of obstacles: circle, ellipse, convex polygon, generic polygon.

  • Start position, goal position, and obstacles can be dynamically changed to simulate motion.

  • Penalty function of type 1/x with the center in the obstacle centroid*.

  • To improve the execution speed, the algorithms to determine if a point is inside an obstacle have been designed to carry out the determination on all points simultaneously.

  • Points on the obstacle borders/edges are not considered inside the obstacle.

  • Option to run sequential tests with different initial conditions to increase the chances to find a global minimum.

  • Usage: python test.py example.

*Some centroid may be outside the obstacle, such as the U-shaped element in the below examples. If that is a problem the simples solution is to divide the obstacle in smaller shapes using convex polygons. For instance, for the mentioned U-shape obstacle two vertical and one horizontal polygons could be used.

Main Parameters

example Number of the example to run (1, 2, or 3.)

start Start coordinates.

goal Goal coordinates.

limits Lower and upper boundaries of the map and search space in the PSO.

nRun Number of runs.

nPts Number of internal points defining the spline. The number of variables is twice this number.

d Number of segments between the spline breakpoints.

nPop, epochs Number of agents (population) and number of iterations.

f_interp Order of the spline (1st, 2nd and 3rd order, respectively.)

Xinit Initial value of the variables. Set Xinit=None to pick them randomly. This array is organized with first the x-coordinates of all internal points and then the y-coordinates of all internal points.

K Average size of each agent's group of informants. If K=0 the entire swarm is used as agent's group of informants.

phi Coefficient to calculate the self-confidence coefficient and the confidence-in-others coefficient.

vel_fact Velocity factor to calculate the maximum and the minimum allowed velocities.

conf_type Confinement type (on the velocities): HY=hyperbolic, RB=random-back, MX=mixed hyeperbolic/random-back.

IntVar List of indexes specifying which variable should be treated as integer. If all variables are real set IntVar=None, if all variables are integer set IntVar=all.

normalize Specifies if the search space should be normalized (to improve convergency).

rad Normalized radius of the hypersphere centered on the best particle. The higher the number of other particles inside and the better is the solution.

Examples

There are three examples, all of them using the same obstacles:

Example 1

  • Multiple runs, cubic spline, optimizer initialized randomly.

  • Best: run=9, L=11.20, count=0.

  • No obstacle violations.

  • See the code for the parameters used.

example_1

Example 2

  • Multiple runs, quadratic spline, optimizer initialized with the straight line between start and goal position.

  • Best: run=4, L=11.884, count=0.

  • Obstacle violation in run 8, 9, 13, 14, and 15.

  • See the code for the parameters used.

example_2

Example 3

  • Single run, linear spline, optimizer initialized with the previous solution, start point chasing a moving goal with one obstacle (the circle) also moving.

  • Path length goes from 11.53 (run 1) to 4.52 (run 65).

  • No obstacle violations.

  • See the code for the parameters used.

example_3

References

pathplanning's People

Contributors

gabrielegilardi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.