Add radar example to test Kalman filter#785
Open
ThreeMonth03 wants to merge 1 commit into
Open
Conversation
ThreeMonth03
commented
May 16, 2026
Collaborator
Author
ThreeMonth03
left a comment
There was a problem hiding this comment.
@yungyuc @j8xixo12 @xingularity Please take a look. Thanks.
Comment on lines
+181
to
+183
| array_type const & q, // FIXME: NOLINT(modernize-pass-by-value) | ||
| array_type const & r, // FIXME: NOLINT(modernize-pass-by-value) | ||
| array_type const & p, // FIXME: NOLINT(modernize-pass-by-value) |
Collaborator
Author
There was a problem hiding this comment.
To determine the covariance matrix at the beginning, I create new constructor in KalmanFilter.
Comment on lines
+411
to
+424
| def test_kalmanfilter_net_radar_example(self): | ||
| # Reference: https://kalmanfilter.net/ | ||
| dt = 5.0 | ||
| x0 = np.array([10000.0, 200.0]) | ||
| f = np.array([[1.0, dt], | ||
| [0.0, 1.0]]) | ||
| h = np.eye(2) | ||
| p0 = np.array([[16.0, 0.0], | ||
| [0.0, 0.25]]) | ||
| q = np.array([[6.25, 2.5], | ||
| [2.5, 1.0]]) | ||
| r = np.array([[36.0, 0.0], | ||
| [0.0, 2.25]]) | ||
| z1 = np.array([11020.0, 202.0]) |
Collaborator
Author
There was a problem hiding this comment.
The following testcase could be found in the reference.
j8xixo12
reviewed
May 16, 2026
| np.testing.assert_allclose( | ||
| kf.state.ndarray, x_pred_expected, atol=1e-12, rtol=0.0) | ||
| np.testing.assert_allclose( | ||
| kf.covariance.ndarray, p_pred_expected, atol=1e-12, rtol=0.0) |
Collaborator
There was a problem hiding this comment.
Why is the atol here different from the one on line 454 ?
Collaborator
Author
There was a problem hiding this comment.
The error at line 454 is much bigger than line 445, so I set 1e-8 there. I would try to align the absolute difference (atol).
Collaborator
There was a problem hiding this comment.
It seems you have increased the precision of the answer to reduce the error.
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.
For issue #685, to validate the implementation of Kalman filter algorithm, @j8xixo12 finds a real example from kalmanfilter.net .
This pull request add the website example to test Kalman filter.