Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 import socket
00037
00038 from rospy import ROSInitException
00039
00040 try:
00041 import hironx_ros_bridge
00042 except:
00043 import roslib
00044 roslib.load_manifest('hironx_ros_bridge')
00045
00046 from hironx_ros_bridge import hironx_client
00047 from hironx_ros_bridge.ros_client import ROS_Client
00048
00049
00050
00051
00052 from hrpsys import rtm
00053 import argparse
00054
00055 errormsg_noros = 'No ROS Master found. Without it, you cannot use ROS from' \
00056 ' this script, but can use RTM. To use ROS, do not forget' \
00057 ' to run rosbridge. How to do so? --> http://wiki.ros.org/rtmros_nextage/Tutorials/Operating%20Hiro%2C%20NEXTAGE%20OPEN'
00058
00059 if __name__ == '__main__':
00060 parser = argparse.ArgumentParser(description='hiro command line interpreters')
00061 parser.add_argument('--host', help='corba name server hostname')
00062 parser.add_argument('--port', help='corba name server port number')
00063 parser.add_argument('--modelfile', help='robot model file nmae')
00064 parser.add_argument('--robot', help='robot modlule name (RobotHardware0 for real robot, Robot()')
00065 args, unknown = parser.parse_known_args()
00066 unknown = [u for u in unknown if u[:2] != '__']
00067
00068 if args.host:
00069 rtm.nshost = args.host
00070 if args.port:
00071 rtm.nsport = args.port
00072 if not args.robot:
00073 args.robot = "RobotHardware0" if args.host else "HiroNX(Robot)0"
00074 if not args.modelfile:
00075 args.modelfile = "/opt/jsk/etc/HIRONX/model/main.wrl" if args.host else ""
00076
00077
00078 if len(unknown) >= 2:
00079 args.robot = unknown[0]
00080 args.modelfile = unknown[1]
00081 robot = hiro = hironx_client.HIRONX()
00082 robot.init(robotname=args.robot, url=args.modelfile)
00083
00084
00085 try:
00086 ros = ROS_Client()
00087 except ROSInitException as e:
00088 print('[nextage.py] {}'.format(e))
00089 except socket.error as e:
00090 print("\033[31m%s\n%s\033[0m" % (e.strerror, errormsg_noros))
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102