test_nxopen_norostest.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 # Software License Agreement (BSD License)
00005 #
00006 # Copyright (c) 2013, Tokyo Opensource Robotics Kyokai Association
00007 # All rights reserved.
00008 #
00009 # Redistribution and use in source and binary forms, with or without
00010 # modification, are permitted provided that the following conditions
00011 # are met:
00012 #
00013 #  * Redistributions of source code must retain the above copyright
00014 #    notice, this list of conditions and the following disclaimer.
00015 #  * Redistributions in binary form must reproduce the above
00016 #    copyright notice, this list of conditions and the following
00017 #    disclaimer in the documentation and/or other materials provided
00018 #    with the distribution.
00019 #  * Neither the name of Tokyo Opensource Robotics Kyokai Association. nor the
00020 #    names of its contributors may be used to endorse or promote products
00021 #    derived from this software without specific prior written permission.
00022 #
00023 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034 # POSSIBILITY OF SUCH DAMAGE.
00035 #
00036 # Author: Isaac Isao Saito
00037 
00038 # This should come earlier than later import.
00039 # See http://code.google.com/p/rtm-ros-robotics/source/detail?r=6773
00040 from nextage_ros_bridge import nextage_client
00041 
00042 from hrpsys import rtm
00043 import argparse
00044 
00045 _ARMGROUP_TESTED = 'rarm'
00046 _LINK_TESTED = 'RARM_JOINT5'
00047 
00048 
00049 class TestNextageNoRostest(object):
00050     '''
00051     Test NextageClient without relying on rostest.
00052     This can be upgraded to rostest version that is more ideal/almost required
00053     for ROS package.
00054     '''
00055 
00056     def __init__(self, nc):
00057         '''
00058         @type nc: NextageClient
00059         '''
00060         self._nxc = nc
00061 
00062 #    def test_set_relative_x(self):
00063     def test_set_relative(self, dx=0, dy=0, dz=0):
00064         #print('Start moving dx={0}, dy={0}, dz={0}'.format(dx, dy, dz))
00065         self._nxc.seq_svc.setMaxIKError(0.00001, 0.01)
00066         posi_prev = self._nxc.getCurrentPosition(_LINK_TESTED)
00067         for i in range(200):
00068             self._nxc.setTargetPoseRelative(_ARMGROUP_TESTED, _LINK_TESTED,
00069                                             dx, dy, dz, tm=0.2)
00070             #print('   joint=', nxc.getJointAngles()[3:9])
00071         posi_post = self._nxc.getCurrentPosition(_LINK_TESTED)
00072 
00073 
00074 if __name__ == '__main__':
00075     parser = argparse.ArgumentParser(description='hiro command line interpreters')
00076     parser.add_argument('--host', help='corba name server hostname')
00077     parser.add_argument('--port', help='corba name server port number')
00078     parser.add_argument('--modelfile', help='robot model file nmae')
00079     parser.add_argument('--robot', help='robot modlule name (RobotHardware0 for real robot, Robot()')
00080     args, unknown = parser.parse_known_args()
00081 
00082     if args.host:
00083         rtm.nshost = args.host
00084     if args.port:
00085         rtm.nsport = args.port
00086     if not args.robot:
00087         args.robot = "RobotHardware0" if args.host else "HiroNX(Robot)0"
00088     if not args.modelfile:
00089         args.modelfile = ""
00090 
00091     # support old style format
00092     if len(unknown) >= 2:
00093         args.robot = unknown[0]
00094         args.modelfile = unknown[1]
00095     nxc = nextage_client.NextageClient()
00096     nxc.init(robotname=args.robot, url=args.modelfile)
00097     nxc.goInitial()
00098     tnn = TestNextageNoRostest(nxc)
00099 #    tnn.test_set_relative_x()
00100     tnn.test_set_relative(dx=0.0001)
00101     tnn.test_set_relative(dy=0.0001)
00102     tnn.test_set_relative(dz=0.0001)


nextage_ros_bridge
Author(s): Isaac Isao Saito , Akio Ochiai
autogenerated on Wed May 15 2019 04:45:36