From fe49a3ea195237ebdd78ea263e4e3350caf1e05f Mon Sep 17 00:00:00 2001
From: Fabian Reister <fabian.reister@kit.edu>
Date: Wed, 4 May 2022 18:38:32 +0200
Subject: [PATCH] implementing additional events

---
 source/armarx/navigation/core/aron/Events.xml | 15 +++++++++
 .../navigation/core/aron_conversions.cpp      | 31 +++++++++++++++++++
 .../armarx/navigation/core/aron_conversions.h | 16 ++++++++--
 .../memory/client/events/Writer.cpp           | 26 +++++++++++++---
 .../navigation/memory/client/events/Writer.h  |  6 ++--
 .../event_publishing/MemoryPublisher.cpp      |  8 ++---
 6 files changed, 88 insertions(+), 14 deletions(-)

diff --git a/source/armarx/navigation/core/aron/Events.xml b/source/armarx/navigation/core/aron/Events.xml
index d7d29939..a0be50ec 100644
--- a/source/armarx/navigation/core/aron/Events.xml
+++ b/source/armarx/navigation/core/aron/Events.xml
@@ -53,5 +53,20 @@
             </ObjectChild>
         </Object>
 
+        <Object name='armarx::navigation::core::arondto::SafetyThrottlingTriggeredEvent'>
+            <ObjectChild key='pose'>
+                <Pose />
+            </ObjectChild>
+            <ObjectChild key='throttlingFactor'>
+                <float />
+            </ObjectChild>
+        </Object>
+
+        <Object name='armarx::navigation::core::arondto::SafetyStopTriggeredEvent'>
+            <ObjectChild key='pose'>
+                <Pose />
+            </ObjectChild>
+        </Object>
+
     </GenerateTypes>
 </AronTypeDefinition>
diff --git a/source/armarx/navigation/core/aron_conversions.cpp b/source/armarx/navigation/core/aron_conversions.cpp
index 4a974067..0aeaa75b 100644
--- a/source/armarx/navigation/core/aron_conversions.cpp
+++ b/source/armarx/navigation/core/aron_conversions.cpp
@@ -196,4 +196,35 @@ namespace armarx::navigation::core
         aron::fromAron(dto.pose, bo.pose.matrix());
     }
 
+
+    void
+    toAron(armarx::navigation::core::arondto::SafetyThrottlingTriggeredEvent& dto,
+           const armarx::navigation::core::SafetyThrottlingTriggeredEvent& bo)
+    {
+        aron::toAron(dto.pose, bo.pose.matrix());
+        aron::toAron(dto.throttlingFactor, bo.throttlingFactor);
+    }
+
+    void
+    fromAron(const armarx::navigation::core::arondto::SafetyThrottlingTriggeredEvent& dto,
+             armarx::navigation::core::SafetyThrottlingTriggeredEvent& bo)
+    {
+        aron::fromAron(dto.pose, bo.pose.matrix());
+        aron::fromAron(dto.throttlingFactor, bo.throttlingFactor);
+    }
+
+    void
+    toAron(armarx::navigation::core::arondto::SafetyStopTriggeredEvent& dto,
+           const armarx::navigation::core::SafetyStopTriggeredEvent& bo)
+    {
+        aron::toAron(dto.pose, bo.pose.matrix());
+    }
+
+    void
+    fromAron(const armarx::navigation::core::arondto::SafetyStopTriggeredEvent& dto,
+             armarx::navigation::core::SafetyStopTriggeredEvent& bo)
+    {
+        aron::fromAron(dto.pose, bo.pose.matrix());
+    }
+
 } // namespace armarx::navigation::core
diff --git a/source/armarx/navigation/core/aron_conversions.h b/source/armarx/navigation/core/aron_conversions.h
index 654fd409..50f6cb44 100644
--- a/source/armarx/navigation/core/aron_conversions.h
+++ b/source/armarx/navigation/core/aron_conversions.h
@@ -63,7 +63,7 @@ namespace armarx::navigation::core
     // Events
     void toAron(armarx::navigation::core::arondto::GoalReachedEvent& dto,
                 const armarx::navigation::core::GoalReachedEvent& bo);
-                
+
     void fromAron(const armarx::navigation::core::arondto::GoalReachedEvent& dto,
                   armarx::navigation::core::GoalReachedEvent& bo);
 
@@ -75,7 +75,7 @@ namespace armarx::navigation::core
 
     void toAron(armarx::navigation::core::arondto::GlobalPlanningFailedEvent& dto,
                 const armarx::navigation::core::GlobalPlanningFailedEvent& bo);
-                
+
     void fromAron(const armarx::navigation::core::arondto::MovementStartedEvent& dto,
                   armarx::navigation::core::MovementStartedEvent& bo);
 
@@ -97,5 +97,17 @@ namespace armarx::navigation::core
     void fromAron(const armarx::navigation::core::arondto::UserAbortTriggeredEvent& dto,
                   armarx::navigation::core::UserAbortTriggeredEvent& bo);
 
+    void toAron(armarx::navigation::core::arondto::SafetyThrottlingTriggeredEvent& dto,
+                const armarx::navigation::core::SafetyThrottlingTriggeredEvent& bo);
+
+    void fromAron(const armarx::navigation::core::arondto::SafetyThrottlingTriggeredEvent& dto,
+                  armarx::navigation::core::SafetyThrottlingTriggeredEvent& bo);
+
+    void toAron(armarx::navigation::core::arondto::SafetyStopTriggeredEvent& dto,
+                const armarx::navigation::core::SafetyStopTriggeredEvent& bo);
+
+    void fromAron(const armarx::navigation::core::arondto::SafetyStopTriggeredEvent& dto,
+                  armarx::navigation::core::SafetyStopTriggeredEvent& bo);
+
 
 } // namespace armarx::navigation::core
diff --git a/source/armarx/navigation/memory/client/events/Writer.cpp b/source/armarx/navigation/memory/client/events/Writer.cpp
index 4325c44a..ab64f942 100644
--- a/source/armarx/navigation/memory/client/events/Writer.cpp
+++ b/source/armarx/navigation/memory/client/events/Writer.cpp
@@ -70,7 +70,8 @@ namespace armarx::navigation::memory::client::events
     bool
     Writer::store(const core::WaypointReachedEvent& event, const std::string& clientID)
     {
-        return storeImpl<core::arondto::WaypointReachedEvent>(event, "WaypointReachedEvent", clientID);
+        return storeImpl<core::arondto::WaypointReachedEvent>(
+            event, "WaypointReachedEvent", clientID);
     }
 
     bool
@@ -82,19 +83,36 @@ namespace armarx::navigation::memory::client::events
     bool
     Writer::store(const core::GlobalPlanningFailedEvent& event, const std::string& clientID)
     {
-        return storeImpl<core::arondto::GlobalPlanningFailedEvent>(event, "GlobalPlanningFailedEvent", clientID);
+        return storeImpl<core::arondto::GlobalPlanningFailedEvent>(
+            event, "GlobalPlanningFailedEvent", clientID);
     }
 
     bool
     Writer::store(const core::MovementStartedEvent& event, const std::string& clientID)
     {
-        return storeImpl<core::arondto::MovementStartedEvent>(event, "MovementStartedEvent", clientID);
+        return storeImpl<core::arondto::MovementStartedEvent>(
+            event, "MovementStartedEvent", clientID);
     }
 
     bool
     Writer::store(const core::UserAbortTriggeredEvent& event, const std::string& clientID)
     {
-        return storeImpl<core::arondto::UserAbortTriggeredEvent>(event, "UserAbortTriggered", clientID);
+        return storeImpl<core::arondto::UserAbortTriggeredEvent>(
+            event, "UserAbortTriggered", clientID);
+    }
+
+    bool
+    Writer::store(const core::SafetyThrottlingTriggeredEvent& event, const std::string& clientID)
+    {
+        return storeImpl<core::arondto::SafetyThrottlingTriggeredEvent>(
+            event, "SafetyThrottlingTriggeredEvent", clientID);
+    }
+
+    bool
+    Writer::store(const core::SafetyStopTriggeredEvent& event, const std::string& clientID)
+    {
+        return storeImpl<core::arondto::SafetyStopTriggeredEvent>(
+            event, "SafetyStopTriggeredEvent", clientID);
     }
 
 
diff --git a/source/armarx/navigation/memory/client/events/Writer.h b/source/armarx/navigation/memory/client/events/Writer.h
index 16812c15..7ad07d7d 100644
--- a/source/armarx/navigation/memory/client/events/Writer.h
+++ b/source/armarx/navigation/memory/client/events/Writer.h
@@ -38,15 +38,13 @@ namespace armarx::navigation::memory::client::events
         using armem::client::util::SimpleWriterBase::SimpleWriterBase;
 
         bool store(const core::GoalReachedEvent& event, const std::string& clientID);
-
         bool store(const core::WaypointReachedEvent& event, const std::string& clientID);
-
         bool store(const core::InternalErrorEvent& event, const std::string& clientID);
-
         bool store(const core::UserAbortTriggeredEvent& event, const std::string& clientID);
-
         bool store(const core::GlobalPlanningFailedEvent& event, const std::string& clientID);
         bool store(const core::MovementStartedEvent& event, const std::string& clientID);
+        bool store(const core::SafetyThrottlingTriggeredEvent& event, const std::string& clientID);
+        bool store(const core::SafetyStopTriggeredEvent& event, const std::string& clientID);
 
 
         std::string propertyPrefix() const override;
diff --git a/source/armarx/navigation/server/event_publishing/MemoryPublisher.cpp b/source/armarx/navigation/server/event_publishing/MemoryPublisher.cpp
index 8f3b9d42..6226169b 100644
--- a/source/armarx/navigation/server/event_publishing/MemoryPublisher.cpp
+++ b/source/armarx/navigation/server/event_publishing/MemoryPublisher.cpp
@@ -21,14 +21,14 @@ namespace armarx::navigation::server
     void
     MemoryPublisher::safetyThrottlingTriggered(const core::SafetyThrottlingTriggeredEvent& event)
     {
-        // eventsWriter->store(event, clientId);
+        eventsWriter->store(event, clientId);
     }
 
 
     void
     MemoryPublisher::safetyStopTriggered(const core::SafetyStopTriggeredEvent& event)
     {
-        // eventsWriter->store(event, clientId);
+        eventsWriter->store(event, clientId);
     }
 
 
@@ -54,7 +54,7 @@ namespace armarx::navigation::server
     void
     MemoryPublisher::localTrajectoryUpdated(const loc_plan::LocalPlannerResult& res)
     {
-        // TODO resultWriter->store(res, clientId);
+        // resultWriter->store(res, clientId);
     }
 
     void
@@ -63,7 +63,7 @@ namespace armarx::navigation::server
         resultWriter->store(res, clientId);
     }
 
-    // TODO event with message or reason (enum)
+    // TODO(fabian.reister): event with message or reason (enum)
     void
     MemoryPublisher::globalPlanningFailed(const core::GlobalPlanningFailedEvent& event)
     {
-- 
GitLab