Friday, December 12, 2008

1D Monte-Carlo Localization

With a function to convert from color values to light sensor values in place, and code for a 1D Monte-Carlo localization(MCL) we were ready to test the converting function and the 1D-MCL.
This test was also used to decide if the converting function found in the Light Sensor Test section was accurate enough. So there have been switch back and forth between these tests.

We have printed a ramp(shown below) with a length of 25 cm on an A4 paper.

The MCL algorithm is running on the pc, while exchanging data with the car via bluetooth. But the software to send commands to the car and receive data from the car is not developed yet, thus we moved the car around by hand, and then manually wrote the measured values into the program.
In this test we only use one sensor.

The code is devided into 3 classes which is written below here. The Sample class is used to make samples with a x position and an importance. The MCL class have all the functionality of the MCL and the MCLMain is used to write input and get ouput back from the MCL.

We were runing a serie of experiments, and the code linked to here is the last one we ran.

Experiment 1
At this expriment we moved the car arround with the diffrent convertionfunctions found in the Light Sensor Test section. But the MCL localized the robot a up to a few cm wrong(with the piecewise linear function). So we looked into the MCL to find out why i was so.

Experiment 2
When we looked at the importance of the samples they were almost the same size, so we decide to ad a power-function to calculation of the importance. In this experiment we used a power of 10.
Because we wanted to make sure that the MCL were working we let all the measurements be the same - like the car was at one x-position(15) and measured the same each time(48).
We used 100 samples and ran 11 cycles trough the MCL.

At the end the end we printed the positions and importance of the samples and analyzed them i a matlab program(linked to below).


After the 11 cycles of the MCL the histogram of the sample position is shown below here. You can see that the most samples is located a little below 16. Which shows that the samples is moving toward the actual position(15).

The figure below shows the importance of the samples as function of their position. It's easy to see that the samples around 15 have the highest importance. Which made us conclude that a few more cycles would make the points move even more toward the actual position.

Experiment 3
Now we have a working MCL, but we were a little concerned about the power of 10. A downside of it could be that the MCL could move toward a wrong position and then not be able to correct it.
So we turned the power down to 2 and added more samples so we now were using 1000 samples. Everything else was as Experiment 2. And the output was analyzed in the matlab program.

The histogram of the x-positions below shows that the samples is much more widely placed on the map. But even though there is the highest amount of samples at 15, so it is working.

The importance as function of the position is much more flat than before and there is some bumps in the curve. But the highest importance is at 15 as expected.

Experiment 4
To see if the results of Experiment 3 was improving if the MCL was running more cycles we made it run for 111 cycles.

This results in that all the samples have their x-position inside 15 +/- 2,5. So the samples is moved much closer to the actual position. (the reason that the bars are not higher is that the samples still are separated into 50 bars, but the bars is only covering 5 cm were they before were covering 25 cm).
The importance as function of the position(shown below) ave become much more sharp and there is no bumps on the curve. So it is possible to achieve about the same precision with power 2 as 10, but it requires more samples and more cycles.

The 1D MCL is working and the sensors seems to be accurate enough to make it posible to find the posistion in the 1D-map. More experiments must be made on more advanced maps to determind the best parameters for the MCL. Is it high power and fast tracking or is it a low power and slow tracking.

No comments: