Repository navigation
Reuse the covariance ellipse helper in all localizers - #137
Open
dchaudhari7177 wants to merge 1 commit into
Open
dchaudhari7177 wants to merge 1 commit into
dchaudhari7177 wants to merge 1 commit into
Conversation
The EKF, UKF and particle filter localizers each computed and drew their error ellipse by hand. Use draw_covariance_ellipse() instead, and in the helper use eigh (covariance matrices are symmetric), compute the points with numpy, pass extra plot options through, and explain the scale factor 3.0. The EKF used to run eig on its whole 4x4 state covariance, so yaw and speed terms leaked into the position ellipse; it now draws the x-y block like the UKF and the particle filter. Closes ShisatoYano#124
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #124
Overview
The EKF, UKF and particle filter localizers each computed and drew their error ellipse by hand. They now call
draw_covariance_ellipse()fromplot_lib.py, and the helper is tidied as the issue asks:np.linalg.eighinstead ofeig: a covariance matrix is symmetric, so the eigenvalues are real and come back sorted, which removes the big/small index juggling. Eigenvalues that rounding pushes slightly below zero are clipped to 0.a * np.cos(t),b * np.sin(t)) instead of list comprehensions.3.0is explained in a comment. The ellipse is the set where the squared Mahalanobis distance from the centre is 3: its half-axes are √3 standard deviations, and it contains 1 − e^(−3/2) ≈ 78 % of a 2D Gaussian. The particle filter's old comment called it a "3-sigma ellipse (99.7% confidence)", which it isn't, so that comment is gone.axes.plot, so the particle filter keeps itslinewidth=1.5. Colour is passed by keyword now.ndt_map.py, the existing user, is unaffected.One behaviour fix comes with it. The EKF ran
eigon its whole 4×4 state covariance and used the first two eigenpairs, so yaw and speed variances (and their correlation with x and y) leaked into the position ellipse. The UKF and the particle filter already used the x-y block; all three now passcov_mat[:2, :2]. With an x-y block rotated by 30° plus some x–yaw correlation, the old EKF ellipse put its points at squared Mahalanobis distances from 6.6 to 132 instead of 3.The now-unused
XYArrayandmathimports are removed from the three localizers.How I confirmed it works
New
test/test_plot_lib.py:color,linewidth) reachaxes.plot;main).Three of the four fail on
main: the EKF one, and the two that readcolorfrom the plot keyword arguments, whichmainpasses positionally. All four pass here. The localization simulations still run:test_ekf_localization_path_tracking,test_ukf_localization_path_tracking,test_pf_localization_path_tracking,test_ekf_vs_ukf_comparison,test_ekf_ukf_pf_comparisonandtest_ndt_map_constructionall pass.I didn't update the demo GIFs. I regenerated the EKF localization GIF on
mainand on this branch: at the demo's zoom the ellipse is a few pixels either way, and frames from the two only differ in the random sensor noise. The committed GIF predates other changes onmain(it has no course line, for example), so regenerating it here would mostly show those.