Instead, when the error ellipse is degenerate, use one of these formulas:
tan theta = b / a if a != 0 cot theta = b / c if c != 0These formulas only work when the error ellipse is degenerate!
if theta is in radians, then d/dtheta(cos_rad theta) = - sin_rad theta
if theta is in degrees, then first let phi = theta * pi / 180
d/dtheta(cos_deg theta) = d/dtheta(cos_rad phi)
= - (sin_rad phi) * dphi/dtheta
= - (sin_deg theta) * pi / 180
An alternative, of course, is to do all your calculations in radians.
Another useful path to try is to trace out a circle in a number of discrete steps. Your first step should be a turn, and then you should have a number of identical steps followed by a turn. You might take 20 or 50 steps to go around the circle. The position uncertainty should be circular after you travel around the circle once.
There are two ways I can explain this. One is that these formulas are trying to draw an ellipse that captures a certain volume under the probability density function. As the minor axis radius approaches 0, the major axis radius approaches infinity to make up the difference. Of course, the reason that the minor axis radius would be 0 is when you know the position of the robot exactly in some direction (as you do at the start of a run!) The other explanation is that with a one dimensional distribution, you have to use a different set of formulas.
In order to draw the degenerate 95% error ellipse, you will simply draw a line of length 4*sigma (i.e. 2*sigma on each side of the mean) along the major axis. You can get the angle of the major axis by using the same formula as for the nondegenerate case (i.e. equation 18 in the aforementioned handout). The variance of the distribution will be equal to a + c.
Support Code for reading input files
Here are the support code files for the basic robot simulator and the
random number stuff (updated 2/23/01 to include the simulated sensor)
Here's a little test program which I used to test the simulated laser rangefinder: