From eb8abfc142fa6aada8057fbca57d1c909950416d Mon Sep 17 00:00:00 2001 From: Martin Miller Date: Sun, 19 Mar 2017 14:15:33 -0500 Subject: Implement feature measurement prediction. Used a slightly simplified expression to compute pib0. Replaced the Householder Transform with quaternion based reflection (untested). --- src/feature.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'src/feature.cpp') diff --git a/src/feature.cpp b/src/feature.cpp index ad554a1..45e24e7 100644 --- a/src/feature.cpp +++ b/src/feature.cpp @@ -19,12 +19,78 @@ #include "feature.h" Matrix -Feature::h ( ) +Feature::h ( const Vector3d &x, const Quaterniond &q ) { Matrix h; + Vector3d xib, xib0; + Vector3d pib0; + + xib = p2x(X); + + // Predict initial view + xib0 = q0._transformVector(q._transformVector(xib) + x - xb0w); + pib0 = x2p(xib0); + + // Predict reflection view + Vector3d xpb, ppb; + Quaterniond qxpb, qrb; + const Quaterniond qrw(0,0,0,-1); // the reflecting plane in world frame + Quaterniond qxib(0,xib[0],xib[1],xib[2]); + + // Compute reflection plane in body frame + qrb = q.conjugate()*qrw; + // Reflect xib about qrb + qxpb = qrb*qxib*qrb; + xpb = qxpb.vec(); + ppb = x2p(xpb); + + h[0] = X[0]; + h[1] = X[1]; + h[2] = pib0[0]; + h[3] = pib0[1]; + h[4] = ppb[0]; + h[5] = ppb[1]; + return h; } /* ----- end of method Feature::h ----- */ +/* + *-------------------------------------------------------------------------------------- + * Class: Feature + * Method: Feature :: p2x + * Description: Returns x, the point p in inverse depth frame in the Cartesian + * frame. + *-------------------------------------------------------------------------------------- + */ +Vector3d +Feature::p2x ( const Vector3d &p ) +{ + Vector3d x; + x[0] = 1./p[2]; + x[1] = p[0]/p[2]; + x[2] = p[1]/p[2]; + return x; +} /* ----- end of method Feature::p2x ----- */ + +/* + *-------------------------------------------------------------------------------------- + * Class: Feature + * Method: Feature :: x2p + * Description: Returns p, the point x in the Cartesian body frame in the + * inverse depth frame. + *-------------------------------------------------------------------------------------- + */ +Vector3d +Feature::x2p ( const Vector3d &x ) +{ + Vector3d p; + p[0] = x[1]/x[0]; + p[1] = x[2]/x[0]; + p[2] = 1./x[0]; + return p; +} /* ----- end of method Feature::x2p ----- */ + + Matrix Feature::Fx ( ) -- cgit v1.1