hironx.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, JSK Lab, University of Tokyo
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 JSK Lab, University of Tokyo. 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 
00037 try:  # catkin does not requires load_manifest
00038     import hironx_ros_bridge
00039 except:
00040     import roslib
00041     roslib.load_manifest('hironx_ros_bridge')
00042 
00043 from hironx_ros_bridge import hironx_client
00044 from hironx_ros_bridge.ros_client import ROS_Client
00045 
00046 # See 'https://github.com/tork-a/rtmros_nextage/commit/' +
00047 #     'd4268d81ec14a514bb4b3b52614c81e708dd1ecc#' +_
00048 #     'diff-20257dd6ad60c0892cfb122c37a8f2ba'
00049 from hrpsys import rtm
00050 import argparse
00051 
00052 if __name__ == '__main__':
00053     parser = argparse.ArgumentParser(description='hiro command line interpreters')
00054     parser.add_argument('--host', help='corba name server hostname')
00055     parser.add_argument('--port', help='corba name server port number')
00056     parser.add_argument('--modelfile', help='robot model file nmae')
00057     parser.add_argument('--robot', help='robot modlule name (RobotHardware0 for real robot, Robot()')
00058     args, unknown = parser.parse_known_args()
00059     unknown = [u for u in unknown if u[:2] != '__'] # filter out ros arguments
00060 
00061     if args.host:
00062         rtm.nshost = args.host
00063     if args.port:
00064         rtm.nsport = args.port
00065     if not args.robot:
00066         args.robot = "RobotHardware0" if args.host else "HiroNX(Robot)0"
00067     if not args.modelfile:
00068         args.modelfile = ""
00069 
00070     # support old style format
00071     if len(unknown) >= 2:
00072         args.robot = unknown[0]
00073         args.modelfile = unknown[1]
00074     robot = hiro = hironx_client.HIRONX()
00075     robot.init(robotname=args.robot, url=args.modelfile)
00076 
00077     # ROS Client
00078     ros = ROS_Client()
00079 
00080 # for simulated robot
00081 # $ ./hironx.py
00082 #
00083 # for real robot
00084 # ../script/hironx.py -- --host hiro014
00085 # ./ipython -i hironx.py -- --host hiro014
00086 # for real robot with custom model file
00087 # ../script/hironx.py -- --host hiro014 --modelfile /opt/jsk/etc/HIRONX/model/main.wrl
00088 #
00089 # See http://unix.stackexchange.com/questions/11376/what-does-double-dash-mean
00090 # for the use of double-dash on unix/linux.


hironx_ros_bridge
Author(s): Kei Okada
autogenerated on Sun Sep 13 2015 23:21:39