test_nxopen_norostest.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 from nextage_ros_bridge import nextage_client
41 
42 from hrpsys import rtm
43 import argparse
44 
45 _ARMGROUP_TESTED = 'rarm'
46 _LINK_TESTED = 'RARM_JOINT5'
47 
48 
49 class TestNextageNoRostest(object):
50  '''
51  Test NextageClient without relying on rostest.
52  This can be upgraded to rostest version that is more ideal/almost required
53  for ROS package.
54  '''
55 
56  def __init__(self, nc):
57  '''
58  @type nc: NextageClient
59  '''
60  self._nxc = nc
61 
62 # def test_set_relative_x(self):
63  def test_set_relative(self, dx=0, dy=0, dz=0):
64  #print('Start moving dx={0}, dy={0}, dz={0}'.format(dx, dy, dz))
65  self._nxc.seq_svc.setMaxIKError(0.00001, 0.01)
66  posi_prev = self._nxc.getCurrentPosition(_LINK_TESTED)
67  for i in range(200):
68  self._nxc.setTargetPoseRelative(_ARMGROUP_TESTED, _LINK_TESTED,
69  dx, dy, dz, tm=0.2)
70  #print(' joint=', nxc.getJointAngles()[3:9])
71  posi_post = self._nxc.getCurrentPosition(_LINK_TESTED)
72 
73 
74 if __name__ == '__main__':
75  parser = argparse.ArgumentParser(description='hiro command line interpreters')
76  parser.add_argument('--host', help='corba name server hostname')
77  parser.add_argument('--port', help='corba name server port number')
78  parser.add_argument('--modelfile', help='robot model file nmae')
79  parser.add_argument('--robot', help='robot modlule name (RobotHardware0 for real robot, Robot()')
80  args, unknown = parser.parse_known_args()
81 
82  if args.host:
83  rtm.nshost = args.host
84  if args.port:
85  rtm.nsport = args.port
86  if not args.robot:
87  args.robot = "RobotHardware0" if args.host else "HiroNX(Robot)0"
88  if not args.modelfile:
89  args.modelfile = ""
90 
91  # support old style format
92  if len(unknown) >= 2:
93  args.robot = unknown[0]
94  args.modelfile = unknown[1]
95  nxc = nextage_client.NextageClient()
96  nxc.init(robotname=args.robot, url=args.modelfile)
97  nxc.goInitial()
99 # tnn.test_set_relative_x()
100  tnn.test_set_relative(dx=0.0001)
101  tnn.test_set_relative(dy=0.0001)
102  tnn.test_set_relative(dz=0.0001)


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