OpenRTM-aist is a reference implementation of RT-Middleware which The National Institute of Advanced Industrial Science and Technology - Intelligent Systems Research Institute - Task Intelligence Research Group, has been implementing, distributing, maintaining. The RT-Middleware as well as OpenRTM-aist are the software platforms which divide the various functional components of the robot into the part unit called RT-Component and support the construction of various robotic systems by the integration of various these elements. Currently, in OMG(Object Management Group), these are conformed to the Robotic Technology Component Specification which have been decided.
OpenRTM-aist Java is that OpenRTM-aist for C++ has been ported to Java. OpenRTM-aist Java which has OpenRTM-aist compatible interfaces for C++ enable to use both RT-Component developed using Java and RT-Component developed using C++.
This manual provides procedures for development of RT-Components for Java using OpenRTM-aist Java. This manual targets those who have the basic knowledge of Java.
Here is a list of environments that are required to run OpenRTM-aist Java.
Environment | Notes |
Java Development Kit 5.0 (JDK 5) (http://java.sun.com/products/archive/j2se/5.0_12/index.html ) |
Java1.4 is not supported. |
Here we explain on procedures to develop RT-Components for Java. We will use a component with the following specifications as a sample.
Basic profile | |
Component Name | sample |
Discription | SampleComponent |
Version | 1.0 |
Vendor | AIST |
Category | example |
Component Type | DataFlowComponent |
Activity Type | SPORADIC |
Maximum number of instances | 5 |
Data InPort | |
Name | in |
Type | TimedLong |
ServiceProvider | |
IDLPath | IDLs/MyService.idl See Note |
Port Name | MySvcPort |
Service Name | myservice0 |
Service Type | MyService |
Configuration parameter | |
Name | multiply |
Parameter Type | int |
Default value | 1 |
Note: MyService.idl creates the following IDL file using the appropriate editor. Also, the "IDL Path" in above table is specified to the MyService.idl Path. On Windows, this "IDL Path" must be the full path to MyService.idl.
typedef sequence<string> EchoList; typedef sequence<float> ValueList; interface MyService { string echo(in string msg); EchoList get_echo_history(); void set_value(in float value); float get_value(); ValueList get_value_history(); };
First, you generate the skeleton of RT-Component which you would like to develop using rtc-template. The rtc-templates which have used on CUI as well as GUI are distinguished as rtc-template (for CUI) and RtcTmplate (for GUI). (Otherwise, when rtc-template is described simply, it means that it is used as general term of CUI edition and GUI edition.)
-rtc-template for CUI
When RT-Component which has the following specifications described in Table3-2 is generated using rtc-template for CUI, run this command.
rtc-template -bjava --module-name=Sample --desc= 'Sample Component' --module-version=1.0 --module-vendor=AIST --module-category=example --module-comp-type=DataFlowComponent --module-act-type=SPORADIC --module-max-inst=5 --inport=in:TimedLong --service=MySvcPort:myservice0:MyService --service-idl=IDLs/MyService.idl --config="multiply:int:1"
Note:When rtc-template is executed in the windows environment, you must enclose in double quotation (") such as "Sample component". When enclose in single quotation ('), the options can't work. Also, the line continuous symbols are need to be modified from (\) to (^).
> $ANT_HOME$bin\ant -f build_Sample.xml
:On the next step of "New Project" wizard, enter "project name" in the dialog box. Check setting of "Compiler compliance level" in "JDK Compliance" is over "5.0" (or over 1.5) and press [Next] button.|
: By specifying the project directory as "Output directory" field, a variety of generated files are to be added to the project (automatically).|
Note In the case of RT-Components which define service ports, errors occur when there are only files generated by Rtctemplate. It is because some of generated files use classes which are generated from IDL files. These required classes will be generated automatically when you build the component.
Note:If OpenRTM-aist Java is not installed on a location which the classpath of the project refers, errors occur, In this case, modify Java Build Path properly of the project, and include the install folder(directory) of OpenRTM-aist Java in the classpath.
corba.nameservers: localhost naming.formats: %n.rtc
> java SampleComp
The relation between source files of RT-Components for Java, and general functions included in each file is shown in Fig.3-21. For comparison, RT-Components for C++ and RT-Components Java for OpenRTM-aist-0.3 are also shown.
This change make it mandatory for component launch classes to implement those interfaces.
In OpenRTM-aist Java, Holder class (DataRef Class) is added to pass data. This changes on how to define and use data ports as follows:
RT-Components for Java | RT-Components for C++ |
//Definition of InPort protected TimedShort m_in_val protected DataRef<TimedLong> m_in; protected InPort<TimedLong> m_inIn; //Registration of InPort m_in_val = new TimedLong(); m_in = new DataRef<TimedLong>(m_in_val); m_inIn = new InPort<TimedLong>("in",m_in); registerInPort(TimedLong.class,"in",m_inIn); //Reading data from InPort m_inIn.read(); Input Data = m_in.v.data; |
//Definition of InPort TimedShort m_in; InPort<TimedShort> m_inIn; //Registration of InPort m_inIn = new InPort<TimedLong>("in",m_in); registerInPort("in",m_inIn); //Reading data from InPort m_inIn.read(); Input Data = m_in.data; |
//Definition of OutPort protected TimedFloat m_out_val; protected DataRef<TimedFloat> m_out; protected OutPort<TimedFloat> m_outOut; //Registration of OutPort m_out_val = new TimedFloat(); m_out = new DataRef<TimedFloat>(m_out_val); m_outOut = new OutPort<TimedLong>("out",m_out); registerOutPort(TimedLong.class,"out",m_outOut); //Writing data to OutPort m_out_val.data = Output Data; m_outOut.write(); |
//Definition of OutPort TimedFloat m_out; OutPort<TimedFLoat> m_outOut; //Registration of OutPort m_outOut = new OutPort<TimedFloat>("out",m_out); registerOutPort("out",m_outOut); //Writing data to OutPort m_out.data = Output Data; m_outOut.write(); |
In OpenRTM-aist Java, the auxiliary variables (<Service Name>Base) for using service ports are added. This changes on how to define and use service ports as follows. For more detail, refer to the samples of "SimpleService".
RT-Components for Java | RT-Components for C++ |
//Definition of Consumer protected CorbaPort m_MyServicePort; protected CorbaConsumer<MyService> m_myservice0Base = new CorbaConsumer<MyService>(MyService.class); protected MyService m_myservice0; //Registration of Consumer m_MyServiceRef = new CorbaPort("MyService"); m_MyServicePort.registerConsumer ("myservice0","MyService",m_myservice0Base); registerPort(m_MyServicePort); //Use of Consumer m_myservice0 = m_myservice0Base._ptr(); m_myservice0.echo(argv[1]); |
//Definition of Consumer RTC::CorbaPort m_MyServicePort; RTC::CorbaConsumer<MyService> m_myservice0; //Registration of Consumer m_MyServicePort = new RTC::CorbaPort("MyService"); m_MyServicePort.registerConsumer ("myservice0","MyService", m_myservice0); registerPort(m_MyServicePort); //Use of Consumer m_myservice0->echo(argv[1].c_str()); |
//Definition of Provider protected CorbaPort m_MyServicePort; protected MyServiceSVC_impl m_myservice0 = new MyServiceSVC_impl(); //Registration of Provider m_MyServiceRef = new CorbaPort("MyService"); m_MyServicePort.registerProvider ("myservice0","MyService",m_myservice0); registerPort(m_MyServicePort); |
//Definition of Provider RTC::CorbaPort m_MyServicePort; MyServiceSVC_impl m_myservice0; //Registration of Provider m_MyServicePort = new RTC::CorbaPort("MyService"); m_MyServicePort.registerProvider ("myservice0","MyService",m_myservice0); registerPort(m_MyServicePort); |
Holder classes are used for configurations as well as data ports. This changes the way how to define and use configuration data as follows:
RT-Components for Java | RT-Components for C++ |
//Definition of Configuration Variable protected IntegerHolder m_int_param0 = new IntegerHolder(); protected StringHolder m_str_param0 = new StringHolder(); protected VectorHolder m_vector_param0= new VectorHolder(); //Bind parameters bindParameter("int_param0",m_int_param_0,"0"); bindParameter("str_param0",m_str_param_0,"sample"); bindParameter("vector_param0",m_vector_param_0,"0.0,1.0,2.0,3.0,4.0"); |
//Definition of Configuration Variable int m_int_param0; str::string m_str_param0; str::vector<double> m_vector_param0; //Bind parameters bindParameter("int_param0",m_int_param_0,"0"); bindParameter("str_param0",m_str_param_0,"sample"); bindParameter("vector_param0",m_vector_param_0,"0.0,1.0,2.0,3.0,4.0"); |
Please refer to samples of "ConfigSample", about how to use configuration data.
Table 3-3 shows kinds of holder classes provided in OpenRTM-aist Java to hold configuration data, and their releations with their data types.
Data type | Holder class |
short | jp.go.aist.rtm.RTC.util.ShortHolder |
int | jp.go.aist.rtm.RTC.util.IntegerHolder |
long | jp.go.aist.rtm.RTC.util.LongHolder |
float | jp.go.aist.rtm.RTC.util.FloatHolder |
double | jp.go.aist.rtm.RTC.util.DoubleHolder |
byte | jp.go.aist.rtm.RTC.util.ByteHolder |
String | jp.go.aist.rtm.RTC.util.StringHolder |
As well OpenRTM-aist for C++, users can create any holder for configuration data which corresponds with any type they define, in OpenRTM-aist Java.
To implement a holder for configuration data, implement stringFrom method of jp.go.aist.rtm.RTC.util.ValueHolder and declare the holder implements Serializable interface in its implements clause.
"stringFrom" method of jp.go.aist.rtm.RTC.util.ValueHolder is a method to convert a string passed by its argument to its targeted data type.
Please refer to VectorHolder class in "ConfigSample" sample, about holders for configuration data.
Table 3-4 shows the relationship between CORBA IDL data types and Java language data types.
CORBA IDL | Java language |
short | short |
long | int |
float | float |
double | double |
long long | long |
long double | double |
char | char |
wchar | char |
octet | byte |
unsigned short | short |
unsigned long | int |
unsigned long long | long |
boolean | boolean |
string | String |
wstring | String |
any | org.omg.CORBA.Any |
void | void |
> eclipse ?data /home/devel/OpenRTM/workspace
OpenRTM-aist Java was developed using the following libraries. We would like to extend out thanks to anyone who was involved in the designing and developing of these projects.
Apache Commons CLI 1.1
This product includes software developed by The Apache Software Foundation (http://www.apache.org/ ).