hku-mars / BALM

An efficient and consistent bundle adjustment for lidar mapping
GNU General Public License v2.0
700 stars 151 forks source link

strange covariance matrix of the estimated poses for benchmark_realworld #33

Closed JzHuai0108 closed 1 year ago

JzHuai0108 commented 1 year ago

Dear authors,

Thank you for the great work. I have run the simulation/consistency app, the saved covariance matrix of the estimated poses (100 poses) is in the attached txt file. The values look fine, agreeing with the fact that the computed NEES value is as expected (600).

So I also try to compute the covariance matrix in the benchmark_realworld app. The default app does not support Rcov, so I have made a few seemingly innocuous changes including

  1. define POINT_NOISE, and use the PointCluster class from simulation/tools.hpp.

  2. paste multi_second and give_second from BAs.hpp to bavoxel.hpp for the right state errors.
  3. straighten the function interfaces.

Then the app is run for the first 61 scans (to save computation for a test) of the benchmark_realworld data. The saved covariance is also attached as a txt file. The covariance entries for the position error states is very large say 100000, as we expect very small values. Can you please inform me about how to fix this issue?

sim_cov_100.txt cov_61.txt

Zale-Liu commented 1 year ago

I think your result is with no problem. In the process of computing covariance matrix for BA, we assume that all the features are strictly planes. In the simulation setup, we can ensure that all the features are flat planes and the point noise is isotropic. In the real-world data, excessive interference may lead to unexpected NEES.

JzHuai0108 commented 1 year ago

Sorry for the late reply. I finally got a break from picking up cotton on my master's plantation :(.

Sounds somewhat reasonable. But your paper implied that proper weighting by covariance is crucial to consistent mapping for real data. How do you obtain the proper covariance matrix if the real data are subject to pose uncertainty and wrong associations? Note that in the above test, I used the sample real data which should have pretty good quality.

For your information, In that paper, just below eq 4, it is mentioned that "the covariance matrix is computed by inverting the Hessian matrix H obtained from the bottom-up hierarchical BA process". And on page 7, section IV.B.2) Hierarchical BA versus Reduced BA, it is demonstrated that proper weighting with correct covariance improves mapping accuracy.

Another point I think may make a difference is the prior factor. In the above simulation test, there was a fixed marginalization factor whereas, in the above real data test, the gauge freedom was not fixed. Do you think this difference could result in the bizarre covariance values in the real data test?

YangSiri commented 1 year ago

Hi, @JzHuai0108

I've encountered the same question as you've mentioned. The covariance matrix (Hess in the code) is strangely large but agrees with the real situation: samller cov in roll, pitch and z components as the constraints are enough for the outdoor scenes. Have you figured out this recently?

JzHuai0108 commented 1 year ago

Unfortunately, I have not solved it yet though I'd like to solve it.

HaisenbergPeng commented 1 year ago

Hi, @JzHuai0108

I've encountered the same question as you've mentioned. The covariance matrix (Hess in the code) is strangely large but agrees with the real situation: samller cov in roll, pitch and z components as the constraints are enough for the outdoor scenes. Have you figured out this recently?

Sorry for the late reply. I finally got a break from picking up cotton on my master's plantation :(.

Sounds somewhat reasonable. But your paper implied that proper weighting by covariance is crucial to consistent mapping for real data. How do you obtain the proper covariance matrix if the real data are subject to pose uncertainty and wrong associations? Note that in the above test, I used the sample real data which should have pretty good quality.

For your information, In that paper, just below eq 4, it is mentioned that "the covariance matrix is computed by inverting the Hessian matrix H obtained from the bottom-up hierarchical BA process". And on page 7, section IV.B.2) Hierarchical BA versus Reduced BA, it is demonstrated that proper weighting with correct covariance improves mapping accuracy.

Another point I think may make a difference is the prior factor. In the above simulation test, there was a fixed marginalization factor whereas, in the above real data test, the gauge freedom was not fixed. Do you think this difference could result in the bizarre covariance values in the real data test?

It seems that your guess is right. I add the 'marginalize' function then the covariance seems about right: 3.5256e-12 3.11688e-11 -3.04067e-09 -3.16728e-06 -4.32052e-06 -1.01181e-11 In the 'to_margi' function, all point clusters are shifted 1 position, and the point clusters in the end are removed. I can understand the removal operation, but why do the shift?

YangSiri commented 1 year ago

Hi, @HaisenbergPeng

Could you please explain more about the 'maginalize' function and how to get the right covariance?

Thank you very much!

HaisenbergPeng commented 1 year ago

'margilize' function is already written in the code. I just used it. try this? benchmark_realworld.txt

JzHuai0108 commented 1 year ago

@HaisenbergPeng Kudos to you.

YangSiri commented 1 year ago

@HaisenbergPeng ,tql!

JzHuai0108 commented 1 year ago

I close the issue because it is solved. The strange covariance is due to gauge freedom which can be fixed by e.g., marginalizing the leading pose.