[openrtm-users 00464] Re: OpenRTM-Python のサービスの参照について: some feedback

kurihara shinji shinji.kurihara @ aist.go.jp
2008年 6月 5日 (木) 18:31:08 JST


Dear Florent Lamiraux,

Thank you very much for your feedback.

> 1. The OpenRTM-Python package that I have downloaded from OpenRTM 
> web-page (OpenRTM-aist-Python-0.4.1-RC1.tar.gz) contains some compiled 
> python xxx_idl.py generated using a version of omniidl older than the 
> one installed on my computer. For this reason, I have regenerated those 
> files by invoking omniidl:
Sorry, when installing OpenRTM-aist-Python, IDL compile is done in the 
next release version. 

> Notice that I installed OpenRTM-Python in a user directory (not in 
> /usr/lib) and defined PYTHONPATH environment variable accordingly. In 
> this case, python interpreter does not search recursively 
> sub-directories of PYTHONPATH paths. That is why I had to add the 
> following lines:
Does the OpenRTM.pth file exist in the same hierarchy as the OpenRTM directory?

for example:
  > cd tmp
  > ls 
  OpenRTM/  OpenRTM.pth

  > more OpenRTM.pth
  OpenRTM
  OpenRTM/RTM_IDL


> Then, I could call all fonctions defined in my idl interface, except one 
> function with an out parameter:
> 
> boolean hppWalkPlannerComp::service::solve(out SwalkPlanFootInPlaneSeq 
> outStepSequence);
> 
> The function was correctly executed in the RTM component, but the result 
> could not reach the python interpreter.
Is the call of hppWalkPlannerComp::service::solve() from the client
side as follows?

  ret, outSepSequence = walkPlannerClient.solve()


Best regards,
Shinji Kurihara




On Thu, 05 Jun 2008 15:45:18 +0900
Florent Lamiraux <florent @ laas.fr> wrote:

> Dear Kurihara san,
> 
> I am currently working with Neo San on an RTM component wrapping path 
> planning functions for a humanoid robot.
> 
> One month ago, Neo San sent you an e-mail to know how to implement a 
> python client to an OpenRTM component. You sent the reply to Neo San who 
> forwarded me the solution.
> 
> First, thank you very much for your help.
> Second, I would like to give you some feedback about my experience.
> 
> I have implemented the solution you suggested me but I ran into some 
> troubles that I am going to describe you.
> 
> 1. The OpenRTM-Python package that I have downloaded from OpenRTM 
> web-page (OpenRTM-aist-Python-0.4.1-RC1.tar.gz) contains some compiled 
> python xxx_idl.py generated using a version of omniidl older than the 
> one installed on my computer. For this reason, I have regenerated those 
> files by invoking omniidl:
> 
> cd OpenRTM/RTM_IDL
> omniidl -bpython BasicDataType.idl
> omniidl -bpython DataPort.idl
> omniidl -bpython OpenRTM.idl
> omniidl -bpython RTC.idl
> omniidl -bpython SDOPackage.idl
> 
> 2. Then, I have followed your instruction in my python file:
> 
> -----------------------------------------------------------
> import sys, os
> import re
> 
> pythonPath = os.environ.get("PYTHONPATH")
> pathList = re.split(':', pythonPath)
> 
> for path in pathList:
>      addPath1 = path+"/OpenRTM"
>      addPath2 = path+"/OpenRTM/RTM_IDL"
>      sys.path.append(addPath1)
>      sys.path.append(addPath2)
> 
> import omniORB
> import RTC
> from CorbaNaming import *
> 
> CORBA = omniORB.CORBA
> from omniORB import any
> 
> import hppWalkPlannerComp
> 
> import string
> from math import sin, cos, pi
> 
> orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
> 
> naming = CorbaNaming(orb, "localhost:2024")
> rtObjRef = naming.resolve("walkPlannerORTM0.rtc")
> 
> rtObject = rtObjRef._narrow(RTC.RTObject)
> 
> componentPorts = rtObject.get_ports()
> 
> connectorProfile = 
> RTC.ConnectorProfile("connect0","",[componentPorts[0]],[])
> ret,cntProf = componentPorts[0].connect(connectorProfile)
> 
> componentServiceRef = 
> any.from_any(cntProf.properties[0].value,keep_structs=True)
> walkPlannerClient = componentServiceRef._narrow(hppWalkPlannerComp.service)
> 
> -----------------------------------------------------------
> 
> Notice that I installed OpenRTM-Python in a user directory (not in 
> /usr/lib) and defined PYTHONPATH environment variable accordingly. In 
> this case, python interpreter does not search recursively 
> sub-directories of PYTHONPATH paths. That is why I had to add the 
> following lines:
> 
> -----------------------------------------------------------
> 
> for path in pathList:
>      addPath1 = path+"/OpenRTM"
>      addPath2 = path+"/OpenRTM/RTM_IDL"
>      sys.path.append(addPath1)
>      sys.path.append(addPath2)
> 
> -----------------------------------------------------------
> 
> Then, I could call all fonctions defined in my idl interface, except one 
> function with an out parameter:
> 
> boolean hppWalkPlannerComp::service::solve(out SwalkPlanFootInPlaneSeq 
> outStepSequence);
> 
> The function was correctly executed in the RTM component, but the result 
> could not reach the python interpreter.
> 
> I then modified my client file as follows, using another python CORBA 
> python that works well.
> 
> -----------------------------------------------------------
> 
> import sys, os
> import re
> 
> pythonPath = os.environ.get("PYTHONPATH")
> pathList = re.split(':', pythonPath)
> 
> for path in pathList:
>      addPath1 = path+"/OpenRTM"
>      addPath2 = path+"/OpenRTM/RTM_IDL"
>      sys.path.append(addPath1)
>      sys.path.append(addPath2)
> 
> from omniORB import CORBA
> import RTC
> from omniORB import any
> 
> import CosNaming, hppWalkPlannerComp
> orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
> 
> obj = orb.resolve_initial_references("NameService")
> rootContext = obj._narrow(CosNaming.NamingContext)
> 
> if rootContext is None:
>    print "failed to narrow the root naming context"
>    sys.exit(1)
> 
> #Create Robot client
> compName = [CosNaming.NameComponent("walkPlannerORTM0", "rtc")]
> 
> try:
>    rtObjRef = rootContext.resolve(compName)
> except CosNaming.NamingContext.NotFound, ex:
>    print "walkPlannerORTM0.rtc not found"
>    sys.exit(1)
> 
> rtObject = rtObjRef._narrow(RTC.RTObject)
> 
> componentPorts = rtObject.get_ports()
> 
> connectorProfile = 
> RTC.ConnectorProfile("connect0","",[componentPorts[0]],[])
> ret,cntProf = componentPorts[0].connect(connectorProfile)
> 
> componentServiceRef = 
> any.from_any(cntProf.properties[0].value,keep_structs=True)
> walkPlannerClient = componentServiceRef._narrow(hppWalkPlannerComp.service)
> 
> -----------------------------------------------------------
> 
> And now, it works perfectly.
> 
> I hope this information can be useful to you.
> Thank you for your help.
> 
> Sincerely yours,
> 
> Florent Lamiraux
> Joint Robotics Laboratory AIST-CNRS
> 


-- 
----------
栗原 眞二
shinji.kurihara @ aist.go.jp
kurihara @ imagination.co.jp



openrtm-users メーリングリストの案内