From f75279f62a3c8833170755cf8a803fdedf438b64 Mon Sep 17 00:00:00 2001
From: Fabian Paus <fabian.paus@kit.edu>
Date: Thu, 21 Apr 2022 10:46:35 +0200
Subject: [PATCH] Split RobotUnit.ice and NJointController.ice again

---
 .../NJointControllers/NJointController.cpp    |  8 +-
 .../NJointControllers/NJointControllerBase.h  |  2 +-
 .../units/RobotUnit/NJointController.ice      | 77 ++++++++++++++++++-
 .../NJointTaskSpaceDMPController.ice          |  2 +
 .../units/RobotUnit/RobotUnitInterface.ice    | 70 +----------------
 5 files changed, 83 insertions(+), 76 deletions(-)

diff --git a/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointController.cpp b/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointController.cpp
index 5d34536c6..a127273c7 100644
--- a/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointController.cpp
+++ b/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointController.cpp
@@ -130,10 +130,10 @@ namespace armarx
         return ds;
     }
 
-    RobotUnitInterfacePrx NJointControllerBase::getRobotUnit(const Ice::Current&) const
-    {
-        return RobotUnitInterfacePrx::uncheckedCast(robotUnit.getProxy(-1));
-    }
+//    RobotUnitInterfacePrx NJointControllerBase::getRobotUnit(const Ice::Current&) const
+//    {
+//        return RobotUnitInterfacePrx::uncheckedCast(robotUnit.getProxy(-1));
+//    }
 
     void NJointControllerBase::activateController(const Ice::Current&)
     {
diff --git a/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointControllerBase.h b/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointControllerBase.h
index cad191935..81afaef0d 100644
--- a/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointControllerBase.h
+++ b/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointControllerBase.h
@@ -761,7 +761,7 @@ namespace armarx
         NJointControllerDescription getControllerDescription(const Ice::Current& = Ice::emptyCurrent) const final override;
         NJointControllerStatus getControllerStatus(const Ice::Current& = Ice::emptyCurrent) const final override;
         NJointControllerDescriptionWithStatus getControllerDescriptionWithStatus(const Ice::Current& = Ice::emptyCurrent) const final override;
-        RobotUnitInterfacePrx getRobotUnit(const Ice::Current& = Ice::emptyCurrent) const final override;
+        //RobotUnitInterfacePrx getRobotUnit(const Ice::Current& = Ice::emptyCurrent) const final override;
 
         void activateController(const Ice::Current& = Ice::emptyCurrent) final override;
         void deactivateController(const Ice::Current& = Ice::emptyCurrent) final override;
diff --git a/source/RobotAPI/interface/units/RobotUnit/NJointController.ice b/source/RobotAPI/interface/units/RobotUnit/NJointController.ice
index 7e07c41de..f10564670 100644
--- a/source/RobotAPI/interface/units/RobotUnit/NJointController.ice
+++ b/source/RobotAPI/interface/units/RobotUnit/NJointController.ice
@@ -22,7 +22,80 @@
 
 #pragma once
 
+#include <ArmarXGui/interface/WidgetDescription.ice>
 
-#include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.ice>
+#include <ArmarXCore/interface/core/UserException.ice>
+#include <ArmarXCore/interface/core/BasicTypes.ice>
+
+module armarx
+{
+    interface NJointControllerInterface;
+
+
+    module RobotUnitControllerNames
+    {
+        const string NJointTrajectoryController = "NJointTrajectoryController";
+        const string NJointGlobalTCPController = "NJointGlobalTCPController"; /*@@@TODO: move NJointGlobalTCPController to RobotAPI */
+        const string NJointTCPController = "NJointTCPController";
+        const string NJointCartesianVelocityController = "NJointCartesianVelocityController";
+    };
+
+
+    class NJointControllerConfig {};
+
+    struct NJointControllerDescription
+    {
+        string instanceName;
+        string className;
+        NJointControllerInterface* controller;
+        StringStringDictionary controlModeAssignment;
+        bool deletable;
+        bool internal;
+    };
+    sequence<NJointControllerDescription> NJointControllerDescriptionSeq;
+
+    struct NJointControllerStatus
+    {
+        string instanceName;
+        bool active = false;
+        bool requested = false;
+        bool error = false;
+        long timestampUSec = 0;
+    };
+    sequence<NJointControllerStatus> NJointControllerStatusSeq;
+
+    struct NJointControllerDescriptionWithStatus
+    {
+        NJointControllerStatus status;
+        NJointControllerDescription description;
+    };
+    sequence<NJointControllerDescriptionWithStatus> NJointControllerDescriptionWithStatusSeq;
+
+    interface NJointControllerInterface
+    {
+        ["cpp:const"] idempotent string getClassName();
+        ["cpp:const"] idempotent string getInstanceName();
+        ["cpp:const"] idempotent StringStringDictionary getControlDeviceUsedControlModeMap();
+        ["cpp:const"] idempotent bool isControllerActive();
+        ["cpp:const"] idempotent bool isControllerRequested();
+        ["cpp:const"] idempotent bool isDeletable();
+        ["cpp:const"] idempotent bool hasControllerError();
+        ["cpp:const"] idempotent NJointControllerStatus getControllerStatus();
+        ["cpp:const"] idempotent NJointControllerDescription getControllerDescription();
+        ["cpp:const"] idempotent NJointControllerDescriptionWithStatus getControllerDescriptionWithStatus();
+        // This method is not used by anybody and just produces cyclic dependencies
+        // If you were able to create/get an NJointController, you know the RobotUnit already.
+        //["cpp:const"] idempotent RobotUnitInterface* getRobotUnit();
+
+        void activateController();
+        void deactivateController();
+        void deleteController() throws LogicError;
+        void deactivateAndDeleteController() throws LogicError;
+
+        ["cpp:const"] idempotent WidgetDescription::StringWidgetDictionary getFunctionDescriptions();
+        void callDescribedFunction(string fuinctionName, StringVariantBaseMap values) throws InvalidArgumentException;
+    };
+
+    dictionary<string, NJointControllerInterface*> StringNJointControllerPrxDictionary;
+};
 
-//see RobotUnitInterface.ice (zeroc broke forward declarations)
diff --git a/source/RobotAPI/interface/units/RobotUnit/NJointTaskSpaceDMPController.ice b/source/RobotAPI/interface/units/RobotUnit/NJointTaskSpaceDMPController.ice
index 84614f0d5..178edf202 100644
--- a/source/RobotAPI/interface/units/RobotUnit/NJointTaskSpaceDMPController.ice
+++ b/source/RobotAPI/interface/units/RobotUnit/NJointTaskSpaceDMPController.ice
@@ -25,6 +25,8 @@
 #include <RobotAPI/interface/units/RobotUnit/NJointController.ice>
 #include <RobotAPI/interface/core/Trajectory.ice>
 
+#include <ArmarXCore/interface/serialization/Eigen.ice>
+
 module armarx
 {
     module NJointTaskSpaceDMPControllerMode
diff --git a/source/RobotAPI/interface/units/RobotUnit/RobotUnitInterface.ice b/source/RobotAPI/interface/units/RobotUnit/RobotUnitInterface.ice
index e6c33056b..f59b43019 100644
--- a/source/RobotAPI/interface/units/RobotUnit/RobotUnitInterface.ice
+++ b/source/RobotAPI/interface/units/RobotUnit/RobotUnitInterface.ice
@@ -41,82 +41,14 @@
 
 #include <RobotAPI/interface/visualization/DebugDrawerInterface.ice>
 #include <RobotAPI/interface/components/RobotHealthInterface.ice>
+#include <RobotAPI/interface/units/RobotUnit/NJointController.ice>
 
 #include <ArmarXCore/interface/core/BasicTypes.ice>
 #include <ArmarXCore/interface/core/UserException.ice>
 #include <ArmarXGui/interface/WidgetDescription.ice>
 
 //NJointController
-module armarx
-{
-    interface NJointControllerInterface;
-    interface RobotUnitInterface;
-
-
-    module RobotUnitControllerNames
-    {
-        const string NJointTrajectoryController = "NJointTrajectoryController";
-        const string NJointGlobalTCPController = "NJointGlobalTCPController"; /*@@@TODO: move NJointGlobalTCPController to RobotAPI */
-        const string NJointTCPController = "NJointTCPController";
-        const string NJointCartesianVelocityController = "NJointCartesianVelocityController";
-    };
-
-
-    class NJointControllerConfig {};
-
-    struct NJointControllerDescription
-    {
-        string instanceName;
-        string className;
-        NJointControllerInterface* controller;
-        StringStringDictionary controlModeAssignment;
-        bool deletable;
-        bool internal;
-    };
-    sequence<NJointControllerDescription> NJointControllerDescriptionSeq;
-
-    struct NJointControllerStatus
-    {
-        string instanceName;
-        bool active = false;
-        bool requested = false;
-        bool error = false;
-        long timestampUSec = 0;
-    };
-    sequence<NJointControllerStatus> NJointControllerStatusSeq;
-
-    struct NJointControllerDescriptionWithStatus
-    {
-        NJointControllerStatus status;
-        NJointControllerDescription description;
-    };
-    sequence<NJointControllerDescriptionWithStatus> NJointControllerDescriptionWithStatusSeq;
-
-    interface NJointControllerInterface
-    {
-        ["cpp:const"] idempotent string getClassName();
-        ["cpp:const"] idempotent string getInstanceName();
-        ["cpp:const"] idempotent StringStringDictionary getControlDeviceUsedControlModeMap();
-        ["cpp:const"] idempotent bool isControllerActive();
-        ["cpp:const"] idempotent bool isControllerRequested();
-        ["cpp:const"] idempotent bool isDeletable();
-        ["cpp:const"] idempotent bool hasControllerError();
-        ["cpp:const"] idempotent NJointControllerStatus getControllerStatus();
-        ["cpp:const"] idempotent NJointControllerDescription getControllerDescription();
-        ["cpp:const"] idempotent NJointControllerDescriptionWithStatus getControllerDescriptionWithStatus();
-        ["cpp:const"] idempotent RobotUnitInterface* getRobotUnit();
-
-        void activateController();
-        void deactivateController();
-        void deleteController() throws LogicError;
-        void deactivateAndDeleteController() throws LogicError;
-
-        ["cpp:const"] idempotent WidgetDescription::StringWidgetDictionary getFunctionDescriptions();
-        void callDescribedFunction(string fuinctionName, StringVariantBaseMap values) throws InvalidArgumentException;
-    };
 
-    dictionary<string, NJointControllerInterface*> StringNJointControllerPrxDictionary;
-};
 
 //RobotUnit Utility types - ControlDevice
 module armarx
-- 
GitLab