test_hand_commander.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright 2015 Shadow Robot Company Ltd.
4 #
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation version 2 of the License.
8 #
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 # more details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 import rospy
18 from sr_robot_commander.sr_hand_commander import SrHandCommander
19 from sr_utilities.hand_finder import HandFinder
20 from unittest import TestCase
21 
22 PKG = "sr_robot_commander"
23 
24 
25 class TestSrHandCommander(TestCase):
26  """
27  Tests the Hand Commander
28  """
29 
30  def setUp(self):
31  rospy.init_node('test_hand_commander', anonymous=True)
32 
33  def test_strip_prefix(self):
34  hand_commander = SrHandCommander()
35 
36  self.assertEqual(hand_commander._strip_prefix("rh_ffj3"), "ffj3", msg="Strip failed")
37  self.assertEqual(hand_commander._strip_prefix("ffj3"), "ffj3", msg="Strip failed")
38 
40  hand_finder = HandFinder()
41  hand_parameters = hand_finder.get_hand_parameters()
42  hand_commander = SrHandCommander(hand_parameters=hand_parameters,
43  hand_serial=hand_parameters.mapping.keys()[0])
44  self.assertGreater(len(hand_commander.get_joints_position()), 0, "No joints found, init must have failed.")
45 
46 if __name__ == "__main__":
47  import rostest
48  rostest.rosrun(PKG, "test_hand_commander", TestSrHandCommander)


sr_robot_commander
Author(s): Andriy Petlovanyy
autogenerated on Wed Oct 14 2020 04:05:30