hrp.py
Go to the documentation of this file.
1 from org.omg.CORBA import *
2 from org.omg.CosNaming import *
4 
5 from java.lang import System
6 from jp.go.aist.hrp.simulator import *
7 
8 import string, math
9 
10 rootnc = None
11 
12 def unbindObject(objname):
13  nc = NameComponent(objname, "")
14  path = [nc]
15  rootnc.unbind(path)
16  return None
17 
18 def initCORBA():
19  global rootnc, orb
20  props = System.getProperties()
21 
22  args = string.split(System.getProperty("NS_OPT"))
23  orb = ORB.init(args, props)
24 
25  nameserver = orb.resolve_initial_references("NameService");
26  rootnc = NamingContextHelper.narrow(nameserver);
27  return None
28 
29 def getRootNamingContext(corbaloc):
30  props = System.getProperties()
31 
32  args = ["-ORBInitRef", corbaloc]
33  orb = ORB.init(args, props)
34 
35  nameserver = orb.resolve_initial_references("NameService");
36  return NamingContextHelper.narrow(nameserver);
37 
38 def findObject(objname, rnc=None):
39  nc = NameComponent(objname,"")
40  path = [nc]
41  if not rnc:
42  rnc = rootnc
43  return rnc.resolve(path)
44 
45 def findReceiver(objname, rnc=None):
46  try:
47  obj = findObject(objname, rnc)
48  return CommandReceiverHelper.narrow(obj)
49  except:
50  print "exception in findReceiver("+objname+")"
51 
52 def findPlugin(name, rnc=None):
53  try:
54  obj = findObject(name, rnc)
55  return PluginHelper.narrow(obj)
56  except:
57  return None
58 
59 def findPluginManager(name, rnc=None):
60  try:
61  obj = findObject(name, rnc)
62  return PluginManagerHelper.narrow(obj)
63  except:
64  print "exception in findPluginManager"
65 
66 def findWalkPlugin(name, rnc=None):
67  try:
68  obj = findObject(name, rnc)
69  return walkpluginHelper.narrow(obj)
70  except:
71  print "exception in findWalkPlugin"
72 
73 def findSeqPlugin(name, rnc=None):
74  try:
75  obj = findObject(name, rnc)
76  return SequencePlayerHelper.narrow(obj)
77  except:
78  print "exception in findSeqPlugin"
79 
80 def findLogPlugin(name, rnc=None):
81  try:
82  return LoggerPluginHelper.narrow(findObject(name, rnc))
83  except:
84  print "exception in findLogPlugin"
85 
86 def findDynamicsPlugin(name, rnc=None):
87  try:
88  return dynamicsPluginHelper.narrow(findObject(name, rnc))
89  except:
90  return None
91 
92 def findStateProvider(name, rnc=None):
93  try:
94  return stateProviderHelper.narrow(findObject(name, rnc))
95  except:
96  return None
97 
98 def findStereoVision(rnc=None):
99  try:
100  return StereoVisionHelper.narrow(findObject("StereoVision", rnc))
101  except:
102  return None
103 
104 def findStabilizerPlugin(name, rnc=None):
105  try:
106  return findPlugin(name, rnc)
107  except:
108  print "exception in findStabilizerPlugin"
109  return None
110 
111 def findIoControlPlugin(name, rnc=None):
112  try:
113  return IoControlPluginHelper.narrow(findObject(name, rnc))
114  except:
115  return None
116 
117 def findModelLoader(rnc=None):
118  try:
119  return ModelLoaderHelper.narrow(findObject("ModelLoader", rnc))
120  except:
121  return None
122 
123 def findPositionSensor(rnc=None):
124  try:
125  return positionSensorHelper.narrow(findObject("positionSensor", rnc))
126  except:
127  return None
128 
129 def findSpeakServer(rnc=None):
130  try:
131  return SpeakServerHelper.narrow(findObject("speakFactory", rnc))
132  except:
133  return None
134 
135 def findOnlineViewer(rnc=None):
136  try:
137  return OnlineViewerHelper.narrow(findObject("OnlineViewer", rnc))
138  except:
139  return None
140 
142  try:
143  return DynamicsSimulatorFactoryHelper.narrow(findObject("DynamicsSimulatorFactory", rnc))
144  except:
145  return None
146 
147 def findControllerFactory(name, rnc=None):
148  try:
149  return ControllerFactoryHelper.narrow(findObject(name, rnc))
150  except:
151  return None
152 
154  try:
155  return CollisionDetectorFactoryHelper.narrow(findObject("CollisionDetectorFactory", rnc))
156  except:
157  return None
158 
159 
160 def degrees(x):
161  return x*180/math.pi
162 
163 
164 def radians(x):
165  return x*math.pi/180
166 
167 def loadVRML(url):
168  ml = findModelLoader()
169  if ml == None:
170  return None
171  model = ml.loadURL(url)
172  co = model.getCharObject()
173  model.destroy()
174  return co
175 
176 initCORBA()
def findLogPlugin(name, rnc=None)
Definition: hrp.py:80
def findObject(objname, rnc=None)
Definition: hrp.py:38
def findSpeakServer(rnc=None)
Definition: hrp.py:129
def getRootNamingContext(corbaloc)
Definition: hrp.py:29
def initCORBA()
Definition: hrp.py:18
def findPluginManager(name, rnc=None)
Definition: hrp.py:59
def findControllerFactory(name, rnc=None)
Definition: hrp.py:147
def findDynamicsPlugin(name, rnc=None)
Definition: hrp.py:86
def findSeqPlugin(name, rnc=None)
Definition: hrp.py:73
def findOnlineViewer(rnc=None)
Definition: hrp.py:135
def findPlugin(name, rnc=None)
Definition: hrp.py:52
def findDynamicsSimulatorFactory(rnc=None)
Definition: hrp.py:141
def findReceiver(objname, rnc=None)
Definition: hrp.py:45
def degrees(x)
Definition: hrp.py:160
def findStabilizerPlugin(name, rnc=None)
Definition: hrp.py:104
def findIoControlPlugin(name, rnc=None)
Definition: hrp.py:111
def findWalkPlugin(name, rnc=None)
Definition: hrp.py:66
def findCollisionDetectorFactory(rnc=None)
Definition: hrp.py:153
def loadVRML(url)
Definition: hrp.py:167
def findPositionSensor(rnc=None)
Definition: hrp.py:123
def findModelLoader(rnc=None)
Definition: hrp.py:117
def findStateProvider(name, rnc=None)
Definition: hrp.py:92
def unbindObject(objname)
Definition: hrp.py:12
def radians(x)
Definition: hrp.py:164
def findStereoVision(rnc=None)
Definition: hrp.py:98
NameComponent
Definition: hrpPrep.py:128


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:38