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

CombinedImuFactor: Add bias effect on position jacobian #874

Merged
merged 45 commits into from
Aug 21, 2022
Merged

Conversation

varunagrawal
Copy link
Collaborator

@varunagrawal varunagrawal commented Sep 16, 2021

Fixes #368

TODO

  • Add a unit test to capture this.
  • Update ImuFactor.pdf with details about the jacobians for CombinedImuFactor
  • Add details about Integration Covariance to ImuFactor.pdf.

@varunagrawal varunagrawal self-assigned this Sep 16, 2021
@varunagrawal varunagrawal added the bugfix Fixes an issue or bug label Sep 16, 2021
@varunagrawal varunagrawal changed the title [WIP] CombinedImuFactor: Add bias effect on position jacobian CombinedImuFactor: Add bias effect on position jacobian Sep 17, 2021
@varunagrawal
Copy link
Collaborator Author

@dellaert I need some help regarding the integration covariance. Can you point me to a resource that can help explain the mathematical basis for it?

@dellaert
Copy link
Member

@dellaert I need some help regarding the integration covariance. Can you point me to a resource that can help explain the mathematical basis for it?

No, @lucacarlone and @cfo did all this. The integration covariance was always a bit of a mystery to me as well ;-) Your best bet is @lucacarlone 's TR which I think you already asked for.

@varunagrawal
Copy link
Collaborator Author

@dellaert I need some help regarding the integration covariance. Can you point me to a resource that can help explain the mathematical basis for it?

No, @lucacarlone and @cfo did all this. The integration covariance was always a bit of a mystery to me as well ;-) Your best bet is @lucacarlone 's TR which I think you already asked for.

Gotcha! That's the only thing left to document before this PR is ready. 🙂

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0, //
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01;

// regression
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I think a "regression" is not enough here. It's easy to make a mistake, so how do we know the code is correct?

Copy link
Collaborator Author

@varunagrawal varunagrawal Sep 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great point which I have been wondering about myself. ImuFactor has a similar test (which I used as a template) so the same question can be asked about that factor.

I should add sub-tests that check for these things individually.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, especially with the non-trivial changes here, we need to think about how we can test, maybe using numbers also derivatives

@lucacarlone
Copy link
Contributor

@dellaert I need some help regarding the integration covariance. Can you point me to a resource that can help explain the mathematical basis for it?

No, @lucacarlone and @cfo did all this. The integration covariance was always a bit of a mystery to me as well ;-) Your best bet is @lucacarlone 's TR which I think you already asked for.

Gotcha! That's the only thing left to document before this PR is ready. 🙂

I shared the report, but I suspect it will not be very useful (it mostly covers the jacobians). I'm happy to write down the math if this is not super-urgent (I cannot do that before sometimes in October).

@varunagrawal
Copy link
Collaborator Author

@lucacarlone yes that works. We can update the document later since this PR is focused on resolving #368. 🙂

@varunagrawal varunagrawal marked this pull request as ready for review September 18, 2021 13:37
@varunagrawal
Copy link
Collaborator Author

@dellaert so I've spent some more time trying to test the preintegration covariance, and I've found a lot of inconsistencies.

  1. For the same initial conditions and measurements, the ImuFactor and the CombinedImuFactor give me significantly different covariances (6 orders of magnitude).
  2. There are some off-diagonal elements missing in the covariance computation for CombinedImuFactor. This is easy enough to add in.

Unfortunately, without understanding the math behind the preintegration covariance, I cannot be certain whether any operation is the correct one to do.

@varunagrawal
Copy link
Collaborator Author

This is the preintegration covariance for the ImuFactor

3.0625e-10          0          0          0          0          0          0          0          0
         0 3.0625e-10          0          0          0          0          0          0          0
         0          0 3.0625e-10          0          0          0          0          0          0
         0          0          0    2.5e-11          0          0      5e-09          0          0
         0          0          0          0    2.5e-11          0          0      5e-09          0
         0          0          0          0          0    2.5e-11          0          0      5e-09
         0          0          0      5e-09          0          0      1e-06          0          0
         0          0          0          0      5e-09          0          0      1e-06          0
         0          0          0          0          0      5e-09          0          0      1e-06

and for the same numbers, we get for CombinedImuFactor

