Coder Social home page Coder Social logo

pso-car's Introduction

Car Control Simulator Based on Particle Swarm Optimization

Requirements Status

A sandbox practice for the particle swarm optimization.

preview

Objective

Use PSO to find the best the RBFN parameters, which input is the distances detected from car radar and output is the angle of wheel.

Objective Function

Minimize the err:

err = (1 / N) * sum(abs(d.expected_output - RBFN(d.input)) for d in training_dataset)

N is the total number of training data.

On the other word, we want to maximize the fitness value (1 / err ).

PSO Position and Velocity Update Formula

The position and velocity for each individual in population of PSO is updated by following formula.

  • Velocity
self.velocity = inertia_weight * self.velocity + \
    cognitive_const * (self.best_position - self.position) + \
    social_const * (global_best_position - self.position)

# limit the velocity
np.clip(self.velocity, -self.v_max, self.v_max, out=self.velocity)

self.position += self.velocity

# limit the position to fit the range of RBFN parameters
rbfn_params_limiter(self.position)

Installation

  • Download this project
git clone https://gitlab.com/seanwu1105/pso-car.git
  • Change directory to the root of the project
cd pso-car/
  • Run with Python interpreter
python3 main.py

Training Data Format

Input (Distances) Output (Wheel Angle)
22.0000000 8.4852814 8.4852814 -16.0709664
# Front_Distance Right_Distance Left_Distance Wheel_Angle

22.0000000 8.4852814 8.4852814 -16.0709664
21.1292288 9.3920089 7.7989045 -14.7971418
20.3973643 24.4555821 7.2000902 16.2304876
19.1995799 25.0357595 7.5129743 16.0825385
18.1744869 42.5622911 8.0705896 15.5075777

Add Customized Map Cases

The data location

The data location is /data. The application will load every files with *.txt extension automatically after the execution.

Example Format

0,0,90  // the starting position and angle of car (x, y, degree)
18,40   // the top-left coordinate of the ending area
30,37   // the bottom-right coordinate of the ending area
-6,-3   // the first point for the wall in map
-6,22
18,22
18,50
30,50
30,10
6,10
6,-6
-6,-3   // the last point for the wall in map

Every coordinates between the fourth and last line are the corner point of the walls in map.

Dependencies

pip3 install numpy
pip3 install matplotlib
pip3 install pyqt5
pip3 install pyside2

pso-car's People

Contributors

seanwu1105 avatar

Stargazers

 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.