[openrtm-users 02847] Re: コンポーネントの中からコンポーネントを終了する
Kei Okada
k-okada @ jsk.t.u-tokyo.ac.jp
2013年 7月 23日 (火) 11:49:10 JST
岡田です.
ありがとうございます.
ご教示いただいた内容を
追加して,こちらで試すと,10秒ぐらいプログラムが停止したあと,以下のようにエラーになります.私は1.1.0を使っています.
prev data = 356 , current data = 357
2 12712
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 504, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/k-okada/ros/fuerte/rtm-ros-robotics/rtmros_common/openrtm/src/openrtm/OpenRTM_aist/Task.py",
line 80, in svc_run
self.svc()
File "/home/k-okada/ros/fuerte/rtm-ros-robotics/rtmros_common/openrtm/src/openrtm/OpenRTM_aist/PeriodicExecutionContext.py",
line 450, in svc
comp._sm.worker()
File "/home/k-okada/ros/fuerte/rtm-ros-robotics/rtmros_common/openrtm/src/openrtm/OpenRTM_aist/PeriodicExecutionContext.py",
line 317, in worker
return self._sm.worker()
File "/home/k-okada/ros/fuerte/rtm-ros-robotics/rtmros_common/openrtm/src/openrtm/OpenRTM_aist/StateMachine.py",
line 469, in worker
self._do[states.curr](states)
File "/home/k-okada/ros/fuerte/rtm-ros-robotics/rtmros_common/openrtm/src/openrtm/OpenRTM_aist/PeriodicExecutionContext.py",
line 256, in on_execute
if self._obj.on_execute(self.ec_id) != RTC.RTC_OK:
File "/home/k-okada/ros/fuerte/rtm-ros-robotics/rtmros_common/openrtm/src/openrtm/OpenRTM_aist/RTM_IDL/RTC_idl.py",
line 401, in on_execute
return _omnipy.invoke(self, "on_execute",
_0_RTC.DataFlowComponentAction._d_on_execute, args)
BAD_INV_ORDER: CORBA.BAD_INV_ORDER(omniORB.BAD_INV_ORDER_WouldDeadLock,
CORBA.COMPLETED_NO)
Traceback (most recent call last):
File "/home/k-okada/ros/fuerte/rtm-ros-robotics/rtmros_common/openrtm/src/openrtm/OpenRTM_aist/CorbaNaming.py",
line 616, in unbind
self._rootContext.unbind(name_)
File "/usr/lib/python2.7/dist-packages/CosNaming_idl.py", line 234, in unbind
return _omnipy.invoke(self, "unbind",
_0_CosNaming.NamingContext._d_unbind, args)
NotFound: CosNaming.NamingContext.NotFound(why=missing_node,
rest_of_name=[CosNaming.NameComponent(id='test_seqio0', kind='rtc')])
2013/7/23 Ando Noriaki <n-ando @ aist.go.jp>:
> 岡田先生
>
> 安藤です
>
> 添付のコードを実行するとどうなりますか?
>
> if ( self.data_received > 10 ) :
> mgr.shutdown()
>
> だと、プロセスごと終了になります。
> コンポーネントだけを終了させたかったら
> self.exit()
> でいけそうな気もするのですが、onExecute() の中で呼べたかどうかは
> 確信がありません。
>
>
>
>
> 2013/7/22 Kei Okada <k-okada @ jsk.t.u-tokyo.ac.jp>:
>> 岡田です.
>>
>> コンポーネントの中からコンポーネントを終了させる,というようなことはできるのでしょうか?
>> 具体的には,例えばonExecuteで10回データをもらったら,exitしたい,と思っています.
>>
>> # rtm modules
>> import sys, time, signal
>> import RTC
>> import OpenRTM_aist
>>
>> global mgr
>>
>> class TestComp(OpenRTM_aist.DataFlowComponentBase):
>> def __init__ (self, manager):
>> OpenRTM_aist.DataFlowComponentBase.__init__(self, manager)
>> return
>>
>> def onInitialize(self):
>> port = "Short"
>> self.inport = OpenRTM_aist.InPort(port, RTC.TimedShort)
>> self.registerInPort(port, self.inport)
>> self.data_received = 0
>>
>> return RTC.RTC_OK
>>
>> def onExecute(self, ec_id):
>> if self.inport.isNew():
>> data = self.inport.read()
>> print data
>> self.data_received += 1
>> if ( self.data_received > 10 ) :
>> mgr.shutdown()
>>
>> return RTC.RTC_OK
>>
>> module_spec = ["implementation_id", "test_seqio",
>> "type_name", "test_seqio",
>> "description", "Dataport ROS bridge component",
>> "version", "1.0",
>> "vendor", "Kei Okada",
>> "category", "example",
>> "activity_type", "DataFlowComponent",
>> "max_instance", "10",
>> "language", "Python",
>> "lang_type", "script",
>> ""]
>>
>> def TestInit(manager):
>> profile = OpenRTM_aist.Properties(defaults_str=module_spec)
>> print profile
>> manager.registerFactory(profile,
>> TestComp,
>> OpenRTM_aist.Delete)
>> comp = manager.createComponent("test_seqio")
>>
>> def test_seqio():
>> mgr = OpenRTM_aist.Manager.init(sys.argv)
>> mgr.setModuleInitProc(TestInit)
>> mgr.activateManager()
>> mgr.runManager()
>> _______________________________________________
>> openrtm-users mailing list
>> openrtm-users @ openrtm.org
>> http://www.openrtm.org/mailman/listinfo/openrtm-users
> _______________________________________________
> openrtm-users mailing list
> openrtm-users @ openrtm.org
> http://www.openrtm.org/mailman/listinfo/openrtm-users
More information about the openrtm-users
mailing list