test_nxopen.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) 2013, 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 Isao Saito
37 
38 # This should come earlier than later import.
39 # See http://code.google.com/p/rtm-ros-robotics/source/detail?r=6773
40 import unittest
41 
42 from hrpsys import rtm
43 from nextage_ros_bridge import nextage_client
44 
45 _ARMGROUP_TESTED = 'larm'
46 _LINK_TESTED = 'LARM_JOINT5'
47 _GOINITIAL_TIME_MIDSPEED = 3 # second
48 _NUM_CARTESIAN_ITERATION = 300
49 _PKG = 'nextage_ros_bridge'
50 
51 
52 class TestNextageopen(unittest.TestCase):
53  '''
54  Test NextageClient with rostest.
55  '''
56 
57  @classmethod
58  def setUpClass(self):
59 
60  modelfile = '/opt/jsk/etc/NEXTAGE/model/main.wrl'
61  rtm.nshost = 'nxc100'
62  robotname = "RobotHardware0"
63 
64  self._robot = nextage_client.NextageClient()
65  self._robot.init(robotname=robotname, url=modelfile)
66 
67  self._robot.goInitial(_GOINITIAL_TIME_MIDSPEED)
68 
69 # def test_set_relative_x(self):
70  def _set_relative(self, dx=0, dy=0, dz=0):
71  #print('Start moving dx={0}, dy={0}, dz={0}'.format(dx, dy, dz))
72  self._robot.seq_svc.setMaxIKError(0.00001, 0.01)
73  posi_prev = self._robot.getCurrentPosition(_LINK_TESTED)
74  for i in range(_NUM_CARTESIAN_ITERATION):
75  self._robot.setTargetPoseRelative(
76  _ARMGROUP_TESTED, _LINK_TESTED, dx, dy, dz, tm=0.15)
77  #print(' joint=', nxc.getJointAngles()[3:9])
78  posi_post = self._robot.getCurrentPosition(_LINK_TESTED)
79 
80  diff_result = posi_post
81  for i in range(len(posi_prev)):
82  diff_result[i] = posi_prev[i] - posi_post[i]
83  print('Position diff={}'.format(diff_result))
84  return True
85 
87  self._robot.goInitial(_GOINITIAL_TIME_MIDSPEED)
88  assert(self._set_relative(dx=0.0001))
89 
91  self._robot.goInitial(_GOINITIAL_TIME_MIDSPEED)
92  assert(self._set_relative(dy=0.0001))
93 
95  self._robot.goInitial(_GOINITIAL_TIME_MIDSPEED)
96  assert(self._set_relative(dz=0.0001))
97 
98 if __name__ == '__main__':
99  import rostest
100  rostest.rosrun(_PKG, 'test_nxopen', TestNextageopen)
def test_set_targetpose_relative_dy(self)
Definition: test_nxopen.py:90
def test_set_targetpose_relative_dz(self)
Definition: test_nxopen.py:94
def _set_relative(self, dx=0, dy=0, dz=0)
Definition: test_nxopen.py:70
def test_set_targetpose_relative_dx(self)
Definition: test_nxopen.py:86


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