From 770b844cc437ca285a6fbf64041b5f943b5f45e3 Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Wed, 10 Feb 2021 10:29:21 +0100
Subject: [PATCH] Clean RosTfListener commands.

---
 src/ros_tf_listener-python-module-py.cc | 18 ++++++++++++++++++
 src/ros_tf_listener-python.hh           |  3 ---
 src/ros_tf_listener.hh                  | 24 ++----------------------
 3 files changed, 20 insertions(+), 25 deletions(-)
 create mode 100644 src/ros_tf_listener-python-module-py.cc
 delete mode 100644 src/ros_tf_listener-python.hh

diff --git a/src/ros_tf_listener-python-module-py.cc b/src/ros_tf_listener-python-module-py.cc
new file mode 100644
index 0000000..3815f45
--- /dev/null
+++ b/src/ros_tf_listener-python-module-py.cc
@@ -0,0 +1,18 @@
+#include <dynamic-graph/python/module.hh>
+#include "ros_tf_listener.hh"
+
+namespace dg = dynamicgraph;
+
+BOOST_PYTHON_MODULE(wrap)
+{
+  bp::import("dynamic_graph");
+
+  dg::python::exposeEntity<dg::RosTfListener, bp::bases<dg::Entity>, dg::python::AddCommands>()
+    .def("add", &dg::RosTfListener::add,
+        "Add a signal containing the transform between two frames.",
+        bp::args( "to_frame_name", "from_frame_name", "out_signal_name"))
+    .def("setMaximumDelay", &dg::RosTfListener::setMaximumDelay,
+        "Set the maximum time delay of the transform obtained from tf.",
+        bp::args("signal_name", "delay_seconds"))
+    ;
+}
diff --git a/src/ros_tf_listener-python.hh b/src/ros_tf_listener-python.hh
deleted file mode 100644
index 492d61f..0000000
--- a/src/ros_tf_listener-python.hh
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "ros_tf_listener.hh"
-
-typedef boost::mpl::vector< dynamicgraph::RosTfListener > entities_t;
diff --git a/src/ros_tf_listener.hh b/src/ros_tf_listener.hh
index a95907a..778c812 100644
--- a/src/ros_tf_listener.hh
+++ b/src/ros_tf_listener.hh
@@ -72,31 +72,11 @@ class RosTfListener : public Entity {
     : Entity(_name)
     , buffer()
     , listener(buffer, rosInit(), false)
-  {
-    std::string docstring =
-        "\n"
-        "  Add a signal containing the transform between two frames.\n"
-        "\n"
-        "  Input:\n"
-        "    - to  : frame name\n"
-        "    - from: frame name,\n"
-        "    - signalName: the signal name in dynamic-graph"
-        "\n";
-    addCommand("add", command::makeCommandVoid3(*this, &RosTfListener::add, docstring));
-    docstring =
-        "\n"
-        "  Set the maximum time delay of the transform obtained from tf.\n"
-        "\n"
-        "  Input:\n"
-        "    - signalName: the signal name,\n"
-        "    - delay  : in seconds\n"
-        "\n";
-    addCommand("setMaximumDelay", command::makeCommandVoid2(*this, &RosTfListener::setMaximumDelay, docstring));
-  }
+  {}
 
   ~RosTfListener()
   {
-    for (Map_t::const_iterator _it = listenerDatas.begin(); _it != listenerDatas.end(); ++_it) delete _it->second;
+    for (const auto& pair : listenerDatas) delete pair.second;
   }
 
   void add(const std::string& to, const std::string& from, const std::string& signame)
-- 
GitLab