test_airhand.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 # Software License Agreement (BSD License)
5 #
6 # Copyright (c) 2014, Tokyo Opensource Robotics Kyokai Association
7 # All rights reserved.
8 #
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
11 # are met:
12 #
13 # * Redistributions of source code must retain the above copyright
14 # notice, this list of conditions and the following disclaimer.
15 # * Redistributions in binary form must reproduce the above
16 # copyright notice, this list of conditions and the following
17 # disclaimer in the documentation and/or other materials provided
18 # with the distribution.
19 # * Neither the name of Tokyo Opensource Robotics Kyokai Association. nor the
20 # names of its contributors may be used to endorse or promote products
21 # derived from this software without specific prior written permission.
22 #
23 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 # POSSIBILITY OF SUCH DAMAGE.
35 #
36 # Author: Isaac I.Y. Saito
37 
38 import unittest
39 
40 import rostest
41 
42 from nextage_ros_bridge import nextage_client
43 
44 _GOINITIAL_TIME_MIDSPEED = 3 # second
45 _PKG = 'nextage_ros_bridge'
46 
47 
48 class TestNxoAirhand(unittest.TestCase):
49  '''
50  Test NextageClient with rostest. This does NOT test hardware (i.e. if DIO
51  is connected and functioning); instead, this only verifies if the
52  software works as to the given hardware spec.
53 
54  For tests involving hardware, follow
55  https://github.com/start-jsk/rtmros_hironx/issues/272.
56  '''
57 
58  @classmethod
59  def setUpClass(cls):
60  cls._robot = nextage_client.NextageClient()
61  cls._robot.init()
62  cls._robot.goInitial(_GOINITIAL_TIME_MIDSPEED)
63 
64  # For older DIO version robot.
65  cls._robot_04 = nextage_client.NextageClient()
66  cls._robot_04.set_hand_version(version=cls._robot_04.HAND_VER_0_4_2)
67  cls._robot_04.init()
68  cls._robot_04.goInitial(_GOINITIAL_TIME_MIDSPEED)
69 
70  @classmethod
71  def tearDownClass(cls):
72  cls._robot.goInitial(_GOINITIAL_TIME_MIDSPEED)
73  cls._robot_04.goInitial(_GOINITIAL_TIME_MIDSPEED)
74 
76  result = self._robot._hands.airhand_l_release()
77  result = self._robot_04.airhand_l_release() and result
78  self.assertTrue(result)
79 
81  result = self._robot._hands.airhand_r_release()
82  result = self._robot_04.airhand_r_release() and result
83  self.assertTrue(result)
84 
86  result = self._robot._hands.airhand_l_drawin()
87  result = self._robot_04.airhand_l_drawin() and result
88  self.assertTrue(result)
89 
91  result = self._robot._hands.airhand_r_drawin()
92  result = self._robot_04.airhand_r_drawin() and result
93  self.assertTrue(result)
94 
96  result = self._robot._hands.airhand_l_keep()
97  result = self._robot_04.airhand_l_keep() and result
98  self.assertTrue(result)
99 
101  result = self._robot._hands.airhand_r_keep()
102  result = self._robot_04.airhand_r_keep() and result
103  self.assertTrue(result)
104 
105 if __name__ == '__main__':
106  rostest.rosrun(_PKG, 'test_nxo_airhand', TestNxoAirhand)


nextage_ros_bridge
Author(s): Isaac Isao Saito , Akio Ochiai
autogenerated on Wed Jun 17 2020 04:14:47