Monte Carlo localization

Post your NXJ projects, project ideas, etc here!

Moderators: imaqine, 99jonathan, roger

leJOS Team Member
Posts: 965
Joined: Mon Feb 05, 2007 1:27 pm

Monte Carlo localization

Postby lawrie » Mon May 12, 2008 6:47 pm


I have implemented a Monte Carlo Localization program with a PC and NXJ program communicating over Bluetooth. The Monte Carlo localization method is an example of the particle filtering algorithm. It is described in Chapter 25 of the book: "Artificial Intelligence: A Modern Approach" - see

You produce a map of the room or other closed environment that you want your robot to explore and put the robot down in a random position. It then works out where it is by moving about randomly, making range measurements to the walls with the ultrasonic sensor, and comparing them with the map.

The way the algorithm works is to spread a set of particles with random "pose" (position and angle) across the interior of the mapped area. Whenever the robot takes range readings, they are used to produce a "weight" for each particle. The particles are then resampled with those with higher weights being more likely to be selected. The new sample includes many particles at the same location. The graphic display shows the particles thinned out with only those with a reasonably high probability of being in the robot's location being shown. When the robot makes a random move it is applied with random noise to each particle. This makes the partcles spread out into clusters.

As the algorithm proceeds the display shows the particles converging into little clusters showing the possible location of the robot. After a while there is a single cluster showing the robot's true position.

The robot needs to be a wheeled vehicle that support the Pilot class and has an ultrasonic sensor mounted above its center of rotation. It runs the Respond program - see ...

The code for the PC Localization program is at ...

User avatar
Advanced Member
Posts: 329
Joined: Wed Sep 13, 2006 12:16 am
Location: UK, Milton Keynes

Postby esmetaman » Thu May 15, 2008 7:48 pm

Fantastic work Lawrie!!!
Juan Antonio Breña Moral

Posts: 47
Joined: Sun Feb 11, 2007 11:30 am
Location: Rome

Postby PheniX » Mon Mar 30, 2009 6:14 am


The URL of the two files is wrong, there is a stop appended, the correct ones are: ... ...

700 Tnega Terces
New User
Posts: 21
Joined: Thu Feb 05, 2009 1:13 am

Postby 700 Tnega Terces » Tue Apr 28, 2009 1:45 am

So how exactly does one use your code?

What are the steps?:
-Inputting a map
-Setting any initial parameters
-Running the program?
"The name's Jond, Bames Jond..."

Return to “NXJ Projects”

Who is online

Users browsing this forum: No registered users and 1 guest