From 1c543489862cd0bf9c559cee6575baf20f84b2d0 Mon Sep 17 00:00:00 2001 From: Martin Miller Date: Tue, 11 Apr 2017 10:57:04 -0500 Subject: Remove features after 5 timesteps without measurements --- src/feature.cpp | 16 ++++++++++++++++ src/feature.h | 3 +++ src/state.cpp | 20 ++++++++++++++++++++ src/state.h | 2 +- 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/feature.cpp b/src/feature.cpp index fbb1376..84575d1 100644 --- a/src/feature.cpp +++ b/src/feature.cpp @@ -36,6 +36,7 @@ Feature::Feature ( int id, const Vector3d &xs, const Vector3d &xr, xb0w = xbw; q0 = q; _patch = p; + lastseen = 0; } /* ----- end of method Feature::Feature (constructor) ----- */ /* @@ -61,6 +62,7 @@ Feature::Feature ( int id, const Vector3d &xs, const Vector3d &xbw, xb0w = xbw; q0 = q; _patch = p; + lastseen = 0; } @@ -1023,6 +1025,7 @@ Feature::sane ( ) void Feature::dx ( const Vector3d &del ) { + lastseen += 1; X += del; return ; } /* ----- end of method Feature::dx ----- */ @@ -1131,3 +1134,16 @@ Feature::reflectedPatch( const Camera &cam, const Quaterniond &q1 ) return cam.reflectPatch(_patch, q0, q1); } +void +Feature::seen ( ) +{ + lastseen = 0; + return ; +} /* ----- end of method Feature::seen ----- */ + +bool +Feature::since ( int N ) const +{ + return (lastseen &z, Vision &viz, kalmanUpdate(h,S,z,q); #endif #endif + // Reset lastseen counter + for (auto i=z.begin(); i!=z.end(); ++i) { + if (i->z_type==HEIGHT) continue; + Feature *ft = featureById(i->id); + if (ft==NULL) { + cerr << "id: " << i->id << "is null." << endl; + } else { + ft->seen(); + } + } + + // Remove features that haven't been measured recently + auto i=features.begin(); + while (i!=features.end()) { + if ((*i)->since(5)) { + ++i; + } else { + i=removeFeature(i,false); + } + } // Initialize new features if (features.size()