fix(Point-LIO): 信息形式分支把 m_noise 当精度用,与协方差分支不一致

update_iterated_dyn_share_modified() 的两个分支对同一量语义不同:
m_noise 是方差(M_Noise = laser_point_cov),信息形式里精度应是 1/m_noise。
原来直接乘 m_noise,导致「追加零信息行反而缩放后验」,与协方差分支结果分歧。

改为 inv_noise = 1/m_noise 后,两式与
  K = (P^-1 + (1/r) H^T H)^-1 H^T (1/r)
一致。同时暴露三个只读诊断字段(state dof / effective m / 走了哪个分支)。

回归:docs/diagnostics/esekfom_update_regression/ 直接 #include 生产头,
用生产 init_dyn_share_modified_2h 入口驱动,参考解为稠密 Kalman(LLT 求解,
不用伪逆),全部通过;Point-LIO 重编通过(6 min 44 s)。
This commit is contained in:
walunt5
2026-11-05 11:58:38 +08:00
parent d2b4cc00c6
commit d9eb7a6ea3
5 changed files with 622 additions and 2 deletions
@@ -202,6 +202,9 @@ public:
state x_propagated = x_;
int dof_Measurement;
double m_noise;
last_update_state_dof_ = -1;
last_update_effective_m_ = -1;
last_update_information_branch_ = false;
for (int i = 0; i < maximum_iter; i++) {
dyn_share.valid = true;
h_dyn_share_modified_1(x_, P_.template block<3, 3>(0, 0), P_.template block<3, 3>(3, 3), dyn_share);
@@ -232,11 +235,18 @@ public:
}
K_ = PHT * HPHT.inverse();
} else {
Matrix<scalar_type, 12, 12> HTH = m_noise * h_x.transpose() * h_x;
// Information form. m_noise is a VARIANCE (M_Noise = laser_point_cov),
// so it enters as a precision 1/m_noise in both places:
// K = (P^-1 + (1/r) H^T H)^-1 H^T (1/r)
// Passing r instead of 1/r here made this branch disagree with the
// covariance branch above: appending a zero-information row rescaled the
// posterior. Regression: docs/diagnostics/esekfom_update_regression.
const scalar_type inv_noise = scalar_type(1) / m_noise;
Matrix<scalar_type, 12, 12> HTH = inv_noise * h_x.transpose() * h_x;
Matrix<scalar_type, n, n> P_inv = P_.inverse();
P_inv.template block<12, 12>(0, 0) += HTH;
P_inv = P_inv.inverse();
K_ = P_inv.template block<n, 12>(0, 0) * h_x.transpose() * m_noise;
K_ = P_inv.template block<n, 12>(0, 0) * h_x.transpose() * inv_noise;
}
Matrix<scalar_type, n, 1> dx_ =
K_ * z; // - h) + (K_x - Matrix<scalar_type, n, n>::Identity()) * dx_new;
@@ -246,6 +256,9 @@ public:
{
P_ = P_ - K_ * h_x * P_.template block<12, n>(0, 0);
}
last_update_state_dof_ = static_cast<int>(n);
last_update_effective_m_ = dof_Measurement;
last_update_information_branch_ = !(n > dof_Measurement);
}
return true;
}
@@ -304,8 +317,18 @@ public:
const state & get_x() const { return x_; }
const cov & get_P() const { return P_; }
// Diagnostics for the most recent update_iterated_dyn_share_modified() call.
// Written after the update completes; read-only from outside. These do not
// participate in any computation.
int last_update_state_dof() const { return last_update_state_dof_; }
int last_update_effective_m() const { return last_update_effective_m_; }
bool last_update_information_branch() const { return last_update_information_branch_; }
cov P_;
state x_;
int last_update_state_dof_ = -1;
int last_update_effective_m_ = -1;
bool last_update_information_branch_ = false;
private:
measurement m_;