summaryrefslogtreecommitdiff
path: root/src/feature.cpp
diff options
context:
space:
mode:
authorMartin Miller2017-03-19 14:15:33 -0500
committerMartin Miller2017-03-19 14:15:33 -0500
commiteb8abfc142fa6aada8057fbca57d1c909950416d (patch)
treeff84abdc2c923fa562c984db3a4c8d66ca91c468 /src/feature.cpp
parent72744081cd18a6a7d19b9c9840be0b20ad314008 (diff)
downloadrefslam-eb8abfc142fa6aada8057fbca57d1c909950416d.zip
refslam-eb8abfc142fa6aada8057fbca57d1c909950416d.tar.gz
Implement feature measurement prediction.
Used a slightly simplified expression to compute pib0. Replaced the Householder Transform with quaternion based reflection (untested).
Diffstat (limited to 'src/feature.cpp')
-rw-r--r--src/feature.cpp68
1 files changed, 67 insertions, 1 deletions
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<double,6,1>
-Feature::h ( )
+Feature::h ( const Vector3d &x, const Quaterniond &q )
{
Matrix<double,6,1> 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<double,3,9>
Feature::Fx ( )