Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function optimizer.computeMarginals() #70

Open
andelby opened this issue Oct 4, 2019 · 8 comments
Open

Function optimizer.computeMarginals() #70

andelby opened this issue Oct 4, 2019 · 8 comments

Comments

@andelby
Copy link

andelby commented Oct 4, 2019

hi, the result of the optimizer.computeMarginals(), is the covariance matrix about the estimated pose?

// bool flag = optimizer.computeMarginals(spinv,optimizer.vertex(0));

@ferreram
Copy link

ferreram commented Oct 4, 2019

Hi, the function computeMarginals() returns the Hessian matrix associated to the state vertex(0), you have to invert it to get the covariance.

@andelby
Copy link
Author

andelby commented Oct 4, 2019

1)thanks @ferreram for the reply, I tried writing this code:
g2o::SparseBlockMatrixXd spinv; optimizer.computeMarginals(spinv, optimizer.vertex(0)); Eigen::Matrix<double, 6, 6> margCovInv = Eigen::Matrix<double, 6, 6>::Zero(); margCovInv.topLeftCorner(6,6) = spinv.block(0, 0)->inverse(); cout<<"Matrix covariance:\n"<<margCovInv<<endl;

But the matrix seems to be incorrect (values too high?)

Schermata del 2019-10-04 13-04-30

Did I miss something in the code?

2)This covariance matrix refer only to the last pose, or to the full trajectory?

@ferreram
Copy link

ferreram commented Oct 4, 2019 via email

@arianna003
Copy link

arianna003 commented Oct 4, 2019

hi @ferreram , the matrix of @Andrea485's figure represent covariance not hessian, but is the pose coordinate uncertainty in meters?

@ferreram
Copy link

ferreram commented Oct 4, 2019

Hi @arianna003 , yes you're right, my bad I read it too fast. In this case @Andrea485 , the uncertainty values of your covariance matrix indeed seems very high. The uncertainty around the translation parts of the matrix are in squared meters if the transnational parts of the states are expressed in meters (it should be the case with a Visual-Inertial method but not with a monocular SLAM)

@andelby
Copy link
Author

andelby commented Oct 4, 2019

@ferreram what's wrong in my code, what can I do?

@ferreram
Copy link

ferreram commented Oct 4, 2019

@Andrea485 , there is nothing wrong in the code you have used to compute the covariance matrix. But what are you doing? VI-Odometry? If so, is the Bundle Adjustment like optimization is giving you good results? You can also have a look at the information you are setting for your edges.

As the Hessian matrix is derived from the Jacobian and the information matrix, high covariances will come from high Jacobians value. Maybe you should verify your Jacobian as well (you can test doing automatic differentiation).

@leslieburke
Copy link

leslieburke commented Dec 5, 2022

@Andrea485 I got the same problem, the value of covariance matrix is too high?what wrong with it?
2022-12-05 16-34-23屏幕截图

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants