-
Notifications
You must be signed in to change notification settings - Fork 920
Use doublecross instead of cross(Cross(a, b)) in NavState #2287
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -444,23 +444,35 @@ Vector9 NavState::coriolis(double dt, const Vector3& omega, bool secondOrder, | |
| const double dt2 = dt * dt; | ||
| const Vector3 omega_cross_vel = omega.cross(n_v); | ||
|
|
||
| // Get perturbations in nav frame | ||
| Vector9 n_xi, xi; | ||
| Matrix3 D_dR_R, D_dP_R, D_dV_R, D_body_nav; | ||
| // Because our navigation frames are placed on a spinning Earth, we experience two apparent forces on our inertials | ||
| // Let Omega be the Earth's rotation rate in the navigation frame | ||
| // Coriolis acceleration = -2 * (omega X n_v) | ||
| // Centrifugal acceleration (secondOrder) = -omega X (omega X n_t) | ||
| // We would also experience a rotation of (omega*dt) over time - so, counteract by compensating rotation by (-omega * dt) | ||
| // Integrate centrifugal & coriolis accelerations to yield position, velocity perturbations | ||
|
|
||
| Vector9 n_xi; | ||
| // Coriolis (first order) acceleration corrections | ||
| dR(n_xi) << ((-dt) * omega); | ||
| dP(n_xi) << ((-dt2) * omega_cross_vel); // NOTE(luca): we got rid of the 2 wrt INS paper | ||
| dV(n_xi) << ((-2.0 * dt) * omega_cross_vel); | ||
|
|
||
| // Centrifugal (second order) acceleration corrections | ||
| Matrix3 H2_wrt_t; // To store Jacobian (if needed/desired) | ||
|
||
| if (secondOrder) { | ||
| const Vector3 omega_cross2_t = omega.cross(omega.cross(n_t)); | ||
| const Vector3 omega_cross2_t = doubleCross(omega, n_t, nullptr, H ? &H2_wrt_t : nullptr); | ||
| dP(n_xi) -= (0.5 * dt2) * omega_cross2_t; | ||
| dV(n_xi) -= dt * omega_cross2_t; | ||
| } | ||
|
|
||
| // Transform n_xi into the body frame | ||
| xi << nRb.unrotate(dR(n_xi), H ? &D_dR_R : 0, H ? &D_body_nav : 0), | ||
| nRb.unrotate(dP(n_xi), H ? &D_dP_R : 0), | ||
| nRb.unrotate(dV(n_xi), H ? &D_dV_R : 0); | ||
| // Transform correction from navigation frame -> body frame and get Jacobians | ||
| Vector9 xi; | ||
| Matrix3 D_dR_R, D_dP_R, D_dV_R, D_body_nav; | ||
|
||
| dR(xi) = nRb.unrotate(dR(n_xi), H ? &D_dR_R : 0, H ? &D_body_nav : 0); | ||
| dP(xi) = nRb.unrotate(dP(n_xi), H ? &D_dP_R : 0); | ||
| dV(xi) = nRb.unrotate(dV(n_xi), H ? &D_dV_R : 0); | ||
|
|
||
| // Assemble Jacobians | ||
dellaert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (H) { | ||
| H->setZero(); | ||
| const Matrix3 Omega = skewSymmetric(omega); | ||
|
|
@@ -472,9 +484,8 @@ Vector9 NavState::coriolis(double dt, const Vector3& omega, bool secondOrder, | |
| D_v_v(H) << D_body_nav * (-2.0 * dt) * D_cross_state; | ||
| D_v_R(H) << D_dV_R; | ||
| if (secondOrder) { | ||
| const Matrix3 D_cross2_state = Omega * D_cross_state; | ||
| D_t_t(H) -= D_body_nav * (0.5 * dt2) * D_cross2_state; | ||
| D_v_t(H) -= D_body_nav * dt * D_cross2_state; | ||
| D_t_t(H) -= (0.5 * dt2) * D_body_nav * (H2_wrt_t * R()); | ||
|
||
| D_v_t(H) -= dt * D_body_nav * (H2_wrt_t * R()); | ||
|
||
| } | ||
| } | ||
| return xi; | ||
|
|
||
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.
Maybe move this up before sig