Particle Filter Localization for a Simulated Mobile Robot

This entry is part 2 of 3 in the series Python Robotics Simulator

This simulation shows a robot (red) moving through a simulated environment and a Particle Filter (PF) trying to localize it in that environment. Initially, the particles (shown in different shades of grey indicating their probabilities) do not know the location of the robot and try and localize the robot from scratch. This is called global localization. After the robot moves about in its environment, the particles coalesce on the robot’s correct position. Thereafter, it is easier for the PF to track the position of the robot and this is called position tracking. Note that the environment is quite symmetric and this is why the PF has difficulty in finding the robot in the beginning, but gets there in the end.

Particle Filter Localization for a Simulated Mobile Robot


The measurements are simulated laser range finder readings (see previous post: Simulated Laser Range Finder Readings Using Python & OpenCV).
The code is written in Python using the OpenCV library (wrapper for python). It is adapted from PF code written by Juan Carlos Kuri Pinto and the Udacity team over at Udacity University’s online Autonomous Driving class (http://www.udacity-forums.com/cs373/questions/14131/unit-3-graphical-demo-of-ro­bot-localization-based-on-particle-filters).

See the video of the simulation here:

I’ll put the code up as soon as I’ve tidied it up a bit.