So which works better for localization, particle filters or kalman filters?

Has anybody tried testing our two localization strategies against each other in the robot framework?

asked 31 Mar '12, 17:31

peteMcC's gravatar image

peteMcC
1.4k82040
accept rate: 88%


2 Answers:

You're sort of comparing apples to oranges. Which one to use depends entirely on what problem you're trying to solve.

When your measurement error and process error are both Gaussian, the Kalman filter can't be beat for computational efficiency. But be really careful about using it at all otherwise.

The great thing about the particle filter is that it's applicable to almost any kind of error model, including Gaussian. And it should theoretically produce roughly the same results as the Kalman filter since they both use a proper Bayesian model. But it's really slow, and a bit less accurate (depending on the number of particles). Never use a particle filter when a Kalman filter is applicable.

Edit: Actually, it's interesting that the course didn't really answer this question very well. I would've really appreciated a bit more discussion regarding the applicability of different filters for different applications. It's something I've been struggling with lately.

link

answered 31 Mar '12, 20:07

John-Paul's gravatar image

John-Paul
98331328

edited 31 Mar '12, 20:10

Well you answered it, so I guess I could say the crowd sourcing aspect of this course did answer this question. Thanks by the way.

In another respect I would say I asked this question because I really didn't know the answer and I thought asking roughly 10,000 people would be more efficient than doing it myself. Eventually I will go though it myself and I will use these answers as my 'ground truth'.

(31 Mar '12, 20:35) peteMcC peteMcC's gravatar image

I have not! But it sounds like a fun test. Particle filters should, I would think, in theory, do the same thing the Kalman filter does. But not the other way around. Particle filters can do more than Kalman filters since they are multimodal and can represent any shape of discrete probability distribution. Kalman filters only represent Gaussian distributions as far as I understand.

link

answered 31 Mar '12, 18:19

Curt%20Welch's gravatar image

Curt Welch
4.9k124574

I agree with your assessment. The robot framework may not test these two completely for the reasons you state. But it will be an interesting test. I will eventually test this when I have some time.

(31 Mar '12, 18:40) peteMcC peteMcC's gravatar image

When I was working on part six of week six, it wouldn't work so I spent a couple of hours rigging up a graphical thing to plot the maze, the smoothed path, and the estimate of the robot position. When I moved on to part seven, I added the robot's actual position to the display.

What I discovered was that the robot's position and the particle filter's estimate would be the same for a while and then they would diverge, never to meet again. I eventually concluded that the particle filter eventually got reduced to a single particle that matched the position of the robot fairly well, but once the particle loses track of the vehicles's position there's no way it can find it again because it's only got one place to pick from.

So, I went in and extended the particle filter by always introducing new particles and wound up with a system where the two positions were always much closer. It didn't work any better guiding the robot, but it didn't work any worse, either, and the estimates were much closer at the end of the goal

I'm kind of wondering if anyone has any interest in that code.

(31 Mar '12, 21:26) JonathanG JonathanG's gravatar image

@JonathanG It sounds like you missed a couple of concepts in your particle filter implementation.

Remember that the measurement step is always supposed to select the same number of particles, so you will never run low. Some of the particles will be duplicates, but on the move step, each particle is projected with random error introduced, so there will no longer be duplicates.

If you get this right, you will never run low on particles, and you will never need to introduce new ones.

(31 Mar '12, 21:39) John-Paul John-Paul's gravatar image

@JonathanG That's an interesting finding. I would not expect you to need to add particles like that for this application. If the random noise of the measurement step caused the measurements to jump outside the current range of particles, that's an indication that the Gaussian function used for applying the measurement to the particle filters did not correctly match the true Gaussian behavior of the measurement!

That is, when a measurement is applied it will not cause the paticles to all cluster into exactly one spot. They will form a Gaussian distribution around the measurement. How wide they all spread is a function of the assumed noise in the sensory signal. If the assumed noise is hard coded, but is too small, it will cause the particles to clump together too closely, and then a random measurement could do as you say, land so far away from the clump, that it takes the particle filter a long time to find the location again.

But if that happens, it is generally an indication that too small of a variance was hard coded into either the measurement, or the move steps. If we increase those values to be correct (we know what the real behavior of the measurement is since it's a simulation), then it should not have that tracking problem.

I'll have to look at the code and see if I can figure out what's happening there. Sebastian might not have "correctly" coded the particle filter to match the noise he coded into the measurements and movements.

And it will be interesting to try and test to see if in fact, the particle filter does lose track of the robot. I would like to plot a dot at each measurement number given to the filter and see where those land relative to the path the filter is returning.

(31 Mar '12, 22:53) Curt Welch Curt%20Welch's gravatar image

BTW, looking at the estimated path the particle filter was producing (I plotted that as well), it did strike me that the path was far more chaotic and jagged than I expected it to be. I expected it should have produced a smoother path (even if the path was off track from the real location due to the noise in the data).

(31 Mar '12, 22:56) Curt Welch Curt%20Welch's gravatar image

What I'm hearing is that I went to a lot of trouble to add a bunch of code that has the same effect as increasing the noise parameters that are labelled "don't change". So I created a modified version with an unmodified particle filter and I increased the noise parameters just for the particle filter. When I did that, it looks to me like the output of the particle filter looks matches the robot's position more closely than it did with the smaller noise parameters, even after the first big bend that the system has so much trouble with.

I still don't understand why the particle filter lost the robot on a lot of the runs I did with the smaller noise parameters and it didn't seem to have happened with anyone else. Luck of the draw, I guess. I can't get it to do it, now.

(01 Apr '12, 10:09) JonathanG JonathanG's gravatar image

I double checked all the code to make sure it was calculating and processing measurements correctly and it is. If you set the noise low enough, you can see the filter actually lose the car. I had never seen that happen before. The result is funny (and surprised me) because the particle filter stays on track, where as the real car goes driving off into never never land. The program in effect is "driving" the particle filter around the track, while ignoring the real car!

Here's an example of what it looks like when the particle filter loses track of the car (and can't find it again due to a lack of particles in the right part of the state space):

http://s18.postimage.org/4nv6osf2h/lost_particle_filter.png

I set the measurement noise down to something like .03 to cause that.

I want to play some more with the particle filter, such as changing the number of particles, to see how that effects it's ability to track.

(01 Apr '12, 15:16) Curt Welch Curt%20Welch's gravatar image
Your answer
Question text:

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×5,188
×140
×76
×61
×25

Asked: 31 Mar '12, 17:31

Seen: 560 times

Last updated: 01 Apr '12, 15:16