0.01  0     0      0           0           0           0        0        0        0    0    0    0    0    0
0     0.01  0      0           0           0           0        0        0        0    0    0    0    0    0
0     0     0.01   0           0           0           0        0        0        0    0    0    0    0    0
0     0     0      2.50025e-07 0           0           0        0        0        0    0    0    0    0    0
0     0     0      0           2.50025e-07 0           0        0        0        0    0    0    0    0    0
0     0     0      0           0           2.50025e-07 0        0        0        0    0    0    0    0    0
0     0     0      0           0           0           0.010001 0        0        0    0    0    0    0    0
0     0     0      0           0           0           0        0.010001 0        0    0    0    0    0    0
0     0     0      0           0           0           0        0        0.010001 0    0    0    0    0    0
0     0     0      0           0           0           0        0        0        0.01 0    0    0    0    0
0     0     0      0           0           0           0        0        0        0    0.01 0    0    0    0
0     0     0      0           0           0           0        0        0        0    0    0.01 0    0    0
0     0     0      0           0           0           0        0        0        0    0    0    0.01 0    0
0     0     0      0           0           0           0        0        0        0    0    0    0    0.01 0
0     0     0      0           0           0           0        0        0        0    0    0    0    0    0.01

I know what is causing the difference, I just need to understand the rationale behind it.

@dellaert
Copy link
Member

Unfortunately, without understanding the math behind the preintegration covariance, I cannot be certain whether any operation is the correct one to do.

So, is this (a) the manifold or (b) tangent-space formulation that has issues?
If (a), the equations in Forster17tro should describe this.
If (b), the section Noise Propagation in ImuFactor.pdf should describe this.

You should not do any operation/correction unless it is described there. If somethings is done in the code that is not described in either document, what is it?

PS It might be easiest to start with tangent-space formulation.

@dellaert
Copy link
Member

Also, which unit test fails - excluding regression tests?

@varunagrawal
Copy link
Collaborator Author

I'm currently working explicitly in the tangent space formulation, but this is an issue in the noise propagation at the factor level so I imagine it will show even in the manifold formulation.

None of the math regarding the covariance of the CombinedImuFactor exists in ImuFactor.pdf. What's confusing is the interaction of the integration covariance with all the Jacobians which we don't have any documentation for yet.

Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to resolve the testing issue before we can land

@@ -42,6 +42,8 @@ typedef ManifoldPreintegration PreintegrationType;
* L. Carlone, Z. Kira, C. Beall, V. Indelman, F. Dellaert, Eliminating
* conditionally independent sets in factor graphs: a unifying perspective based
* on smart factors, Int. Conf. on Robotics and Automation (ICRA), 2014.
*
* [3] is available in this repo as "PreintegratedIMUJacobians.pdf".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not say this below where [3] is defined?

@@ -44,6 +44,8 @@ typedef ManifoldPreintegration PreintegrationType;
* C. Forster, L. Carlone, F. Dellaert, D. Scaramuzza, "IMU Preintegration on
* Manifold for Efficient Visual-Inertial Maximum-a-Posteriori Estimation",
* Robotics: Science and Systems (RSS), 2015.
*
* [3] is available in this repo as "PreintegratedIMUJacobians.pdf".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same: say this below

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0, //
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01;

// regression
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, especially with the non-trivial changes here, we need to think about how we can test, maybe using numbers also derivatives

@varunagrawal
Copy link
Collaborator Author

@lucacarlone yes last PR. Just the one file in CombinedImuFactor.cpp needs to be reviewed since that is the main change here.

@lucacarlone
Copy link
Contributor

@varunagrawal : to be honest I'm a bit lost among these PRs. the PR says this mostly updates the pdf, but you mention CombinedImuFactor.cpp is what's important?

@varunagrawal
Copy link
Collaborator Author

@lucacarlone so sorry about that. This PR was supposed to initially fix a bug causing degenerate covariances but we discovered a lot of issues when going through the IMU factor PDF, which is why you saw the other PRs built on top of this.

Honestly, this PR should be good to go since the other PRs were updates to this one. Frank prefers having smaller PRs to make reviewing easier but this time it proved to be a bit more complicated.

CombinedImuFactor.cpp is definitely the only major change here. Everything else should just be a repeat of things you've already reviewed.

@varunagrawal
Copy link
Collaborator Author

The original PR comment is definitely outdated.

Copy link
Contributor

@lucacarlone lucacarlone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving this, but haven't re-reviewed the math.

@varunagrawal
Copy link
Collaborator Author

@lucacarlone thank you! That should be fine since the math is the same from the prior PRs you reviewed and I went from math -> code + added lots of unit tests.

@dellaert just need you to unblock this PR now and we can land it!!! 😄

@varunagrawal varunagrawal linked an issue Aug 3, 2022 that may be closed by this pull request
@varunagrawal
Copy link
Collaborator Author

@dellaert I undid the name change from biasAccOmegaInt to biasAccOmegaInit. Will make another PR for that once this is merged so we can land this one.

@varunagrawal
Copy link
Collaborator Author

@dellaert

@dellaert
Copy link
Member

Thanks for isolating the name change. Will approve now.

@varunagrawal varunagrawal merged commit 587678e into develop Aug 21, 2022
@varunagrawal varunagrawal deleted the fix/368 branch August 21, 2022 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes an issue or bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The role of the integration covariance CombinedImuFactor with just one measurement leads to degeneracy
3 participants