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 00046 if __name__ == '__main__': 00047 parser = argparse.ArgumentParser(description='hiro command line interpreters') 00048 parser.add_argument('--host', help='corba name server hostname') 00049 parser.add_argument('--port', help='corba name server port number') 00050 parser.add_argument('--modelfile', help='robot model file nmae') 00051 parser.add_argument('--robot', help='robot modlule name (RobotHardware0 for real robot, Robot()') 00052 args, unknown = parser.parse_known_args() 00053 00054 if args.host: 00055 rtm.nshost = args.host 00056 if args.port: 00057 rtm.nsport = args.port 00058 if not args.robot: 00059 args.robot = "RobotHardware0" if args.host else "HiroNX(Robot)0" 00060 if not args.modelfile: 00061 args.modelfile = "" 00062 00063 # support old style format 00064 if len(unknown) >= 2: 00065 args.robot = unknown[0] 00066 args.modelfile = unknown[1] 00067 robot = nxc = nextage_client.NextageClient() 00068 # Use generic name for the robot instance. This enables users on the 00069 # script commandline (eg. ipython) to run the same commands without asking 00070 # them to specifically tell what robot they're using (eg. hiro, nxc). 00071 # This is backward compatible so that users can still keep using `nxc`. 00072 # See http://code.google.com/p/rtm-ros-robotics/source/detail?r=6926 00073 robot.init(robotname=args.robot, url=args.modelfile) 00074 00075 # for simulated robot 00076 # $ ./hironx.py 00077 # 00078 # for real robot 00079 # ./hironx.py --host hiro014 00080 # ./ipython -i hironx.py --host hiro014 00081 # for real robot with custom model file 00082 # ./hironx.py --host hiro014 --modelfile /opt/jsk/etc/HIRONX/model/main.wrl