From a1acd81deeb4b5ffcfd0d829279e203ed7630484 Mon Sep 17 00:00:00 2001
From: ARMAR-6 User <armar6@kit.edu>
Date: Thu, 24 Nov 2022 10:05:22 +0100
Subject: [PATCH] handling case when body frames are just not available yet

---
 .../AzureKinectPointCloudProvider.cpp               | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/source/VisionX/components/pointcloud_provider/AzureKinectPointCloudProvider/AzureKinectPointCloudProvider.cpp b/source/VisionX/components/pointcloud_provider/AzureKinectPointCloudProvider/AzureKinectPointCloudProvider.cpp
index 4477a9a44..ca62a5e8c 100644
--- a/source/VisionX/components/pointcloud_provider/AzureKinectPointCloudProvider/AzureKinectPointCloudProvider.cpp
+++ b/source/VisionX/components/pointcloud_provider/AzureKinectPointCloudProvider/AzureKinectPointCloudProvider.cpp
@@ -23,6 +23,7 @@
 
 
 #include "AzureKinectPointCloudProvider.h"
+#include "ArmarXCore/core/exceptions/LocalException.h"
 #include "ArmarXCore/core/logging/Logging.h"
 
 
@@ -653,7 +654,17 @@ namespace visionx
         while(true)
         {
 
-            k4abt::frame body_frame = bodyTracker.pop_result();
+            // body frames might just not be available.
+            const k4abt::frame body_frame = [&]() -> k4abt::frame{
+                try {
+                    auto result = bodyTracker.pop_result();
+                    return result;
+                } catch (...) {
+                    ARMARX_VERBOSE << deactivateSpam(1) << "Exception in body tracking publishing: " << armarx::GetHandledExceptionString();
+                    return {};
+                }
+            }();
+
             if (body_frame != nullptr)
             {
                 armarx::core::time::ScopedStopWatch sw{createSwCallback("publish body tracking result")};
-- 
GitLab