# Particle Filter, Hacker News

### [–particle_show_frequencyPARTICLE_SHOW_FREQUENCY] Introduction

Particle filter is a Monte Carlo algorithm used to solve statistical inference problems. In this project, the turtle location and heading direction in maze was infered using particle filter. The green turtle is the actual location while the orange turtule is the estimated location. The arrows are particles. Blue arrows stand for low probability particles while red arrows stand for high probability particles. There are four sensors installed on the front, back, left and right of the turtle. The sensors measure its perpendicular distances to the closest walls in four directions, possibly bounded by some sensor limit.

Files

### Dependencies

Python 3.6

•
• Numpy 1. [–particle_show_frequencyPARTICLE_SHOW_FREQUENCY]
• ************************** Usages

### **************************** (\$) ******************************** (python main.py– help usage: main.py[-h][–window_widthWINDOW_WIDTH]                [–wall_probWALL_PROB] [–num_particlesNUM_PARTICLES]                [–num_rowsNUM_ROWS]                [–grid_heightGRID_HEIGHT] [–grid_widthGRID_WIDTH]                [–num_rowsNUM_ROWS] [–num_rowsNUM_ROWS] ************************** [–wall_probWALL_PROB]                [–wall_probWALL_PROB] **************************** [–wall_probWALL_PROB]                [–robot_speedROBOT_SPEED] [–robot_speedROBOT_SPEED]                [–robot_speedROBOT_SPEED] Particle filterin maze. optional arguments:   – h, – helpshow this (help) ********************************** message and exit  – window_width [ –robot_speedROBOT_SPEED] ******************** WINDOW_WIDTH                         Window width.   – window_height WINDOW_HEIGHT                         Window height.   – num_particles [ –robot_speedROBOT_SPEED] ******************** NUM_PARTICLES                         Number of particles usedinparticle filter.   – sensor_limit_ratio SENSOR_LIMIT_RATIO                         Distance limit of sensors (**********************, [–wall_probWALL_PROB] real value: 0 – 1)`****************************** 0:                         Useless sensor; 1: Perfect sensor.   - grid_height [--robot_speedROBOT_SPEED] ****************** GRID_HEIGHT                         Heightforeach grid of maze.   - grid_width [--robot_speedROBOT_SPEED] ****************** GRID_WIDTH                         Widthforeach grid of maze.   - num_rows [--robot_speedROBOT_SPEED] ******************** NUM_ROWS Number of rows```` inmaze   - num_cols [--robot_speedROBOT_SPEED] ******************** NUM_COLS Number of columns inmaze   - wall_prob [--robot_speedROBOT_SPEED] ******************** WALL_PROB                         Wall probability of a random maze.   - random_seedRANDOM_SEED                         Random seedfor random maze and particle filter.   - robot_speed [--robot_speedROBOT_SPEED] ******************** ROBOT_SPEED                         Robot movement speed ```

``` ```
• ```inmaze.   - kernel_sigma KERNEL_SIGMA                         Sigmaforgaussian distance kernel.   - particle_show_frequency PARTICLE_SHOW_FREQUENCY                         Frequency of showing particles on maze. To run particle filter using default parameters, simply run the following command in terminal: Demo [--robot_speedROBOT_SPEED] **************************** (\$) python main.py- num_particles [ --grid_widthGRID_WIDTH] ************************** [--wall_probWALL_PROB] ******************** - kernel_sigma - random_seed200 [ --wall_probWALL_PROB] ************************************ (Particle Filter[--wall_probWALL_PROB] **************** References```
• ``` ```

### Some of the code in this project were revised from the Beacon Based Particle Filter project. But the robot environment is totally different and the sensor measure mechanism is also totally different. The robot in this project could be more clumsy compared to the robot used in the Beacon Based Particle Filter project, but the particle filter still inferred the correct location and heading direction. Notes (******************

I found that if the number of particles is not sufficiently large, particularly for some complicated environment, such as the maze which looks quite similar in many local regions, and when the sensor is not perfect, sometimes it will take much longer time, after many rounds of particle reinitializations, to get the right location of the turtle. So the number of particles is definitely the most important parameters for particle filter. However, it slows down the computations.

If the number of particles is not sufficiently large, sometimes adjusting the standard deivation of Gaussian kernel might make it converges faster.

Although theoretically it is true, it is amazing to see that the particle filter could infer the heading direction of turtle correctly even if the sensor measurements do not contain direction information directly.

Miscellaneous

### (Particle Filter Online) ****************************************: An interesting online particle filter that uses similar designs to mine.

GitHub

(Particle Filter)

## What do you think?

GIPHY App Key not set. Please check settings