We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c27fa87 + d9ea0c9 commit 9244135Copy full SHA for 9244135
1 file changed
core/src/kalman.rs
@@ -300,7 +300,13 @@ impl NavigationFilter for UnscentedKalmanFilter {
300
self.mean_state[7] = wrap_to_2pi(self.mean_state[7]);
301
self.mean_state[8] = wrap_to_2pi(self.mean_state[8]);
302
self.covariance -= &k * &s * &k.transpose();
303
- self.covariance = 0.5 * (&self.covariance + self.covariance.transpose());
+ // Ensure covariance remains positive semi-definite with gentle regularization
304
+ self.covariance = symmetrize(&self.covariance);
305
+ // Add small diagonal regularization to prevent negative eigenvalues
306
+ let eps = 1e-9;
307
+ for i in 0..self.state_size {
308
+ self.covariance[(i, i)] += eps;
309
+ }
310
}
311
fn get_estimate(&self) -> DVector<f64> {
312
self.mean_state.clone()
0 commit comments