Skip to content

Commit

Permalink
[ros_bridge][py] Refactoring getRTCList method.
Browse files Browse the repository at this point in the history
`Rtclist` arg wasn't used in `hironx_ros_bridge/hironx_client.py`. Rename it to express its usage is private only and utilize it for future purpose.
  • Loading branch information
130s committed Apr 26, 2017
1 parent 2bd1166 commit 40e3ffe
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 14 deletions.
27 changes: 13 additions & 14 deletions hironx_ros_bridge/src/hironx_ros_bridge/hironx_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,16 @@ class via the link above; nicely formatted api doc web page

HandGroups = {'rhand': [2, 3, 4, 5], 'lhand': [6, 7, 8, 9]}

RtcList = []
_RTClist = [
['seq', "SequencePlayer"],
['sh', "StateHolder"],
['fk', "ForwardKinematics"],
['ic', "ImpedanceController"],
['el', "SoftErrorLimiter"],
# ['co', "CollisionDetector"],
['sc', "ServoController"],
['log', "DataLogger"],
]

# servo controller (grasper)
sc = None
Expand Down Expand Up @@ -442,26 +451,16 @@ def getRTCList(self):
@rerutrn List of available components. Each element consists of a list
of abbreviated and full names of the component.
'''
rtclist = [
['seq', "SequencePlayer"],
['sh', "StateHolder"],
['fk', "ForwardKinematics"],
['ic', "ImpedanceController"],
['el', "SoftErrorLimiter"],
# ['co', "CollisionDetector"],
['sc', "ServoController"],
['log', "DataLogger"],
]
if hasattr(self, 'rmfo'):
self.ms.load("RemoveForceSensorLinkOffset")
self.ms.load("AbsoluteForceSensor")
if "RemoveForceSensorLinkOffset" in self.ms.get_factory_names():
rtclist.append(['rmfo', "RemoveForceSensorLinkOffset"])
self._RTClist.append(['rmfo', "RemoveForceSensorLinkOffset"])
elif "AbsoluteForceSensor" in self.ms.get_factory_names():
rtclist.append(['rmfo', "AbsoluteForceSensor"])
self._RTClist.append(['rmfo', "AbsoluteForceSensor"])
else:
print "Component rmfo is not loadable."
return rtclist
return self._RTClist

# hand interface
# effort: 1~100[%]
Expand Down
3 changes: 3 additions & 0 deletions hironx_ros_bridge/test/test-hironx.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@
args="-ORBInitRef NameService=corbaloc:iiop:localhost:2809/NameService" />
<test type="test_hironx_ik_noinit.py" pkg="hironx_ros_bridge" test-name="test_hironx_ik_noinit" time-limit="3000"
args="-ORBInitRef NameService=corbaloc:iiop:localhost:2809/NameService" />
<test type="test_hironx_client.py" pkg="hironx_ros_bridge"
test-name="test_hironx_client" time-limit="3000"
args="-ORBInitRef NameService=corbaloc:iiop:localhost:2809/NameService" />
</launch>
58 changes: 58 additions & 0 deletions hironx_ros_bridge/test/test_hironx_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Software License Agreement (BSD License)
#
# Copyright (c) 2017, TORK
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of TORK (Tokyo Opensource Robotics Kyokai Association).
# nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from test_hironx import TestHiro

PKG = 'hironx_ros_bridge'


class TestHiroClient(TestHiro):

def test_getRTCList(self):
RTC_LIST = [
['seq', "SequencePlayer"],
['sh', "StateHolder"],
['fk', "ForwardKinematics"],
['ic', "ImpedanceController"],
['el', "SoftErrorLimiter"],
# ['co', "CollisionDetector"],
['sc', "ServoController"],
['log', "DataLogger"],
]
self.assertListEqual(self.robot.getRTCList(), RTC_LIST)

if __name__ == '__main__':
import rostest
rostest.rosrun(PKG, 'test_hronx_client', TestHiroClient)

0 comments on commit 40e3ffe

Please sign in to comment.