Skip to content
Snippets Groups Projects
Commit c85eac75 authored by Joana Plewnia's avatar Joana Plewnia
Browse files

fix for recording with LTM when dealing with broken "sent"-timestamps, like in...

fix for recording with LTM when dealing with broken "sent"-timestamps, like in Proprioception of RobotState Memory.
In this case the frequency filter takes the "arrived" timestamp, as this is normally not broken.
parent de49db15
No related branches found
No related tags found
2 merge requests!469Loading the last n Snapshots from LTM on Startup,!468Draft: fix for recording with LTM when dealing with broken "sent"-timestamps
Pipeline #20738 passed
......@@ -23,7 +23,13 @@ namespace armarx::armem::server::ltm::processor::filter
ARMARX_INFO << "First time this entity is saved";
auto firstIndex = e.getInstanceIndices()[0];
auto firstInsance = e.getInstance(firstIndex);
auto lastT = firstInsance.metadata().sentTime.toMilliSecondsSinceEpoch();
if (lastT < 946688400000) {
// we assume the timestamp does not make sense if it is older than the year 2000
lastT = firstInsance.metadata().arrivedTime.toMilliSecondsSinceEpoch(); //then we take the time it arrived.
ARMARX_DEBUG << "sentTime does not make sense. Fix: taking arrivedTime";
}
//for statistics sake:
auto end = std::chrono::high_resolution_clock::now();
stats.end_time = end;
......@@ -39,11 +45,24 @@ namespace armarx::armem::server::ltm::processor::filter
// check if any one of the instances for this snapshot were sent in the last x
// milliseconds since a snapshot was accepted last for this entity:
e.forEachInstance([this, &instances_accepted, &current, &lastTime](armem::wm::EntityInstance& i){
int difference = std::abs(i.metadata().sentTime.toMilliSecondsSinceEpoch() - lastTime);
if(difference > this->maxDifference){ //at least one instance is older than the last saved instance
instances_accepted = true;
current = i.metadata().sentTime.toMilliSecondsSinceEpoch();
bool sentTimeOkay = true;
if (i.metadata().sentTime.toMilliSecondsSinceEpoch() < 946688400000){
sentTimeOkay = false;
}
if(sentTimeOkay){
int difference = std::abs(i.metadata().sentTime.toMilliSecondsSinceEpoch() - lastTime);
if(difference > this->maxDifference){ //at least one instance is older than the last saved instance
instances_accepted = true;
current = i.metadata().sentTime.toMilliSecondsSinceEpoch();
}
} else {
int difference = std::abs(i.metadata().arrivedTime.toMilliSecondsSinceEpoch() - lastTime);
if(difference > this->maxDifference){ //at least one instance is older than the last saved instance
instances_accepted = true;
current = i.metadata().arrivedTime.toMilliSecondsSinceEpoch();
}
}
});
if(instances_accepted){ //if one of the instances was accepted the time when an
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment