From 7ec6cf9d48392af4bdb93842845563ffe5068b95 Mon Sep 17 00:00:00 2001
From: "Christian R. G. Dreher" <c.dreher@kit.edu>
Date: Mon, 12 Jul 2021 18:08:06 +0200
Subject: [PATCH] feature: Add Exmaple component together with stubs for
 component plugin.

---
 source/Navigation/components/CMakeLists.txt   |  4 +-
 .../components/ExampleClient/CMakeLists.txt   | 35 ++++++++
 .../ExampleClient/ExampleClient.cpp           | 89 +++++++++++++++++++
 .../components/ExampleClient/ExampleClient.h  | 85 ++++++++++++++++++
 source/Navigation/libraries/client.h          |  4 +
 .../libraries/client/CMakeLists.txt           | 10 ++-
 .../libraries/client/ComponentPlugin.cpp      | 20 +++++
 .../libraries/client/ComponentPlugin.h        | 46 ++++++++++
 .../Navigation/libraries/client/Navigator.cpp | 19 ++++
 .../Navigation/libraries/client/Navigator.h   | 15 ++++
 .../client/NavigatorComponentPlugin.h         |  0
 .../TrajectoryFollowingController.h           |  2 +-
 12 files changed, 323 insertions(+), 6 deletions(-)
 create mode 100644 source/Navigation/components/ExampleClient/CMakeLists.txt
 create mode 100644 source/Navigation/components/ExampleClient/ExampleClient.cpp
 create mode 100644 source/Navigation/components/ExampleClient/ExampleClient.h
 create mode 100644 source/Navigation/libraries/client.h
 create mode 100644 source/Navigation/libraries/client/ComponentPlugin.cpp
 create mode 100644 source/Navigation/libraries/client/ComponentPlugin.h
 create mode 100644 source/Navigation/libraries/client/Navigator.cpp
 delete mode 100644 source/Navigation/libraries/client/NavigatorComponentPlugin.h

diff --git a/source/Navigation/components/CMakeLists.txt b/source/Navigation/components/CMakeLists.txt
index 0e87d394..4059527a 100644
--- a/source/Navigation/components/CMakeLists.txt
+++ b/source/Navigation/components/CMakeLists.txt
@@ -1,2 +1,4 @@
+add_subdirectory(Navigator)
 
-add_subdirectory(Navigator)
\ No newline at end of file
+# Examples
+add_subdirectory(ExampleClient)
diff --git a/source/Navigation/components/ExampleClient/CMakeLists.txt b/source/Navigation/components/ExampleClient/CMakeLists.txt
new file mode 100644
index 00000000..27bdf6a5
--- /dev/null
+++ b/source/Navigation/components/ExampleClient/CMakeLists.txt
@@ -0,0 +1,35 @@
+set(LIB_NAME ExampleClient)
+
+
+armarx_component_set_name("${LIB_NAME}")
+armarx_set_target("Library: ${LIB_NAME}")
+
+
+# Add the component
+armarx_add_component(
+    COMPONENT_LIBS
+        # ArmarXCore
+        ArmarXCore
+        ## ArmarXCoreComponentPlugins  # For DebugObserver plugin.
+        # ArmarXGui
+        ## ArmarXGuiComponentPlugins  # For RemoteGui plugin.
+        # RobotAPI
+        ## RobotAPICore
+        ## RobotAPIInterfaces
+        ## RobotAPIArmarXObjects
+        ## RobotAPIComponentPlugins  # For ArViz and other plugins.
+        # Navigation
+        Navigation::Client
+
+    SOURCES
+        ExampleClient.cpp
+
+    HEADERS
+        ExampleClient.h
+)
+
+
+# Generate the application
+armarx_generate_and_add_component_executable(
+    COMPONENT_NAMESPACE armarx::nav::components
+)
diff --git a/source/Navigation/components/ExampleClient/ExampleClient.cpp b/source/Navigation/components/ExampleClient/ExampleClient.cpp
new file mode 100644
index 00000000..8fc5398d
--- /dev/null
+++ b/source/Navigation/components/ExampleClient/ExampleClient.cpp
@@ -0,0 +1,89 @@
+/**
+ * This file is part of ArmarX.
+ *
+ * ArmarX is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * ArmarX is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package    Navigation::ArmarXObjects::ExampleClient
+ * @author     Christian R. G. Dreher ( c dot dreher at kit dot edu )
+ * @date       2021
+ * @copyright  http://www.gnu.org/licenses/gpl-2.0.txt
+ *             GNU General Public License
+ */
+
+
+#include <Navigation/components/ExampleClient/ExampleClient.h>
+
+
+
+armarx::nav::components::ExampleClient::ExampleClient()
+{
+    // pass
+}
+
+
+armarx::nav::components::ExampleClient::~ExampleClient()
+{
+    // pass
+}
+
+
+void
+armarx::nav::components::ExampleClient::onInitComponent()
+{
+    // pass
+}
+
+
+void
+armarx::nav::components::ExampleClient::onConnectComponent()
+{
+    task = new RunningTask<ExampleClient>(this, &ExampleClient::exampleNavigation);
+    task->start();
+}
+
+
+void
+armarx::nav::components::ExampleClient::onDisconnectComponent()
+{
+    const bool join = true;
+    task->stop(join);
+}
+
+
+void
+armarx::nav::components::ExampleClient::onExitComponent()
+{
+    // pass
+}
+
+
+std::string
+armarx::nav::components::ExampleClient::getDefaultName() const
+{
+    return "ExampleClient";
+}
+
+
+void
+armarx::nav::components::ExampleClient::exampleNavigation()
+{
+
+}
+
+
+armarx::PropertyDefinitionsPtr
+armarx::nav::components::ExampleClient::createPropertyDefinitions()
+{
+    PropertyDefinitionsPtr def = new ComponentPropertyDefinitions(getConfigIdentifier());
+    return def;
+}
diff --git a/source/Navigation/components/ExampleClient/ExampleClient.h b/source/Navigation/components/ExampleClient/ExampleClient.h
new file mode 100644
index 00000000..8404ad89
--- /dev/null
+++ b/source/Navigation/components/ExampleClient/ExampleClient.h
@@ -0,0 +1,85 @@
+/**
+ * This file is part of ArmarX.
+ *
+ * ArmarX is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * ArmarX is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package    Navigation::ArmarXObjects::ExampleClient
+ * @author     Christian R. G. Dreher ( c dot dreher at kit dot edu )
+ * @date       2021
+ * @copyright  http://www.gnu.org/licenses/gpl-2.0.txt
+ *             GNU General Public License
+ */
+
+
+#pragma once
+
+
+// ArmarX
+#include <ArmarXCore/util/tasks.h>
+
+// Navigation
+#include <Navigation/libraries/client.h>
+
+
+namespace armarx::nav::components
+{
+
+    /**
+     * @defgroup Component-ExampleClient ExampleClient
+     * @ingroup Navigation-Components
+     * A description of the component ExampleClient.
+     *
+     * @class ExampleClient
+     * @ingroup Component-ExampleClient
+     * @brief Brief description of class ExampleClient.
+     *
+     * Detailed description of class ExampleClient.
+     */
+    class ExampleClient :
+        virtual public Component,
+        virtual public nav::client::ComponentPluginUser
+    {
+
+    public:
+
+        ExampleClient();
+
+        ~ExampleClient() override;
+
+    protected:
+
+        /// @see PropertyUser::createPropertyDefinitions()
+        PropertyDefinitionsPtr createPropertyDefinitions() override;
+
+        /// @see armarx::ManagedIceObject::onInitComponent()
+        void onInitComponent() override;
+
+        /// @see armarx::ManagedIceObject::onConnectComponent()
+        void onConnectComponent() override;
+
+        /// @see armarx::ManagedIceObject::onDisconnectComponent()
+        void onDisconnectComponent() override;
+
+        /// @see armarx::ManagedIceObject::onExitComponent()
+        void onExitComponent() override;
+
+        std::string getDefaultName() const override;
+
+        void exampleNavigation();
+
+    private:
+
+        RunningTask<ExampleClient>::pointer_type task;
+
+    };
+} // namespace armarx::nav::components
diff --git a/source/Navigation/libraries/client.h b/source/Navigation/libraries/client.h
new file mode 100644
index 00000000..02957051
--- /dev/null
+++ b/source/Navigation/libraries/client.h
@@ -0,0 +1,4 @@
+#pragma once
+
+
+#include <Navigation/libraries/client/ComponentPlugin.h>
diff --git a/source/Navigation/libraries/client/CMakeLists.txt b/source/Navigation/libraries/client/CMakeLists.txt
index 2192ec99..bc5bcad2 100644
--- a/source/Navigation/libraries/client/CMakeLists.txt
+++ b/source/Navigation/libraries/client/CMakeLists.txt
@@ -10,19 +10,21 @@ armarx_add_library(
         # RobotAPI
         aron
         # Navigation
+        NavigatorInterfaces
         Navigation::Core
         Navigation::GlobalPlanning
         Navigation::LocalPlanning
         Navigation::TrajectoryControl
         Navigation::SafetyControl
     SOURCES  
-        # ./Navigator.cpp
+        ./Navigator.cpp
         ./NavigationStackConfig.cpp
-        # ./NavigatorComponentPlugin.cpp
-    HEADERS  
+        ./ComponentPlugin.cpp
+    HEADERS
+        ../client.h
         ./Navigator.h
         ./NavigationStackConfig.h
-        ./NavigatorComponentPlugin.h
+        ./ComponentPlugin.h
 )
 
 add_library(Navigation::Client ALIAS ${PROJECT_NAME}Client)
diff --git a/source/Navigation/libraries/client/ComponentPlugin.cpp b/source/Navigation/libraries/client/ComponentPlugin.cpp
new file mode 100644
index 00000000..a8277b9b
--- /dev/null
+++ b/source/Navigation/libraries/client/ComponentPlugin.cpp
@@ -0,0 +1,20 @@
+#include <Navigation/libraries/client/ComponentPlugin.h>
+
+
+armarx::nav::client::ComponentPlugin::~ComponentPlugin()
+{
+
+}
+
+
+armarx::nav::client::ComponentPluginUser::ComponentPluginUser()
+{
+    addPlugin(plugin);
+}
+
+
+armarx::nav::client::ComponentPluginUser::~ComponentPluginUser()
+{
+
+}
+
diff --git a/source/Navigation/libraries/client/ComponentPlugin.h b/source/Navigation/libraries/client/ComponentPlugin.h
new file mode 100644
index 00000000..8505213e
--- /dev/null
+++ b/source/Navigation/libraries/client/ComponentPlugin.h
@@ -0,0 +1,46 @@
+#pragma once
+
+
+// ArmarX
+#include <ArmarXCore/core/ComponentPlugin.h>
+#include <ArmarXCore/core/ManagedIceObject.h>
+
+// Navigator
+#include <Navigation/libraries/client/Navigator.h>
+
+
+namespace armarx::nav::client
+{
+
+    class ComponentPlugin :
+        virtual public armarx::ComponentPlugin
+    {
+
+    public:
+
+        using armarx::ComponentPlugin::ComponentPlugin;
+        ~ComponentPlugin() override;
+
+    };
+
+
+    class ComponentPluginUser :
+        virtual public ManagedIceObject
+    {
+
+    public:
+
+        ComponentPluginUser();
+        ~ComponentPluginUser() override;
+
+    public:
+
+        Navigator navigator;
+
+    private:
+
+        ComponentPlugin* plugin = nullptr;
+
+    };
+
+}
diff --git a/source/Navigation/libraries/client/Navigator.cpp b/source/Navigation/libraries/client/Navigator.cpp
new file mode 100644
index 00000000..76932799
--- /dev/null
+++ b/source/Navigation/libraries/client/Navigator.cpp
@@ -0,0 +1,19 @@
+#include <Navigation/libraries/client/Navigator.h>
+
+
+void armarx::nav::client::Navigator::configure()
+{
+
+}
+
+
+void armarx::nav::client::Navigator::moveTo()
+{
+
+}
+
+
+void armarx::nav::client::Navigator::moveTowards()
+{
+
+}
diff --git a/source/Navigation/libraries/client/Navigator.h b/source/Navigation/libraries/client/Navigator.h
index a2c16cd5..f045dd42 100644
--- a/source/Navigation/libraries/client/Navigator.h
+++ b/source/Navigation/libraries/client/Navigator.h
@@ -20,13 +20,28 @@
  *             GNU General Public License
  */
 
+
+#include <Navigation/components/Navigator/NavigatorInterface.h>
+
+
 namespace armarx::nav::client
 {
 
     class Navigator
     {
+
     public:
+
+        void configure();
+        void moveTo();
+        void moveTowards();
+
     protected:
+
     private:
+
+        components::NavigatorInterfacePrx navigator;
+
     };
+
 } // namespace armarx::nav::client
diff --git a/source/Navigation/libraries/client/NavigatorComponentPlugin.h b/source/Navigation/libraries/client/NavigatorComponentPlugin.h
deleted file mode 100644
index e69de29b..00000000
diff --git a/source/Navigation/libraries/trajectory_control/TrajectoryFollowingController.h b/source/Navigation/libraries/trajectory_control/TrajectoryFollowingController.h
index 7baf15a8..80e79738 100644
--- a/source/Navigation/libraries/trajectory_control/TrajectoryFollowingController.h
+++ b/source/Navigation/libraries/trajectory_control/TrajectoryFollowingController.h
@@ -25,7 +25,7 @@
 #include "RobotAPI/libraries/core/MultiDimPIDController.h"
 
 #include "Navigation/libraries/trajectory_control/TrajectoryController.h"
-#include "aron/TrajectoryFollowingControllerParams.aron.generated.h"
+//#include "aron/TrajectoryFollowingControllerParams.aron.generated.h"
 
 namespace armarx::nav::traj_ctrl
 {
-- 
GitLab