summaryrefslogtreecommitdiff
path: root/src/state.cpp
diff options
context:
space:
mode:
authorMartin Miller2017-04-11 10:57:04 -0500
committerMartin Miller2017-04-11 10:57:04 -0500
commit1c543489862cd0bf9c559cee6575baf20f84b2d0 (patch)
treed968bf97d9d6a6bd444fd97b24054f720456c84f /src/state.cpp
parent16972c736994fa49b04d1e967516278660e4be2d (diff)
downloadrefslam-1c543489862cd0bf9c559cee6575baf20f84b2d0.zip
refslam-1c543489862cd0bf9c559cee6575baf20f84b2d0.tar.gz
Remove features after 5 timesteps without measurements
Diffstat (limited to 'src/state.cpp')
-rw-r--r--src/state.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/state.cpp b/src/state.cpp
index 055a3d1..10b3ad3 100644
--- a/src/state.cpp
+++ b/src/state.cpp
@@ -1164,6 +1164,26 @@ State::doMeasurements ( vector<measurement_t> &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()<MINFEATURES) {