25 #define TIE(R,t,v,x) const Rot3& R = (x).R_;const Point3& t = (x).t_;const Velocity3& v = (x).v_; 32 *H1 << I_3x3, Z_3x3, Z_3x3;
43 *H1 << I_3x3, Z_3x3, Z_3x3, I_3x3, Z_3x3, Z_3x3;
52 *H << I_3x3, Z_3x3, Z_3x3;
59 *H << Z_3x3,
R(), Z_3x3;
66 *H << Z_3x3, Z_3x3,
R();
77 *H << D_bv_nRb, Z_3x3, I_3x3;
83 Matrix3
R = this->
R();
85 T <<
R, Z_3x3,
t(), Z_3x3,
R,
v(), Vector6::Zero().transpose(), 1.0;
91 os <<
"R: " << state.
attitude() <<
"\n";
92 os <<
"p: " << state.
position().transpose() <<
"\n";
93 os <<
"v: " << state.
velocity().transpose();
99 cout << (s.empty() ? s : s +
" ") << *
this << endl;
111 TIE(
nRb, n_t, n_v, *
this);
112 Matrix3 D_bRc_xi, D_R_nRb, D_t_nRb, D_v_nRb;
114 const Rot3 nRc =
nRb.compose(bRc, H1 ? &D_R_nRb : 0);
115 const Point3 t = n_t +
nRb.rotate(dP(xi), H1 ? &D_t_nRb : 0);
116 const Point3 v = n_v +
nRb.rotate(dV(xi), H1 ? &D_v_nRb : 0);
118 *H1 << D_R_nRb, Z_3x3, Z_3x3,
127 *H2 << D_bRc_xi, Z_3x3, Z_3x3,
137 Matrix3 D_dR_R, D_dt_R, D_dv_R;
140 const Vector dV = R_.unrotate(g.
v_ - v_, H1 ? &D_dv_R : 0);
144 xi << Rot3::Logmap(dR, (H1 || H2) ? &D_xi_R : 0), dP, dV;
146 *H1 << D_xi_R * D_dR_R, Z_3x3, Z_3x3,
147 D_dt_R, -I_3x3, Z_3x3,
148 D_dv_R, Z_3x3, -I_3x3;
151 *H2 << D_xi_R, Z_3x3, Z_3x3,
152 Z_3x3, dR.
matrix(), Z_3x3,
153 Z_3x3, Z_3x3, dR.
matrix();
160 #define D_R_R(H) (H)->block<3,3>(0,0) 161 #define D_R_t(H) (H)->block<3,3>(0,3) 162 #define D_R_v(H) (H)->block<3,3>(0,6) 163 #define D_t_R(H) (H)->block<3,3>(3,0) 164 #define D_t_t(H) (H)->block<3,3>(3,3) 165 #define D_t_v(H) (H)->block<3,3>(3,6) 166 #define D_v_R(H) (H)->block<3,3>(6,0) 167 #define D_v_t(H) (H)->block<3,3>(6,3) 168 #define D_v_v(H) (H)->block<3,3>(6,6) 176 Matrix39 D_xiP_state;
178 double dt22 = 0.5 * dt *
dt;
181 dR(xi) << dt * b_omega;
182 dP(xi) << dt * b_v + dt22 * b_acceleration;
183 dV(xi) << dt * b_acceleration;
187 NavState newState = retract(xi, F, G1 || G2 ? &D_newState_xi : 0);
192 F->middleRows<3>(3) += dt *
D_t_t(F) * D_xiP_state;
201 *G1 = D_newState_xi.middleCols<3>(3) * dt22
202 + D_newState_xi.rightCols<3>() *
dt;
209 *G2 = D_newState_xi.leftCols<3>() * dt;
217 TIE(
nRb, n_t, n_v, *
this);
218 const double dt2 = dt *
dt;
219 const Vector3 omega_cross_vel = omega.cross(n_v);
223 Matrix3 D_dR_R, D_dP_R, D_dV_R, D_body_nav;
224 dR(n_xi) << ((-
dt) * omega);
225 dP(n_xi) << ((-dt2) * omega_cross_vel);
226 dV(n_xi) << ((-2.0 *
dt) * omega_cross_vel);
228 const Vector3 omega_cross2_t = omega.cross(omega.cross(n_t));
229 dP(n_xi) -= (0.5 * dt2) * omega_cross2_t;
230 dV(n_xi) -= dt * omega_cross2_t;
234 xi <<
nRb.unrotate(dR(n_xi), H ? &D_dR_R : 0, H ? &D_body_nav : 0),
235 nRb.unrotate(dP(n_xi), H ? &D_dP_R : 0),
236 nRb.unrotate(dV(n_xi), H ? &D_dV_R : 0);
241 const Matrix3 D_cross_state = Omega *
R();
244 D_t_v(H) << D_body_nav * (-dt2) * D_cross_state;
246 D_v_v(H) << D_body_nav * (-2.0 *
dt) * D_cross_state;
249 const Matrix3 D_cross2_state = Omega * D_cross_state;
250 D_t_t(H) -= D_body_nav * (0.5 * dt2) * D_cross2_state;
251 D_v_t(H) -= D_body_nav * dt * D_cross2_state;
258 Vector9 NavState::correctPIM(
const Vector9& pim,
double dt,
264 const double dt22 = 0.5 * dt *
dt;
267 Matrix3 D_dP_Ri1, D_dP_Ri2, D_dP_nv, D_dV_Ri;
270 + dt * nRb.
unrotate(n_v, H1 ? &D_dP_Ri1 : 0, H2 ? &D_dP_nv : 0)
271 + dt22 * nRb.
unrotate(n_gravity, H1 ? &D_dP_Ri2 : 0);
272 dV(xi) = dV(pim) + dt * nRb.
unrotate(n_gravity, H1 ? &D_dV_Ri : 0);
275 xi +=
coriolis(dt, *omegaCoriolis, use2ndOrderCoriolis, H1);
279 Matrix3 Ri = nRb.
matrix();
284 D_t_R(H1) += dt * D_dP_Ri1 + dt22 * D_dP_Ri2;
285 D_t_v(H1) += dt * D_dP_nv * Ri;
286 D_v_R(H1) += dt * D_dV_Ri;
void print(const Matrix &A, const string &s, ostream &stream)
static const Velocity3 vel(0.4, 0.5, 0.6)
Vector3 Velocity3
Velocity is currently typedef'd to Vector3.
Rot2 R(Rot2::fromAngle(0.1))
Point3 unrotate(const Point3 &p, OptionalJacobian< 3, 3 > H1=boost::none, OptionalJacobian< 3, 3 > H2=boost::none) const
rotate point from world to rotated frame
Pose2_ Expmap(const Vector3_ &xi)
Point3 t_
position n_t, in nav frame
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
boost::function< Vector9(const NavState &, const bool &)> coriolis
void g(const string &key, int i)
Rot3 R_
Rotation nRb, rotates points/velocities in body to points/velocities in nav.
Velocity3 v_
velocity n_v in nav frame
static const Pose3 pose(Rot3(Vector3(1,-1,-1).asDiagonal()), Point3(0, 0, 0.5))
ostream & operator<<(ostream &os, const NavState &state)
Eigen::Triplet< double > T
Navigation state composing of attitude, position, and velocity.
Velocity3 velocity(const NavState &X, OptionalJacobian< 3, 9 > H)
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
Matrix3 transpose() const
const Velocity3 & velocity(OptionalJacobian< 3, 9 > H=boost::none) const
Rot3 attitude(const NavState &X, OptionalJacobian< 3, 9 > H)
Matrix3 skewSymmetric(double wx, double wy, double wz)
ofstream os("timeSchurFactors.csv")
const Point3 & position(OptionalJacobian< 3, 9 > H=boost::none) const
Class between(const Class &g) const
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Point3 position(const NavState &X, OptionalJacobian< 3, 9 > H)
Vector3 bodyVelocity(const Pose3 &w_t_b, const Vector3 &vec_w, OptionalJacobian< 3, 6 > Hpose=boost::none, OptionalJacobian< 3, 3 > Hvel=boost::none)
const Rot3 & rotation(OptionalJacobian< 3, 6 > Hself=boost::none) const
get rotation
const Rot3 & attitude(OptionalJacobian< 3, 9 > H=boost::none) const