From 1fb72ab798aa3b50edf4d6ac28ad3c210ed4d843 Mon Sep 17 00:00:00 2001
From: Sergi Hernandez Juan <shernand@iri.upc.edu>
Date: Fri, 23 Oct 2020 13:31:29 +0200
Subject: [PATCH] Set the python setup of the package. Added the python
 functions to generate the generic parameters for the module, module service
 and module action classes.

---
 CMakeLists.txt                  |  2 +-
 setup.py                        | 10 ++++++++++
 src/iri_ros_tools/__init__.py   |  0
 src/iri_ros_tools/dyn_params.py | 30 ++++++++++++++++++++++++++++++
 4 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 setup.py
 create mode 100644 src/iri_ros_tools/__init__.py
 create mode 100644 src/iri_ros_tools/dyn_params.py

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e2ea37a..72267f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,7 +12,7 @@ find_package(Boost REQUIRED COMPONENTS system)
 ## Uncomment this if the package has a setup.py. This macro ensures
 ## modules and global scripts declared therein get installed
 ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
-# catkin_python_setup()
+catkin_python_setup()
 
 ################################################
 ## Declare ROS messages, services and actions ##
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..b40c66f
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+from distutils.core import setup
+from catkin_pkg.python_setup import generate_distutils_setup
+d = generate_distutils_setup(
+    packages=['iri_ros_tools'],
+    package_dir={'': 'src'},
+    requires=['roslib', 'rospy', 'rosservice']
+)
+setup(**d)
+
diff --git a/src/iri_ros_tools/__init__.py b/src/iri_ros_tools/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/iri_ros_tools/dyn_params.py b/src/iri_ros_tools/dyn_params.py
new file mode 100644
index 0000000..93ce21b
--- /dev/null
+++ b/src/iri_ros_tools/dyn_params.py
@@ -0,0 +1,30 @@
+# submodule config parameters
+from dynamic_reconfigure.parameter_generator_catkin import *
+
+def add_module_service_params(gen,name):
+  new_group = gen.add_group(name)
+
+  new_group.add(name+"_num_retries",int_t, 0,"Number of times a service will be called before reporting an error",1,1,10)
+  new_group.add(name+"_enabled",    bool_t,0,"Enable or disable the actual service call",                         True)
+
+  return new_group
+
+def add_module_action_params(gen,name):
+  new_group = gen.add_group(name)
+
+  new_group.add(name+"_num_retries",             int_t,   0,"Number of times an action will be called before reporting an error",1,     1,      10)
+  new_group.add(name+"_enable_timeout",          bool_t,  0,"Enable or disable the timeout feature",                             True)
+  new_group.add(name+"_timeout_s",               double_t,0,"Maximum time in second to wait for the action to complete",         10.0,  1.0,    600.0)
+  new_group.add(name+"_enable_iwatchdog",        bool_t,  0,"Enable or disable the watchdog feature",                            True)
+  new_group.add(name+"_feedback_watchdog_time_s",double_t,0,"Maximum time in second between two consecutive feedback topics",    2.0,   1.0,    100.0)
+  new_group.add(name+"_enabled",                 bool_t,  0,"Enable or disable the actual action request",                       True)
+
+  return new_group
+
+def add_module_params(gen,name):
+  new_group = gen.add_group(name)
+
+  new_group.add(name+"_rate_hz", double_t, 0,"Desired rate in Hz of the module",1.0,0.1,100.0)
+
+  return new_group
+
-- 
GitLab