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

Reason for 0.5 factor in the error #31

Open
nkhedekar opened this issue Oct 29, 2024 · 2 comments
Open

Reason for 0.5 factor in the error #31

nkhedekar opened this issue Oct 29, 2024 · 2 comments

Comments

@nkhedekar
Copy link

In the IntegratedMatchingCostFactor (and others), the error is evaluated as const double error = 0.5 * residual.transpose() * residual; . This error is then used to create the HessianFactor as new gtsam::HessianFactor(keys()[0], H_source, -b_source, error).

As per the documentation of the HessianFactor, the constant term that needs to be provided to the constructor is $f = b^Tb$ where $b = \Sigma^{-1/2} (z - h(x_0))$ is the whitened negative error at the linearization point $x_0$.
image

Maybe I am misunderstanding something but I don't follow the reason for the factor of 0.5 in the code?

@koide3
Copy link
Owner

koide3 commented Oct 30, 2024

Hmmm, maybe I added that constant for some reasons (consistency with GTSAM factors?), but I'm not very confident now. While the error value itself does not affect the optimization as long as H and b are correct, I'll re-check whether 0.5 is necessary.

@koide3
Copy link
Owner

koide3 commented Jan 9, 2025

Sorry, it took a long time to come back to this issue. I validated the linearized factor by comparing its error values with nonlinear ICP error values under small displacements. Without multiplying 0.5, the linear factor nicely approximates the nonlinear factor, and thus it seems 0.5 is not necessary. I'll soon add a patch to remove it from matching cost factors.

w/ 0.5
Screenshot_20250109_213022

w/o 0.5
Screenshot_20250109_213050

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

2 participants