From c1b90d7a0e16ac94715a3c3a4e812c14489f7764 Mon Sep 17 00:00:00 2001 From: "Isaac I.Y. Saito" <130s@2000.jukuin.keio.ac.jp> Date: Fri, 28 Apr 2017 21:56:37 -0700 Subject: [PATCH] [ros_bridge][py] Add back CollisionDetector as an option. Now that RTCs to activate is selectable from the end client (e.g. hironx.py), we need to expose all RTCs available. [ros_bridge][test][py] Refactoring. --- .../src/hironx_ros_bridge/hironx_client.py | 19 +++++++++++++++++-- .../testutil => test}/test_hironx_client.py | 16 +++------------- 2 files changed, 20 insertions(+), 15 deletions(-) rename hironx_ros_bridge/{src/hironx_ros_bridge/testutil => test}/test_hironx_client.py (89%) diff --git a/hironx_ros_bridge/src/hironx_ros_bridge/hironx_client.py b/hironx_ros_bridge/src/hironx_ros_bridge/hironx_client.py index 33edfe2d..70d645b5 100644 --- a/hironx_ros_bridge/src/hironx_ros_bridge/hironx_client.py +++ b/hironx_ros_bridge/src/hironx_ros_bridge/hironx_client.py @@ -310,13 +310,25 @@ class via the link above; nicely formatted api doc web page # This shouldn't be accessed once turned to True during `init` method. is_rtc_activated = False + # Default set of RTCs to be activated. _RTC_list = [ ['seq', "SequencePlayer"], ['sh', "StateHolder"], ['fk', "ForwardKinematics"], ['ic', "ImpedanceController"], ['el', "SoftErrorLimiter"], - # ['co', "CollisionDetector"], + ['sc', "ServoController"], + ['log', "DataLogger"], + ] + + # All available RTCs. This list is meant to be immutable. + RTCs_all_available = [ + ['seq', "SequencePlayer"], + ['sh', "StateHolder"], + ['fk', "ForwardKinematics"], + ['ic', "ImpedanceController"], + ['el', "SoftErrorLimiter"], + ['co', "CollisionDetector"], ['sc', "ServoController"], ['log', "DataLogger"], ] @@ -491,8 +503,11 @@ def getRTCList(self, rtcs_str=None): if not all(x in rtcs_req_list for x in self._RTC_NAME_MINREQ): raise ValueError('{} are required at minimum'.format( self._RTC_NAME_MINREQ)) + + # Create a new list of requested RTC with the name of + # implementations. for rtc_requested in rtcs_req_list: - for elem in self._RTC_list: + for elem in self.RTCs_all_available: if elem[0] == rtc_requested: new_rtcs.append(elem) break diff --git a/hironx_ros_bridge/src/hironx_ros_bridge/testutil/test_hironx_client.py b/hironx_ros_bridge/test/test_hironx_client.py similarity index 89% rename from hironx_ros_bridge/src/hironx_ros_bridge/testutil/test_hironx_client.py rename to hironx_ros_bridge/test/test_hironx_client.py index 0106957e..49c923ab 100755 --- a/hironx_ros_bridge/src/hironx_ros_bridge/testutil/test_hironx_client.py +++ b/hironx_ros_bridge/test/test_hironx_client.py @@ -41,18 +41,6 @@ class TestHiroClient(TestHiro): - _RTC_LIST = [ - ['seq', "SequencePlayer"], - ['sh', "StateHolder"], - ['fk', "ForwardKinematics"], - ['ic', "ImpedanceController"], - ['el', "SoftErrorLimiter"], - ['sc', "ServoController"], - ['log', "DataLogger"], - # rmfo will be automatically added in getRTCList. - ['rmfo', 'RemoveForceSensorLinkOffset'] - ] - _RTC_LIST_CUSTOM = [ ['seq', "SequencePlayer"], ['sh', "StateHolder"], @@ -80,7 +68,9 @@ def test_getRTCList(self): ''' self.assertTrue( self._compare_2dlist( - self.robot.getRTCList(), self._RTC_LIST)) + self.robot.getRTCList(), + # Accessing a private member var only for testing purpose. + self.robot._RTC_list)) def test_getRTCList_customrtcs_args_correct(self): '''