-
Notifications
You must be signed in to change notification settings - Fork 773
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
Fix CombinedImuFactor #882
Conversation
c20fe7d
to
3cee1b7
Compare
@varunagrawal : how is it going on this? I'm happy to help if you want! |
I've actually figured this out but we're in the middle of a submission cycle, so I'll get back to this in a week. :) |
yay! great to hear! |
@lucacarlone I am requesting a review from you and I hope you will be the primary person for discussion to get this fix merged in. I have updated the |
@varunagrawal could you give some more context and summary of changes in the PR comment so @lucacarlone could sanity-check this? I'll also be happy to take a look. Also, consider pasting the relevant change from the PDF in the comments so this is easy to review without having to checkout the pdf. |
@varunagrawal @dellaert : I'm happy to review this! |
@dellaert @lucacarlone here are the relevant sections. The code should match the math. If something is unclear or the if there are better naming recommendations, I am happy to oblige. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are now changes in 808 files. Did you change the base? Reason it's not develop?
Also. just pasting those sections does not make clear what changed. Please help us by providing that and the reason for the change.. |
The main idea is that I re-derived the covariance update equations for the |
Sorry about that. Had to merge in develop across multiple branches. This PR does not target |
@@ -123,7 +123,7 @@ boost::shared_ptr<PreintegratedCombinedMeasurements::Params> imuParams() { | |||
// PreintegrationCombinedMeasurements params: | |||
p->biasAccCovariance = bias_acc_cov; // acc bias in continuous | |||
p->biasOmegaCovariance = bias_omega_cov; // gyro bias in continuous | |||
p->biasAccOmegaInt = bias_acc_omega_int; | |||
p->biasAccOmegaInit = bias_acc_omega_init; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming breaks API and I really think it was meant to be "int" for "integration"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, we have integrationCovariance
in PreintegrationParams.h
for integration. This was a typo that I fixed.
@@ -94,7 +94,7 @@ boost::shared_ptr<PreintegratedCombinedMeasurements::Params> imuParams() { | |||
I_3x3 * 1e-8; // error committed in integrating position from velocities | |||
Matrix33 bias_acc_cov = I_3x3 * pow(accel_bias_rw_sigma, 2); | |||
Matrix33 bias_omega_cov = I_3x3 * pow(gyro_bias_rw_sigma, 2); | |||
Matrix66 bias_acc_omega_int = | |||
Matrix66 bias_acc_omega_init = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -39,7 +39,7 @@ void PreintegrationCombinedParams::print(const string& s) const { | |||
<< endl; | |||
cout << "biasOmegaCovariance:\n[\n" << biasOmegaCovariance << "\n]" | |||
<< endl; | |||
cout << "biasAccOmegaInt:\n[\n" << biasAccOmegaInt << "\n]" | |||
cout << "biasAccOmegaInit:\n[\n" << biasAccOmegaInit << "\n]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -62,19 +62,19 @@ typedef ManifoldPreintegration PreintegrationType; | |||
struct GTSAM_EXPORT PreintegrationCombinedParams : PreintegrationParams { | |||
Matrix3 biasAccCovariance; ///< continuous-time "Covariance" describing accelerometer bias random walk | |||
Matrix3 biasOmegaCovariance; ///< continuous-time "Covariance" describing gyroscope bias random walk | |||
Matrix6 biasAccOmegaInt; ///< covariance of bias used for pre-integration | |||
Matrix6 biasAccOmegaInit; ///< covariance of bias used as initial estimate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etc...
@@ -145,7 +145,8 @@ Eigen::Matrix<double, 15, 15> CombinedScenarioRunner::estimateCovariance( | |||
auto pim = integrate(T, estimatedBias, true); | |||
NavState sampled = predict(pim); | |||
Vector15 xi = Vector15::Zero(); | |||
xi << sampled.localCoordinates(prediction), estimatedBias_.vector(); | |||
xi << sampled.localCoordinates(prediction), | |||
(estimatedBias_.vector() - estimatedBias.vector()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the only real change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this PR? CombinedImuFactor.cpp
has the main changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are making a math change - in future make this as atomic as possible. Lot's of distractions that make this hard to review.
D_R_R(&G_measCov_Gt) = theta_H_biasOmega // | ||
* (wCov_updated / dt) // | ||
* (theta_H_biasOmega.transpose()); | ||
D_v_v(&G_measCov_Gt) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you restore the order in which these terms are computed for easier review, and comment on what has changed and why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This order would be more aligned with the math and should make verifying it easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm saying it's harder for review. It's also not arbitrary. Maybe re-arrange the math. The order of Navstate
is "attitude", "position", "velocity".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused. It's already in attitude-position-velocity order (D_R_R for attitude, D_t_t for position and D_v_v fro velocity). The prior code had it position-velocity-attitude which isn't the expected order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@varunagrawal : besides the order of the pre-integrated measurements, can you point out what changed with respect to my (terrible) writeup? I think you added a second-order term in the position and changed how the covariances are discretized. were there other bugs you fixed with respect to my writeup? (i.e., was my writeup wrong, or only the implementation? or both? :-) )
also: is the order attitude-position-velocity now also used in the standard IMU factor? or only the combined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe just the implementation was incorrect in certain places. @lucacarlone's overall writeup was pretty great and I just expanded upon that with additional information I picked up from other books and papers. :)
It's been a while since I've seen this math though so I may have added minor corrections where I found them which I don't remember of the top of my head.
As for the attitude-position-velocity order, this was not really an issue for ImuFactor since the expression for the jacobians was a lot simpler (G * C/dt * G'
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at the differences again: I also changed the noise variable order from
$$\epsilon_{b^{\omega}{init}}, \epsilon{\Delta b^{a}}, \epsilon_{\Delta b^{\omega}}$$
to
$$\epsilon_{int}, \epsilon_{b^{a}{init}}, \epsilon{b^{\omega}_{init}}$$
(Apologies for the rendering issues. Seems like Github's Math mode is a bit buggy.)
D_v_t(&G_measCov_Gt) = vel_H_biasAcc * (aCov / dt) * pos_H_biasAcc.transpose(); | ||
D_R_v(&G_measCov_Gt) = temp.transpose(); | ||
D_t_v(&G_measCov_Gt) = pos_H_biasAcc * (aCov / dt) * vel_H_biasAcc.transpose(); | ||
D_R_t(&G_measCov_Gt) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. And why get rid of temp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got rid of temp because the derivation is no longer D_v_R = temp
and D_R_v = temp.transpose()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@varunagrawal : I'm starting to review the PR - great job overall! I plan to add comments as I go, starting from the writeup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me overall - thanks for the great work @varunagrawal !! It would be amazing to have a numerical analysis / example showing that this leads to better results (or at least better bias estimates).
\begin_inset Formula $\zeta_{k}=[\theta_{k},p_{k},v_{k}]$ | ||
\end_inset | ||
|
||
and rewrite Eqns. | ||
, as a 9D vector on tangent space at and rewrite Eqns. | ||
( | ||
\begin_inset CommandInset ref | ||
LatexCommand ref |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
near eq (17) it is worth remarking these are discrete-time covariances (and point to the section on covariance discretization)
|
||
The noise model associated with this factor is assumed to be zero-mean Gaussian | ||
with a | ||
\begin_inset Formula $9\times9$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slightly confusing, since it is 15x15 in the combined factor. I would rephrase this sentence to keep it more general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, though Frank wanted this to be specific since we have different sections for ImuFactor and CombinedFactor. I'll add a corresponding paragraph in the Combined IMU Factor
subsection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
doc/ImuFactor.lyx
Outdated
|
||
. | ||
This covariance matrix is computed in the preintegrated measurement class, | ||
of which there are two variants as discussed above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here I suggest making the terminology clearer: are these continuous-time densities/covariances or discrete-time covariances?
|
||
: The covariance associated with the gyroscope bias random walk. | ||
\end_layout | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
below the reference "Murray84book" does not render correctly
D_R_R(&G_measCov_Gt) = theta_H_biasOmega // | ||
* (wCov_updated / dt) // | ||
* (theta_H_biasOmega.transpose()); | ||
D_v_v(&G_measCov_Gt) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@varunagrawal : besides the order of the pre-integrated measurements, can you point out what changed with respect to my (terrible) writeup? I think you added a second-order term in the position and changed how the covariances are discretized. were there other bugs you fixed with respect to my writeup? (i.e., was my writeup wrong, or only the implementation? or both? :-) )
also: is the order attitude-position-velocity now also used in the standard IMU factor? or only the combined?
@@ -76,7 +76,7 @@ TEST(TestImuPreintegration, LoadedSimulationData) { | |||
imuPreintegratedParams->gyroscopeCovariance = I_3x3 * pow(gyrNoiseSigma, 2); | |||
imuPreintegratedParams->biasOmegaCovariance = I_3x3 * pow(gyrBiasRwSigma, 2); | |||
imuPreintegratedParams->integrationCovariance = I_3x3 * integrationCovariance; | |||
imuPreintegratedParams->biasAccOmegaInt = I_6x6 * biasAccOmegaInt; | |||
imuPreintegratedParams->biasAccOmegaInit = I_6x6 * biasAccOmegaInit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not there yet, I suggest adding a unit test on the block-wise implementation of G * cov * G'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will have to be an MCMC test similar to ImuFactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@varunagrawal : this is good to go to me, but do you have stats to show how it compares with the standard imu factor?
@lucacarlone that is going to have to be another PR since I will need to implement the |
This PR updates the
CombinedImuFactor
to compute the preintegration covariance as per the updated ImuFactor.pdf document.