From 4bf3ea201005ad8476cd63a19e7eac306687df28 Mon Sep 17 00:00:00 2001 From: Eloy Retamino Date: Mon, 2 Dec 2019 13:36:30 +0000 Subject: [PATCH 1/2] Merged in NRRPLT-7700-tf-execution-order (pull request #81) [NRRPLT-7700] Added order attribute to transfer functions Approved-by: Michael Zechmair Approved-by: Ugo Albanese --- .../server/CLEGazeboSimulationAssembly.py | 2 +- .../hbp_nrp_commons/sim_config/SimConfig.py | 12 ++++++++++-- .../tests/sim_config/test_SimConfig.py | 15 ++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/hbp_nrp_cleserver/hbp_nrp_cleserver/server/CLEGazeboSimulationAssembly.py b/hbp_nrp_cleserver/hbp_nrp_cleserver/server/CLEGazeboSimulationAssembly.py index 9406908..344d59b 100644 --- a/hbp_nrp_cleserver/hbp_nrp_cleserver/server/CLEGazeboSimulationAssembly.py +++ b/hbp_nrp_cleserver/hbp_nrp_cleserver/server/CLEGazeboSimulationAssembly.py @@ -419,7 +419,7 @@ def __load_tfs(self): continue try: - tfm.set_transfer_function(tf.code, new_code, tf.name, tf.active) + tfm.set_transfer_function(tf.code, new_code, tf.name, tf.active, tf.priority) except tfm.TFLoadingException as loading_e: logger.error(loading_e) tfm.set_flawed_transfer_function(tf.code, tf.name, loading_e) diff --git a/hbp_nrp_commons/hbp_nrp_commons/sim_config/SimConfig.py b/hbp_nrp_commons/hbp_nrp_commons/sim_config/SimConfig.py index 794aa6b..bd72c82 100644 --- a/hbp_nrp_commons/hbp_nrp_commons/sim_config/SimConfig.py +++ b/hbp_nrp_commons/hbp_nrp_commons/sim_config/SimConfig.py @@ -119,18 +119,25 @@ class _TF(object): # pragma: no cover """ Model to store TF information """ - def __init__(self, name, code, src=None, active=False): + def __init__(self, name, code, src=None, active=False, priority=0): """ Initialize a transfer function object :param name: name of the transfer function :param code: compiled (restricted) source code of transfer function :param src: source code (plain text) of transfer function + :param active: active state of the transfer function + :param priority: specifies execution order of the transfer function. Transfer functions with + higher priority are executed first. """ self.name = name self.code = code self.src = src self.active = active + try: + self.priority = int(priority) + except (ValueError, TypeError): + self.priority = 0 class SimConfig(object): @@ -331,8 +338,9 @@ def _read_dom_data(self): code = generate_tf(_tf, self.sim_dir) name = get_tf_name(code) src = _tf.src if _tf.src else None # must be not None and not "" + priority = _tf.priority if _tf.priority else 0 active = bool(_tf.active) if _tf.active else False - self._tfs.append(_TF(name, code, src, active)) + self._tfs.append(_TF(name, code, src, active, priority)) def _read_robot_models(self): """ diff --git a/hbp_nrp_commons/hbp_nrp_commons/tests/sim_config/test_SimConfig.py b/hbp_nrp_commons/hbp_nrp_commons/tests/sim_config/test_SimConfig.py index 9d32ed0..a2cc604 100644 --- a/hbp_nrp_commons/hbp_nrp_commons/tests/sim_config/test_SimConfig.py +++ b/hbp_nrp_commons/hbp_nrp_commons/tests/sim_config/test_SimConfig.py @@ -30,7 +30,7 @@ from mock import patch, Mock, MagicMock, ANY, mock_open from hbp_nrp_commons.MockUtil import MockUtil -from hbp_nrp_commons.sim_config.SimConfig import SimConfig +from hbp_nrp_commons.sim_config.SimConfig import SimConfig, _TF __author__ = 'Hossain Mahmud' @@ -116,6 +116,19 @@ def test_read_data(self): def test_properties(self): pass + def test_priority_is_int(self): + # test _TF priority value is always initialized to an integer + tf_1 = _TF("dummy_name", "dummy_code",priority=None) + tf_2 = _TF("dummy_name", "dummy_code", priority="string_value") + tf_3 = _TF("dummy_name", "dummy_code", priority=False) + tf_4 = _TF("dummy_name", "dummy_code", priority=3.1416) + + self.assertTrue(type(tf_1.priority) == int) + self.assertTrue(type(tf_2.priority) == int) + self.assertTrue(type(tf_3.priority) == int) + self.assertTrue(type(tf_4.priority) == int) + + if __name__ == '__main__': unittest.main() From f5405fb98bf61667c27e0359c37149ab3a97b8c9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2019 16:54:00 +0000 Subject: [PATCH 2/2] Bump pyyaml from 3.11 to 5.1 in /hbp_nrp_backend Bumps [pyyaml](https://github.com/yaml/pyyaml) from 3.11 to 5.1. - [Release notes](https://github.com/yaml/pyyaml/releases) - [Changelog](https://github.com/yaml/pyyaml/blob/master/CHANGES) - [Commits](https://github.com/yaml/pyyaml/compare/3.11...5.1) Signed-off-by: dependabot[bot] --- hbp_nrp_backend/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hbp_nrp_backend/requirements.txt b/hbp_nrp_backend/requirements.txt index a280870..3a75354 100644 --- a/hbp_nrp_backend/requirements.txt +++ b/hbp_nrp_backend/requirements.txt @@ -1,6 +1,6 @@ # other requirements lxml==3.4.0 -PyYAML==3.11 +PyYAML==5.1 rospkg==1.0.38 catkin_pkg==0.2.10 pyxb==1.2.4