From 5a34d14b9e01c11a5f1d1f859763a9c66b2f3c46 Mon Sep 17 00:00:00 2001
From: Mirko Waechter <mirko.waechter@kit.edu>
Date: Mon, 6 Jun 2016 12:43:38 +0200
Subject: [PATCH] added mutex call

---
 .../components/RobotState/RobotStateComponent.cpp         | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/source/RobotAPI/components/RobotState/RobotStateComponent.cpp b/source/RobotAPI/components/RobotState/RobotStateComponent.cpp
index ebbc4f01a..941097740 100644
--- a/source/RobotAPI/components/RobotState/RobotStateComponent.cpp
+++ b/source/RobotAPI/components/RobotState/RobotStateComponent.cpp
@@ -61,7 +61,10 @@ namespace armarx
     {
 
         historyLength = getProperty<int>("HistoryLength").getValue();
-        history.clear();
+        {
+            boost::unique_lock<SharedMutex> lock(historyMutex);
+            history.clear();
+        }
 
 
         relativeRobotFile = getProperty<std::string>("RobotFileName").getValue();
@@ -210,7 +213,6 @@ namespace armarx
         RobotStateConfig config;
         if (!interpolate(timestamp, config))
         {
-            ARMARX_WARNING << "Could not find or interpolate a robot state for time " << IceUtil::Time::microSeconds(timestamp).toDateTime();
             return NameValueMap();
         }
         return config.jointMap;
@@ -222,7 +224,6 @@ namespace armarx
         RobotStateConfig config;
         if (!interpolate(timestamp, config))
         {
-            ARMARX_WARNING << "Could not find or interpolate a robot state for time " << IceUtil::Time::microSeconds(timestamp).toDateTime();
             return RobotStateConfig();
         }
         return config;
@@ -242,6 +243,7 @@ namespace armarx
         }
         else if (it == history.end())
         {
+            ARMARX_WARNING << "Could not find or interpolate a robot state for time " << IceUtil::Time::microSeconds(time).toDateTime() << " - oldest available value: " << IceUtil::Time::microSeconds(history.begin()->first).toDateTime();
             return false;
         }
         else
-- 
GitLab