From b32ccb14315d8a6e05aaf42845f31c8f0d2a92d8 Mon Sep 17 00:00:00 2001
From: Mirko Waechter <mirko.waechter@kit.edu>
Date: Thu, 16 Aug 2018 16:24:17 +0200
Subject: [PATCH] robotstatecomponent will reject now timestamps that are >2
 secs newer than the newest available data

---
 .../RobotAPI/components/RobotState/RobotStateComponent.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/source/RobotAPI/components/RobotState/RobotStateComponent.cpp b/source/RobotAPI/components/RobotState/RobotStateComponent.cpp
index 4374e8b88..b2da65eda 100644
--- a/source/RobotAPI/components/RobotState/RobotStateComponent.cpp
+++ b/source/RobotAPI/components/RobotState/RobotStateComponent.cpp
@@ -272,6 +272,13 @@ namespace armarx
         }
         if (time > history.rbegin()->first)
         {
+            double maxOffset = 2000000;
+            if (time > history.rbegin()->first + maxOffset)
+            {
+                ARMARX_WARNING << deactivateSpam(1) << "Requested timestamp is substantially newer (>" << maxOffset << " usec) than newest available timestamp!\nrequested timestamp: "
+                               << IceUtil::Time::microSecondsDouble(time).toDateTime() << " newest timestamp: " << IceUtil::Time::microSecondsDouble(history.rbegin()->first).toDateTime();
+                return false;
+            }
             config = history.rbegin()->second;
         }
         else if (it == history.end())
-- 
GitLab