Go to the documentation of this file.00001 from org.omg.CORBA import *
00002 from org.omg.CosNaming import *
00003 from org.omg.CosNaming.NamingContextPackage import *
00004
00005 from java.lang import System
00006 from jp.go.aist.hrp.simulator import *
00007
00008 import string, math
00009
00010 rootnc = None
00011
00012 def unbindObject(objname):
00013 nc = NameComponent(objname, "")
00014 path = [nc]
00015 rootnc.unbind(path)
00016 return None
00017
00018 def initCORBA():
00019 global rootnc, orb
00020 props = System.getProperties()
00021
00022 args = string.split(System.getProperty("NS_OPT"))
00023 orb = ORB.init(args, props)
00024
00025 nameserver = orb.resolve_initial_references("NameService");
00026 rootnc = NamingContextHelper.narrow(nameserver);
00027 return None
00028
00029 def getRootNamingContext(corbaloc):
00030 props = System.getProperties()
00031
00032 args = ["-ORBInitRef", corbaloc]
00033 orb = ORB.init(args, props)
00034
00035 nameserver = orb.resolve_initial_references("NameService");
00036 return NamingContextHelper.narrow(nameserver);
00037
00038 def findObject(objname, rnc=None):
00039 nc = NameComponent(objname,"")
00040 path = [nc]
00041 if not rnc:
00042 rnc = rootnc
00043 return rnc.resolve(path)
00044
00045 def findReceiver(objname, rnc=None):
00046 try:
00047 obj = findObject(objname, rnc)
00048 return CommandReceiverHelper.narrow(obj)
00049 except:
00050 print "exception in findReceiver("+objname+")"
00051
00052 def findPlugin(name, rnc=None):
00053 try:
00054 obj = findObject(name, rnc)
00055 return PluginHelper.narrow(obj)
00056 except:
00057 return None
00058
00059 def findPluginManager(name, rnc=None):
00060 try:
00061 obj = findObject(name, rnc)
00062 return PluginManagerHelper.narrow(obj)
00063 except:
00064 print "exception in findPluginManager"
00065
00066 def findWalkPlugin(name, rnc=None):
00067 try:
00068 obj = findObject(name, rnc)
00069 return walkpluginHelper.narrow(obj)
00070 except:
00071 print "exception in findWalkPlugin"
00072
00073 def findSeqPlugin(name, rnc=None):
00074 try:
00075 obj = findObject(name, rnc)
00076 return SequencePlayerHelper.narrow(obj)
00077 except:
00078 print "exception in findSeqPlugin"
00079
00080 def findLogPlugin(name, rnc=None):
00081 try:
00082 return LoggerPluginHelper.narrow(findObject(name, rnc))
00083 except:
00084 print "exception in findLogPlugin"
00085
00086 def findDynamicsPlugin(name, rnc=None):
00087 try:
00088 return dynamicsPluginHelper.narrow(findObject(name, rnc))
00089 except:
00090 return None
00091
00092 def findStateProvider(name, rnc=None):
00093 try:
00094 return stateProviderHelper.narrow(findObject(name, rnc))
00095 except:
00096 return None
00097
00098 def findStereoVision(rnc=None):
00099 try:
00100 return StereoVisionHelper.narrow(findObject("StereoVision", rnc))
00101 except:
00102 return None
00103
00104 def findStabilizerPlugin(name, rnc=None):
00105 try:
00106 return findPlugin(name, rnc)
00107 except:
00108 print "exception in findStabilizerPlugin"
00109 return None
00110
00111 def findIoControlPlugin(name, rnc=None):
00112 try:
00113 return IoControlPluginHelper.narrow(findObject(name, rnc))
00114 except:
00115 return None
00116
00117 def findModelLoader(rnc=None):
00118 try:
00119 return ModelLoaderHelper.narrow(findObject("ModelLoader", rnc))
00120 except:
00121 return None
00122
00123 def findPositionSensor(rnc=None):
00124 try:
00125 return positionSensorHelper.narrow(findObject("positionSensor", rnc))
00126 except:
00127 return None
00128
00129 def findSpeakServer(rnc=None):
00130 try:
00131 return SpeakServerHelper.narrow(findObject("speakFactory", rnc))
00132 except:
00133 return None
00134
00135 def findOnlineViewer(rnc=None):
00136 try:
00137 return OnlineViewerHelper.narrow(findObject("OnlineViewer", rnc))
00138 except:
00139 return None
00140
00141 def findDynamicsSimulatorFactory(rnc=None):
00142 try:
00143 return DynamicsSimulatorFactoryHelper.narrow(findObject("DynamicsSimulatorFactory", rnc))
00144 except:
00145 return None
00146
00147 def findControllerFactory(name, rnc=None):
00148 try:
00149 return ControllerFactoryHelper.narrow(findObject(name, rnc))
00150 except:
00151 return None
00152
00153 def findCollisionDetectorFactory(rnc=None):
00154 try:
00155 return CollisionDetectorFactoryHelper.narrow(findObject("CollisionDetectorFactory", rnc))
00156 except:
00157 return None
00158
00159
00160 def degrees(x):
00161 return x*180/math.pi
00162
00163
00164 def radians(x):
00165 return x*math.pi/180
00166
00167 def loadVRML(url):
00168 ml = findModelLoader()
00169 if ml == None:
00170 return None
00171 model = ml.loadURL(url)
00172 co = model.getCharObject()
00173 model.destroy()
00174 return co
00175
00176 initCORBA()