Skip to content

Commit 8d257bc

Browse files
authored
Merge pull request #24 from MOLAorg/fix/bugs-in-simple-estimator-cov
Fix: Avoid double covariance increment
2 parents ebfb4ff + e7e3c86 commit 8d257bc

2 files changed

Lines changed: 25 additions & 21 deletions

File tree

mola_state_estimation_simple/include/mola_state_estimation_simple/StateEstimationSimple.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
namespace mola::state_estimation_simple
4141
{
42-
/** Fuse of odometry, IMU, and SE(3) pose/twist estimations.
42+
/** Simple motion-model state estimator fusing odometry, IMU, and SE(3) pose/twist.
4343
*
4444
* Usage:
4545
* - (1) Call initialize() or set the required parameters directly in params_.
@@ -50,13 +50,24 @@ namespace mola::state_estimation_simple
5050
* - (4) Read the estimation up to any nearby moment in time with
5151
* estimated_navstate()
5252
*
53-
* Old observations are automatically removed.
53+
* ## Prior covariance model (estimated_navstate)
5454
*
55-
* \note This implementation of mola::NavStateFilter ignores the passed
56-
* "frame_id".
57-
* \note It also ignore GNSS sensor.
55+
* Given `dt` seconds elapsed since the last `fuse_pose()` call, the returned
56+
* prior pose covariance diagonal is:
57+
*
58+
* cov_xyz = sigma_relative_pose_linear^2
59+
* + (sigma_random_walk_acceleration_linear * dt)^2
60+
*
61+
* cov_rot = sigma_relative_pose_angular^2
62+
* + (sigma_random_walk_acceleration_angular * dt)^2
5863
*
59-
* \sa mola::IMUIntegrator
64+
* `sigma_relative_pose_linear` [m] is a dt-independent floor on position
65+
* uncertainty and is the primary knob for tightening the ICP prior.
66+
* `sigma_random_walk_acceleration_linear` [m/s^2] adds time-growing
67+
* uncertainty due to unmodeled accelerations.
68+
*
69+
* \note This implementation of mola::NavStateFilter ignores the passed
70+
* "frame_id" and GNSS observations.
6071
*
6172
* \ingroup mola_state_estimation_grp
6273
*/

mola_state_estimation_simple/src/StateEstimationSimple.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -312,21 +312,14 @@ std::optional<NavState> StateEstimationSimple::estimated_navstate(
312312
cov(i, i) += varRot;
313313
}
314314

315-
if (state_.last_twist_cov.has_value())
316-
{
317-
auto twistCov = state_.last_twist_cov.value();
318-
twistCov *= dt * dt;
319-
cov += twistCov;
320-
321-
for (int i = 0; i < 3; i++)
322-
{
323-
(*state_.last_twist_cov)(i, i) += varXYZ;
324-
}
325-
for (int i = 3; i < 6; i++)
326-
{
327-
(*state_.last_twist_cov)(i, i) += varRot;
328-
}
329-
}
315+
// sigma_rel is a position-domain quantity (meters): add it directly as
316+
// position variance, independent of the fuse_pose/query dt ratio.
317+
cov(0, 0) += mrpt::square(params.sigma_relative_pose_linear);
318+
cov(1, 1) += mrpt::square(params.sigma_relative_pose_linear);
319+
cov(2, 2) += mrpt::square(params.sigma_relative_pose_linear);
320+
cov(3, 3) += mrpt::square(params.sigma_relative_pose_angular);
321+
cov(4, 4) += mrpt::square(params.sigma_relative_pose_angular);
322+
cov(5, 5) += mrpt::square(params.sigma_relative_pose_angular);
330323

331324
ret.pose.cov_inv = cov.inverse_LLt();
332325

0 commit comments

Comments
 (0)