인스톨이 정상적으로 종료되면 부속되어 있는 샘플로 동작 테스트를 합니다. 샘플은 {prefix}* /share/OpenRTM-aist/examples에 있습니다(소스로 빌드·인스톨 했을 경우는 인스톨 디렉토리 이하의 /examples/<샘플 컴포넌트 세트명> 에도 있습니다). 샘플 컴포넌트 세트인 SimpleIO 를 사용하여 샘플 컴포넌트와 OpenRTM-aist 의 동작을 확인합니다.
{prefix}*: 통상 Linux라면 /usr 그 이외에서는 /usr/local 가 되는 경우가 대부분입니다. 소스로 빌드·인스톨 했을 경우는 configure 시의 옵션, --prefix 에게 준 경로( --prefix 를 설정하지 않았던 경우의 디폴트치는 /usr/local).
샘플 컴포넌트 세트 SimpleIO: RT컴포넌트 ConsoleInComp, ConsoleOutComp와 이것들의 통신을 접속하는 ConnectorComp로 된 샘플 세트입니다. 이 세트는 ConsoleInComp에게 준 수치를 ConsoleOutComp에 표시시키는 「가장 간단한 I/O 데몬스트레이션」을 목적으로 한 샘플입니다. ConsoleInComp로부터 ConsoleOutComp에 접속해, 그 통신을 개시시키는 것이 ConnectorComp의 역할입니다.
◆편의상 샘플은 usr/share/OpenRTM-aist/examples 이하에 있는 것으로서 설명을 기술합니다.
우선, rtm-naming *으로 네임서버를 기동합니다. 이 때 포트 넘버는 9876로 지정해 주십시오.
$ rtm-naming 9876 tarting omniORB omniNames: localhost.localdomain:9876 $ Wed Jun 4 23:03:09 2008: Starting omniNames for the first time. Wrote initial log file. Read log file successfully. Root context is IOR:010000002b00000049444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436f6e746578744578743a312e30000001000000000000006400000001010200100000003139322e3136382e3130302e32333600942600000b0000004e616d6553657276696365000200000000000000080000000100000000545441010000001c00000001000000010001000100000001000105090101000100000009010100 Checkpointing Phase 1: Prepare. Checkpointing Phase 2: Commit. Checkpointing completed.
* 패스는 {prefix} /bin/rtm-naming. 대개, which rtm-naming 명령어로 검색할 수 있습니다.
테스트를 위한 RTC 컨피그레이션 파일 rtc.conf를 작성해 배치합니다. 우선, 적당한 작업 디렉토리를 만듭니다. 여기에서는 편의상 홈 디렉토리 아래에 RTCwork 라고 하는 디렉토리를 작업 디렉토리로 하겠습니다. 작업 디렉토리 RTCwork에 다음과 같은 내용의 파일 rtc.conf 를 작성해 저장합니다. ※/usr/share/OpenRTM-aist/examples 아래에 있는 rtc.conf는 이 예에서는 사용할 수 없으므로, ~/RTCWork/rtc.conf 로서 새롭게 작성해 주십시오.
corba.nameservers: localhost:9876 naming.formats: %n.rtc
터미널을 기동하고 다음과 같이 2.에서 작성한 rtc.conf를 참조시키는 형태로 ConsoleInComp를 기동합니다.
$ /usr/share/OpenRTM-aist/examples/ConsoleInComp -f ~/RTCwork/rtc.conf Creating a component: "ConsoleIn"....succeed. ================================================= Component Profile ------------------------------------------------- InstanceID: ConsoleIn0 Implementation: ConsoleIn Description: Console input component Version: 1.0 Maker: Noriaki Ando, AIST Category: example Other properties ================================================= ================================================= Port0 (name): out ------------------------------------------------- - properties - port.port_type: DataOutPort dataport.data_type: TimedLong dataport.interface_type: CORBA_Any dataport.dataflow_type: Push, Pull dataport.subscription_type: Flush, New, Periodic -------------------------------------------------
자신이 빌드·인스톨 했을 경우는, {인스톨 디렉토리}/examples/SimpleIO/ConsoleInComp -f ~/RTCwork/rtc.conf 으로 ConsoleInComp를 기동합니다.
터미널을 기동하고 다음과 같이 2.에서 작성한 rtc.conf를 참조하는 형태로 ConsoleOutComp를 기동합니다.
$ /usr/share/OpenRTM-aist/examples/ConsoleOutComp -f ~/RTCwork/rtc.conf succeed. ================================================= Component Profile ------------------------------------------------- InstanceID: ConsoleOut0 Implementation: ConsoleOut Description: Console output component Version: 1.0 Maker: Noriaki Ando, AIST Category: example Other properties ================================================= ================================================= Port0 (name): in ------------------------------------------------- - properties - port.port_type: DataInPort dataport.data_type: TimedLong dataport.interface_type: CORBA_Any dataport.dataflow_type: Push, Pull dataport.subscription_type: Any -------------------------------------------------
터미널을 기동하고 다음과 같이 ConnectorComp를 기동합니다.
$ /usr/share/OpenRTM-aist/examples/ConnectorComp Subscription Type: Connector ID: f9626fe4-3243-21dd-0100-000c293a94a2 dataport.interface_type: CORBA_Any dataport.dataflow_type: Push dataport.subscription_type: dataport.corba_any.outport_ref: not a string value dataport.corba_any.inport_ref: not a string value $
자신이 빌드·인스톨 했을 경우는, {인스톨 디렉토리}/examples/SimpleIO/ConnectorComp 으로 ConnectorComp를 기동합니다.
5.ConnectorComp 의 기동 후, ConsoleInComp측의 터미널에
Please input number:
ConsoleInComp 측의 터미널에 숫자를 입력하면, ConsoleOutComp 측의 터미널에 입력한 수치가 나타납니다. 여기까지 되었다면 OpenRTM-aist가 정상적으로 인스톨 되고 있는 것을 확인할 수 있습니다.
컴포넌트의 템플릿 제네레이터를 사용하고 간단한 컴포넌트를 작성하는 테스트를 실시합니다. 템플릿 제네레이터 (rtc-template)를 사용합니다.
컴포넌트를 작성하는 디렉토리(임의의 디렉토리)를 작성하고, 컴포넌트를 작성해 컴파일 해 보겠습니다.
> cd > mkdir SampleComponent > cd SampleComponent
우선은 help를 보겠습니다.
> rtc-template --help
Usage: rtc-template [OPTIONS]
Options:
[-h] Print short help.
[--help] Print details help.
[--backend[=backend] or -b] Specify template code generator.
[--module-name[=name]] Your module name.
[--module-desc[=description]] Module description.
[--module-version[=version]] Module version.
[--module-vendor[=vendor]] Module vendor.
[--module-category[=category]] Module category.
[--module-comp-type[=component_type]] Component type.
[--module-act-type[=activity_type]] Component's activity type.
[--module-max-inst[=max_instance]] Number of maximum instance.
[--module-lang[=language]] Language.
[--config[=ParamName:Type:Default]] Configuration variable.
[--inport[=PortName:Type]] InPort's name and type.
[--outport[=PortName:Type]] OutPort's name and type
[--service[=PortName:Name:Type]] Service Provider Port
[--service-idl[=IDL_file]] IDL file name for service
[--consumer[=PortName:Name:Type]] Service Consumer Port
[--consumer-idl[=IDL_file]] IDL file name for consumer
[--idl-include=[path]] Search path for IDL compile
:
중략
:
Example:
rtc-template -bcxx --module-name=Sample --module-desc='Sample component' --module-version=0.1 --module-vendor=AIST --module-category=Generic --module-comp-type=DataFlowComponent --module-act-type=SPORADIC --module-max-inst=10 --config=int_param0:int:0 --config=int_param1:int:1 --config=double_param0:double:3.14 --config=double_param1:double:9.99 --config="str_param0:std::string:hoge" --config="str_param1:std::string:foo" --inport=Ref:TimedFloat --inport=Sens:TimedFloat --outport=Ctrl:TimedDouble --outport=Monitor:TimedShort --service=MySvcPort:myservice0:MyService --consumer=YourSvcPort:yourservice0:YourService --service-idl=MyService.idl --consumer-idl=YourService.idlrtc-template에 대해서 작성하고 싶은 컴포넌트의 설정을 인수로서 넘겨주면 컴포넌트의 양식을 작성합니다. 여기에서는, help의 표시의 마지막에 표시된 Example: 이하를 복사하고 테스트해 보겠습니다.|
interface MyService
{
void echo();
}; interface YourService
{
void echo();
};이러한 파일을 작성했다면,Example: 의 예를 복사&붙여넣기를 하는 등 커멘드로서 입력합니다.
> rtc-template -bcxx --module-name=Sample --module-desc='Sample component' --module-version=0.1 --module-vendor=AIST --module-category=Generic --module-comp-type=DataFlowComponent --module-act-type=SPORADIC --module-max-inst=10 --config=int_param0:int:0 --config=int_param1:int:1 --config=double_param0:double:3.14 --config=double_param1:double:9.99 --config="str_param0:std::string:hoge" --config="str_param1:std::string:foo" --inport=Ref:TimedFloat --inport=Sens:TimedFloat --outport=Ctrl:TimedDouble --outport=Monitor:TimedShort --service=MySvcPort:myservice0:MyService --consumer=YourSvcPort:yourservice0:YourService --service-idl=MyService.idl --consumer-idl=YourService.idl File "MyServiceSVC_impl.h" was generated. File "MyServiceSVC_impl.cpp" was generated. File "Sample.h" was generated. File "Sample.cpp" was generated. File "SampleComp.cpp" was generated. File "Makefile.Sample" was generated. File "SampleComp_vc8.vcproj" was generated. File "Sample_vc8.vcproj" was generated. File "SampleComp_vc9.vcproj" was generated. File "Sample_vc9.vcproj" was generated. File "Sample_vc8.sln" was generated. File "Sample_vc9.sln" was generated. File "copyprops.bat" was generated. File "user_config.vsprops" was generated. File "README.Sample" was generated. File "Sample.yaml" was generated. > ls Makefile.Sample Sample.h Sample_vc8.vcproj MyService.idl Sample.yaml Sample_vc9.sln MyServiceSVC_impl.cpp SampleComp.cpp Sample_vc9.vcproj MyServiceSVC_impl.h SampleComp_vc8.vcproj YourService.idl README.Sample SampleComp_vc9.vcproj copyprops.bat Sample.cpp Sample_vc8.sln user_config.vsprops
4.의 결과, 위와 같이 컴포넌트의 C++의 코드, 서비스의 구현 코드 및 Makefile 등(그 밖에 VC++관련의 파일=Windows용을 포함)이 작성됩니다. 여기서,
> make -f Makefile.Sample 혹은 > mv Makefile.Sample Makefile > make
로서 make 합니다.
> make -f Makefile.Sample
:
중략
:
g++ -o SampleComp Sample.o MyServiceSkel.o YourServiceStub.o MyServiceSVC_impl.o SampleComp.o `rtm-config --libs`
> ls
Makefile.Sample README.Sample Sample_vc9.sln
MyService.hh Sample.cpp Sample_vc9.vcproj
MyService.idl Sample.h YourService.hh
MyServiceDynSK.cc Sample.o YourService.idl
MyServiceSK.cc Sample.so YourServiceDynSK.cc
MyServiceSVC_impl.cpp Sample.yaml YourServiceSK.cc
MyServiceSVC_impl.h SampleComp YourServiceSkel.cpp
MyServiceSVC_impl.o SampleComp.cpp YourServiceSkel.h
MyServiceSkel.cpp SampleComp.o YourServiceStub.cpp
MyServiceSkel.h SampleComp_vc8.vcproj YourServiceStub.h
MyServiceSkel.o SampleComp_vc9.vcproj YourServiceStub.o
MyServiceStub.cpp Sample_vc8.sln copyprops.bat
MyServiceStub.h Sample_vc8.vcproj user_config.vsprops이것으로 loadable module판의 컴포넌트(Sample.so)와 실행 형식의 컴포넌트(SampleComp)가 작성되었습니다.
작성된 실행 형식의 컴포넌트를 실행해 보겠습니다. 먼저 그 준비를 합니다. 처음으로 CORBA 의 네임 서비스를 기동합니다. CORBA 의 네임 서비스는,
> rtm-naming [포트 번호]
로 기동할 수 있기 때문에 8.에서 작성하는 rtc.conf로 설정하는 포트 번호를 지정해 기동해 주십시오. 아무것도 지정하지 않으면 디폴트 포트(2809)를 사용합니다. 여기에서는 디폴트 포트를 사용하는 예를 들고 있습니다.
> rtm-naming Starting omniORB omniNames: rtm:2809 n-ando@rtm:/tmp/SampleComponent> Fri Apr 27 03:53:09 2007: Starting omniNames for the first time. Wrote initial log file. Read log file successfully. Root context is IOR:010000002b00000049444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436f6e746578744578743a312e300000010000000000000060000000010102000e0000003135302e32392e39362e31363900611e0b0000004e616d6553657276696365000200000000000000080000000100000000545441010000001c00000001000000010001000100000001000105090101000100000009010100 Checkpointing Phase 1: Prepare. Checkpointing Phase 2: Commit. Checkpointing completed.
$ rtm-naming Starting omniORB omniNames: localhost.localdomain: omniORB: Error: Unable to create an endpoint of this description: giop:tcp::2809 Failed to initialise the POAs. Is omniNames already running? $
이것은 해당 포트를 사용한 네임서버가 이미 기동하고 있는 것을 나타내고 있습니다. 이 경우는 그대로 다음의 7.에 진행되어 괜찮습니다.
다음에 컴포넌트를 조작하기 위한 GUI 툴:RtcLink를 기동합니다(RtcLink에 대한 자세한 것은RtcLink 를, 또 인스톨 방법 등은RtcLink·RtcTemplate의 인스톨을 참조해 주십시오).
corba.nameservers: localhost naming.formats: %n.rtc logger.log_level: PARANOID
*NOTES: corba.nameservers: rtm.or.jp:2809 (와)과 같이 corba.nameservers: 에는 호스트명 혹은 IP주소와 포토 번호(rtm.or.jp 는 호스트명, 2809는 포토 번호)를 줄 수 있습니다.
마지막으로, 컴포넌트를 기동합니다.
> ./SampleComp -f rtc.conf
혹은
> ./SampleComp (디폴트로 현재 디렉토리의 rtc.conf를 읽어들인다)