From 02aa96337c3bbaa19fa0747eaddf24b700184807 Mon Sep 17 00:00:00 2001
From: Fabian Reister <fabian.reister@kit.edu>
Date: Thu, 20 May 2021 14:17:00 +0200
Subject: [PATCH] object memory: added attachments segment

---
 .../ArticulatedObjectLocalizerExample.cfg     |  8 ++++++++
 .../server/ObjectMemory/ObjectMemory.cpp      | 19 ++++++++++++-------
 .../armem/server/ObjectMemory/ObjectMemory.h  |  2 ++
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/scenarios/ArMemObjectMemory/config/ArticulatedObjectLocalizerExample.cfg b/scenarios/ArMemObjectMemory/config/ArticulatedObjectLocalizerExample.cfg
index 50dce2f4a..82769e0f2 100644
--- a/scenarios/ArMemObjectMemory/config/ArticulatedObjectLocalizerExample.cfg
+++ b/scenarios/ArMemObjectMemory/config/ArticulatedObjectLocalizerExample.cfg
@@ -102,6 +102,14 @@ ArmarX.ArticulatedObjectLocalizerExample.mem.obj.articulated.ProviderName = Exam
 # ArmarX.ArticulatedObjectLocalizerExample.tpc.sub.MemoryListener = MemoryUpdates
 
 
+# ArmarX.ArticulatedObjectLocalizerExample.updateFrequency:  Memory update frequency (write).
+#  Attributes:
+#  - Default:            25
+#  - Case sensitivity:   yes
+#  - Required:           no
+# ArmarX.ArticulatedObjectLocalizerExample.updateFrequency = 25
+
+
 # ArmarX.CachePath:  Path for cache files. If relative path AND env. variable ARMARX_USER_CONFIG_DIR is set, the cache path will be made relative to ARMARX_USER_CONFIG_DIR. Otherwise if relative it will be relative to the default ArmarX config dir (${HOME}/.armarx)
 #  Attributes:
 #  - Default:            mongo/.cache
diff --git a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp
index 837fcbcf8..b6d997f68 100644
--- a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp
+++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp
@@ -57,6 +57,8 @@ namespace armarx::armem::server::obj
         articulatedObjectInstanceSegment.defineProperties(defs, prefix + "articulated.inst.");
         articulatedObjectClassSegment.defineProperties(defs, prefix + "articulated.cls.");
 
+        attachmentSegment.defineProperties(defs, prefix + "attachments.");
+
         return defs;
     }
 
@@ -69,7 +71,9 @@ namespace armarx::armem::server::obj
         articulatedObjectClassSegment(server::ComponentPluginUser::iceMemory,
                                       server::ComponentPluginUser::workingMemoryMutex),
         articulatedObjectInstanceSegment(server::ComponentPluginUser::iceMemory,
-                                         server::ComponentPluginUser::workingMemoryMutex)
+                                         server::ComponentPluginUser::workingMemoryMutex),
+        attachmentSegment(server::ComponentPluginUser::iceMemory,
+                          server::ComponentPluginUser::workingMemoryMutex)
     {
     }
 
@@ -120,6 +124,10 @@ namespace armarx::armem::server::obj
             articulatedObjectInstanceSegment.init();
         });
 
+        initSegmentWithCatch("attachment", [&]()
+        {
+            attachmentSegment.init();
+        });
 
     }
 
@@ -155,12 +163,9 @@ namespace armarx::armem::server::obj
             ArVizComponentPluginUser::getArvizClient()
         );
 
-
-        // {
-        //     std::lock_guard g(server::ComponentPluginUser::workingMemoryMutex);
-        //     // server::ComponentPluginUser::workingMemory.addCoreSegment("ArticulatedObjectInstance"); // TODO , arondto::::toInitialAronType());
-        //     server::ComponentPluginUser::workingMemory.addCoreSegment("ArticulatedObjectClass"); // TODO , arondto::::toInitialAronType());
-        // }
+        attachmentSegment.connect(
+            ArVizComponentPluginUser::getArvizClient()
+        );
 
         createRemoteGuiTab();
         RemoteGui_startRunningTask();
diff --git a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h
index f42860d88..2dfd668d1 100644
--- a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h
+++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h
@@ -40,6 +40,7 @@
 #include <RobotAPI/libraries/armem_objects/server/instance/SegmentAdapter.h>
 #include <RobotAPI/libraries/armem_objects/server/articulated_object_instance/Segment.h>
 #include <RobotAPI/libraries/armem_objects/server/articulated_object_class/Segment.h>
+#include <RobotAPI/libraries/armem_objects/server/attachments/Segment.h>
 
 
 #define ICE_CURRENT_ARG const Ice::Current& = Ice::emptyCurrent
@@ -112,6 +113,7 @@ namespace armarx::armem::server::obj
 
         articulated_object_class::Segment articulatedObjectClassSegment;
         articulated_object_instance::Segment articulatedObjectInstanceSegment;
+        attachments::Segment attachmentSegment;
 
         // associations::Segment associationsSegment;
 
-- 
GitLab