summaryrefslogtreecommitdiff
path: root/src/feature.cpp
diff options
context:
space:
mode:
authorMartin Miller2017-03-31 15:54:02 -0500
committerMartin Miller2017-03-31 15:54:02 -0500
commitf21a53aa32f9a005258b129c1e0ef5c7d71890df (patch)
tree9f138e467e54268f3319c942e04acab10e604044 /src/feature.cpp
parentb330172b4030340586307b46424e34ddd9d11160 (diff)
downloadrefslam-f21a53aa32f9a005258b129c1e0ef5c7d71890df.zip
refslam-f21a53aa32f9a005258b129c1e0ef5c7d71890df.tar.gz
Add 1-Point RANSAC.
1-Pt RANSAC is a method for detecting outlier measurements in the EKF framework. This algorithm is as described in Civera 2010.
Diffstat (limited to 'src/feature.cpp')
-rw-r--r--src/feature.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/feature.cpp b/src/feature.cpp
index 8b1ffe6..caa56f0 100644
--- a/src/feature.cpp
+++ b/src/feature.cpp
@@ -629,3 +629,59 @@ Feature::inFOV ( )
return rv;
} /* ----- end of method Feature::inFOV ----- */
+bool
+Feature::isInlier(const measurement_t &z, const Matrix<double,9,9> &Pxx,
+ const Matrix<double,9,3> &Pxy, const Matrix<double,3,3> &Pyy,
+ const Vector3d &pos, const Quaterniond &q, double thr)
+{
+ Matrix<double,Dynamic,Dynamic,0,6,6> s;
+ Matrix<double,Dynamic,1,0,6,1> hi, zi, y;
+ s = S(Pxx, Pxy, Pyy, pos, q);
+ hi = h(pos,q);
+ if (z.z_type==MONO) {
+ s = s.topLeftCorner<4,4>();
+ hi = hi.head<4>();
+ zi = measurement_vector(z.source);
+ } else {
+ zi = measurement_vector(z.source, z.reflection);
+ }
+ double Y;
+ y = zi-hi;
+ Y = y.transpose()*s.inverse()*y;
+
+ return (Y<thr) ? true : false;
+} /* ----- end of method Feature::isInlier ----- */
+
+bool
+Feature::isRansacInlier(const measurement_t &z, const Vector3d &pos,
+ const Quaterniond &q)
+{
+ Matrix<double,Dynamic,1,0,6,1> hi, zi, y;
+ hi = h(pos,q);
+ if (z.z_type==MONO) {
+ hi = hi.head<4>();
+ zi = measurement_vector(z.source);
+ } else {
+ zi = measurement_vector(z.source, z.reflection);
+ }
+ double Y;
+ y = zi-hi;
+ Y = y.transpose()*y;
+
+ return (Y<RANSAC_LI_THRESHOLD) ? true : false;
+}
+
+Vector3d
+Feature::asVector ( )
+{
+ return X;
+} /* ----- end of method Feature::asVector ----- */
+
+
+void
+Feature::asVector ( const Vector3d &m )
+{
+ X = m;
+ return ;
+} /* ----- end of method Feature::asVector ----- */
+