test_hironx_ros_bridge_controller.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, JSK Lab, University of Tokyo
7 # Copyright (c) 2014, TORK
8 # All rights reserved.
9 #
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
12 # are met:
13 #
14 # * Redistributions of source code must retain the above copyright
15 # notice, this list of conditions and the following disclaimer.
16 # * Redistributions in binary form must reproduce the above
17 # copyright notice, this list of conditions and the following
18 # disclaimer in the documentation and/or other materials provided
19 # with the distribution.
20 # * Neither the name of JSK Lab, University of Tokyo, TORK, nor the
21 # names of its contributors may be used to endorse or promote products
22 # derived from this software without specific prior written permission.
23 #
24 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 # POSSIBILITY OF SUCH DAMAGE.
36 
37 import numpy
38 import rospy
39 from tf.transformations import quaternion_matrix, euler_from_matrix
40 import time
41 
42 from hironx_ros_bridge.testutil.test_rosbridge import TestHiroROSBridge
43 
44 PKG = 'hironx_ros_bridge'
45 
46 
48 
50  goal = self.goal_RArm()
51  for av in [[-0.6, 0, -100, 15.2, 9.4, 3.2]]: #[ 25,-139,-157, 45, 0, 0]]:
52  goal = self.setup_Positions(goal, [av])
53  self.rarm.send_goal_and_wait(goal)
54  # check if tf and current link is same
55  rospy.sleep(1)
56  now = rospy.Time.now()
57  self.listener.waitForTransform("WAIST", "RARM_JOINT5_Link", now, rospy.Duration(1.0))
58  (pos_tf, rot_tf) = self.listener.lookupTransform("WAIST", "RARM_JOINT5_Link", now)
59  rot_tf = quaternion_matrix(rot_tf)[0:3,0:3]
60  pos_c = self.robot.getCurrentPosition('RARM_JOINT5','WAIST')
61  rot_c = self.robot.getCurrentRotation('RARM_JOINT5','WAIST')
62  numpy.testing.assert_array_almost_equal(pos_tf, pos_c, decimal=3)
63  numpy.testing.assert_array_almost_equal(rot_tf, rot_c, decimal=2)
64 
65  goal = self.goal_LArm()
66  for av in [[0.6, 0, -100, -15.2, 9.4, -3.2]]: #[ 25,-139,-157, 45, 0, 0]]:
67  goal = self.setup_Positions(goal, [av])
68  self.larm.send_goal_and_wait(goal)
69  # check if tf and current link is same
70  rospy.sleep(1)
71  now = rospy.Time.now()
72  self.listener.waitForTransform("WAIST", "LARM_JOINT5_Link", now, rospy.Duration(1.0))
73  (pos_tf, rot_tf) = self.listener.lookupTransform("WAIST", "LARM_JOINT5_Link", now)
74  rot_tf = quaternion_matrix(rot_tf)[0:3,0:3]
75  pos_c = self.robot.getCurrentPosition('LARM_JOINT5','WAIST')
76  rot_c = self.robot.getCurrentRotation('LARM_JOINT5','WAIST')
77  numpy.testing.assert_array_almost_equal(pos_tf, pos_c, decimal=3)
78  numpy.testing.assert_array_almost_equal(rot_tf, rot_c, decimal=2)
79 
80 if __name__ == '__main__':
81  import rostest
82  rostest.rosrun(PKG, 'test_hronx_ros_bridge_controller', TestHiroROSBridgeController)
83 
84 
85 


hironx_ros_bridge
Author(s): Kei Okada , Isaac I.Y. Saito
autogenerated on Thu May 14 2020 03:52:05