From b6b982bfcb49f2842502d5ea047028a2dc62e713 Mon Sep 17 00:00:00 2001
From: Fabian Paus <fabian.paus@kit.edu>
Date: Sat, 18 Jan 2020 11:52:10 +0100
Subject: [PATCH] ArViz: Bug fixes - Stop recording task only if it was started
 - Set revision in pullUpdatesSince in return value - Disable joint value
 propagation in robot visualization

---
 source/RobotAPI/components/ArViz/ArVizStorage.cpp      | 10 +++++++---
 .../components/ArViz/Coin/VisualizationRobot.cpp       |  3 +++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/source/RobotAPI/components/ArViz/ArVizStorage.cpp b/source/RobotAPI/components/ArViz/ArVizStorage.cpp
index 1dc7d7297..e5d8c926a 100644
--- a/source/RobotAPI/components/ArViz/ArVizStorage.cpp
+++ b/source/RobotAPI/components/ArViz/ArVizStorage.cpp
@@ -92,8 +92,11 @@ void ArVizStorage::onConnectComponent()
 
 void ArVizStorage::onDisconnectComponent()
 {
-    recordingTask->stop();
-    recordingTask = nullptr;
+    if (recordingTask)
+    {
+        recordingTask->stop();
+        recordingTask = nullptr;
+    }
 }
 
 
@@ -171,9 +174,10 @@ viz::data::LayerUpdates armarx::ArVizStorage::pullUpdatesSince(Ice::Long revisio
     result.updates.reserve(currentState.size());
     for (auto& layer : currentState)
     {
-        if (revision < layer.revision)
+        if (layer.revision > revision)
         {
             result.updates.push_back(layer.update);
+            result.revision = std::max(result.revision, layer.revision);
         }
     }
 
diff --git a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp
index e5b070ec0..7de0d53c8 100644
--- a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp
+++ b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp
@@ -49,6 +49,9 @@ namespace armarx::viz::coin
                 ARMARX_INFO << "Loading robot from " << fullFilename;
                 result = VirtualRobot::RobotIO::loadRobot(fullFilename, loadMode);
                 result->setThreadsafe(false);
+                // Do we want to propagate joint values? Probably not...
+                // Closing the hand on the real robot could be implemented on another level
+                result->setPropagatingJointValuesEnabled(false);
             }
             catch (std::exception const& ex)
             {
-- 
GitLab