OpenRTM-aist comes with some sample components that are easy to use. (OpenCV is required for CameraViewer / OpenCVCamera components.) Also, the source code of the sample component is included, so please refer to it for development.
This chapter describes the samples provided with OpenRTM-aist. If you want to use the sample component, start the name service before starting the sample component. The following programs are provided for the name service.
To run the name server on Windows, locate the file in Explorer and double-click it. If you installed using the installer, you can also start the name service by selecting [Start Menu]> [OpenRTM-aist]> [Start Naming Service]. Note that this chapter assumes that RTSystemEditor is installed in your environment. For details on installing RTSystemEditor, see Installing OpenRTP.
This sample is included with C ++, Python and Java versions of OpenRTM-aist.
Sample of how to use InPort and OutPort. Start the ConsoleIn and ConsoleOut components. When the ports are connected, the numbers entered on the ConsoleIn side are displayed on the ConsoleOut side. Ports can be connected by executing rtshell commands in addition to using RTSystemEditor.
The sample of SimpleIO is a sample that sends the number input by ConsoleIn from the data port to ConsoleOut and displays the same number on ConsoleOut side. Enter a number from the ConsoleIn screen. Then the number entered in ConsoleOut will be output.
For Windows | For Linux | |||
ConsoleIn component | ConsoleOut component | ConsoleIn component | ConsoleOut component | |
C++ version | ConsoleIn.bat | ConsoleOut.bat | ConsoleInComp | ConsoleOutComp |
Python version | ConsoleIn.bat | ConsoleOut.bat | ConsoleIn.py | ConsoleOut.py |
Java version | ConsoleIn.bat | ConsoleOut.bat | ConsoleIn.sh | ConsoleOut.sh |
This sample is included with the C++, Python and the Java editions of OpenRTM-aist.
The SeqIO sample is a sample that sends numerical data continuously from the output of SeqOut. And the data is sent to the data port of SeqIn. Both output data and input data are displayed on each GUI / console screen. Connection of the corresponding ports of SeqOut and SeqIn are done on RTSystemEditor. When both components are activated, not only SeqOut but also the numerical value on the SeqIn GUI / console changes continuously, and you can observe the input and output of the data port.
Windows | Linux | |||
SeqIn component | SeqOut component | SeqIn component | SeqOut component | |
C++ | SeqIn.bat | SeqOut.bat | SeqInComp | SeqOutComp |
Python | SeqIn.bat | SeqOut.bat | SeqIn.py | SeqOut.py |
Java | SeqIn.bat | SeqOut.bat | SeqIn.sh | SeqOut.sh |
This sample comes only with the Python version.
It is a component that determines data received from InPort based on a certain standard and outputs it to OutPort in another form. It can be used with SeqIn and SeqOut.
When the ports are connected, the output value on the SeqOut side and the input value on the SeqIn side are displayed on their respective console screens. (Use RTSystemEditor for connection between ports.)
Autocontrol compares the fourth element of the data input from Sens port with the parameter "distance_to_env" that can be set in Configuration, and if it is less than or equal to the value, (turn_vel, -turn_vel) is output to vel port. If it is larger than it, (velocity, velocity ) is output to the port. Connect the corresponding ports of Autocntrol, SeqOut, and SeqIn on RTSystemEditor. When all the components are activated, the output value of SeqOut and the input value to SeqIn are displayed on each console screen.
This sample is included with C ++, Python and Java versions of OpenRTM-aist.
This is a sample that shows how to use the composite component. Before activating a composite component, you must connect the child components that make up the composite component.
Double-click PeriodicECShareComposite to display the inside of the composite component. It will show another editor view. Connect the components.
Here is an example of an operation when connecting with the ConsoleIn/ConsoleOut component.
If "111" is entered in ConsoleIn and "888" is displayed in ConsoleOut, the operation is correct. The child components that make up the composite component output twice the input value (the values displayed on the composite component screen).
In the sample of Composite, the value received from the input data port is doubled and output from output data port of each of the three child components, so the sample finally outputs the 8 times value from the output data port of Composite
Windows case | Linux case | |
C++ version | Composite.bat | Composite |
Python version | Composite.bat | Composite.py |
Java version | Composite.bat | Composite.sh |
This sample is included with the C++, Python and the Java editions of OpenRTM-aist.
This is a sample that shows how to use ServicePort. The service is defined using the IDL shown below.
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(); };
Start the MyServiceConsumer and MyServiceProvider components. Activate the Consumer component and a list of available commands will be displayed on the console. Try each command. (Use RTSystemEditor for connection between ports.)
SimpleService is a sample that sends a command from MyServiceConsumer and causes it to be processed by MyServiceProvider. Connect the corresponding ports of MyServiceConsumer and MyServiceProvider on RTSystemEditor. Activate both components (If the Consumer component is activated, it may activate the Provider too). A list of commands will be displayed at the Consumer prompt, so try to use the commands. The response of the Provider can be observed on the prompt.
The startup of the component differs depending on the OS and the language of OpenRTM-aist, so start regarding the table below.
Windows | Linux | |||
MyServiceConsumer component | MyServiceProvider component | MyServiceConsumer component | MyServiceProvider component | |
C++ | MyServiceConsumer.bat | MyServiceProvider.bat | MyServiceConsumerComp | MyServiceProviderComp |
Python | MyServiceConsumer.bat | MyServiceProvider.bat | MyServiceConsumer.py | MyServiceProvider.py |
Java | MyServiceConsumer.bat | MyServiceProvider.bat | MyServiceConsumer.sh | MyServiceProvider.sh |
If the connection between Ports is successful, a menu is displayed on the console that executed ExtConnector to select which component to be triggered. With this input value, each component executes its processing one cycle at a time.
This sample is included with the C++, Python and the Java editions of OpenRTM-aist.
This example shows how to use the configuration-set feature of the RT-Component. When you launch the ConfigSample component, its configuration sets are set up automatically. You can check and alter configuration parameters using RTSystemEditor.
Note: If an error "Specified path cannot be found" occurs, modify the value of "example.ConfigSample.config_file" in rtc.conf file under the RTMExamples\ConfigSample directory. Change it to:
.\\RTMExamples\\ConfigSample\\configsample.conf (Use '\\' instead of '\' for the separator between file name and directory names. )
or rewrite it to the full path of "configsample.conf". In this case, you need to specify '\\' as a directory separator, as well.
This sample keeps displaying the configuration set data of the component on the console screen. It updates the display when the configuration data is changed in RTSystemEditor.
Windows | Linux | |
C++ | ConfigSample.bat | ConfigSampleComp |
Python | ConfigSample.bat | ConfigSample.py |
Java | ConfigSample.bat | ConfigSample.sh |
This sample is included only with Java version of OpenRTM-aist. Please note that it is not included with C ++ version and Python version.
RT component sample with GUI screen. Execute the GUIIn.bat for Windows and GUIIn.sh for Linux to start the sample component.
Each port transmits input data by connecting the corresponding ports and turning on the check box next to the GUI element. (Use RTSystemEditor for connection between ports. Use other samples such as SeqIn to check output data.)
If you operate the checked controls (sliders, spinners) on the GUI screen of the GUIIn component, the values on the SeqIn console screen will change as the values change.
This sample comes only with the Python version.
tkLRFViewer is an example of an RTC that displays the output from a Laser Range Finder sensor. Connect and use the RTC that handles the input from the laser range finder. Enter the RTC to be connected according to the device to be connected. For example, see Hokuyo Electric Co., Ltd. URG series. The LRF sensor is a sensor that scans the space while rotating the Laser rangefinder and sends out the measured distance data sequentially. Data is output in the form of the initial value and end value of the rotation angle, the angle interval at which each distance data is measured, and a series of measured distance data. This component is to show the scanned data by using a graphic format.
When this component is started, the following GUI screen is displayed.
To use this RTC, as described above, read the sensor output from the externally connected Laser Range Finder sensor, convert it, and convert it to a RangeData type and also refer to the above link about the laser range finder sensor.
Name | function |
Scale Factor | When drawing, the distance is based on a space of 480m x 480m, and scale is used to scale the drawing by a scale value. For detecting a general range of about several m x several m, 0.01 It is better to set the value to |
Reset Scale button | Button to reset to Scale Factor 1.0 |
Axis checkbox | If this checkbox is checked, the X and Y axes will be displayed |
Grid checkbox | Tick marks are displayed when this checkbox is checked |
Line checkbox | Distance data is drawn as a line when this checkbox checked |
Fill checkbox | Distance data is drawn as a filled object when this checkbox checked |
Threshold checkbox and slider | If checked, the parameter is enabled and the lower limit (*) is processed. If the input distance is smaller than that value, it is considered invalid and the detection distance is assumed to be 1000m |
Fileter (Time) checkbox and slider | If checked, filters for time-domain changes is enabled and the degree of the effect is adjusted with the slider |
Fileter (Spacial) checkbox and slider | If checked, filters for changes in scan data in the rotation direction are enabled, and the degree of the effect is adjusted with the slider |
Note) The current display scale and the way Threshold works are not effective settings in the real world. It is recommended to rewrite and adjust the source code according to the user environment.
The GUI will output something like the following screen.
This sample comes with the Python version of OpenRTM-aist. Please note that it is not included in C ++ version and Java version.
RT component sample with GUI screen. The sample component is started by executing TkJoyStickComp.bat. The value (x, y) corresponding to the position where the joystick on the GUI is moved by dragging is output.
This sample comes with the Python version of OpenRTM-aist. Please note that it is not included in C ++ version and Java version.
RT component sample with GUI screen. The sample component starts by executing TkMobileRobotSimulator.bat.
For the system to recognize it as an RTC and make the RTC visible in the Name Service, press the [Create] button in the center-right of the GUI. A pentagonal object imitating an object that moves back and forth and left and right with a motor is displayed on the GUI. The pentagonal object on the screen moves according to the input value to InPort. The input to InPort is two value vector values and one is the rotation speed of the left wheel motor and the other is the rotation speed of the right wheel motor. The speed of both wheels must be the same to go straight apex.
Connect TkJoystick (input device) and TkMobileRobotSimulator, and simulate a robot that the joystick controls the moving speed on the GUI.
This sample comes with the Python version of OpenRTM-aist. Please note that it is not included in C ++ version and Java version.
RT component sample with GUI screen. The sample component is started by executing TkMotorComp.bat.
This sample comes with the Python version of OpenRTM-aist. Please note that it is not included in C ++ version and Java version.
RT component sample with GUI screen. Executing SliderComp.bat starts the sample component. (The following screen is for Windows.)
Simulate the environment of controlling the rotation of the motor with the slide knob on the GUI with SliderComp and TkMotorComp.
This sample comes with the Python version of OpenRTM-aist. Please note that it is not included in C ++ version and Java version.
RT component sample with GUI screen. The sample component is started by executing TkMotorComp.bat.
This sample comes with the Python version of OpenRTM-aist. Please note that it is not included in C ++ version and Java version.
RT component sample with GUI screen. Executing SliderComp.bat starts the sample component. (The following screen is for Windows.)
Simulate the environment of controlling the rotation of the motor with the slide knob on the GUI with SliderComp and TkMotorPosComp.
This sample is included with OpenRTM-aist C ++ Windows version. Note that OpenRTM-aist is not included in the C ++ version and you need to build and install them on Linux by using OpenCV Sample Code Build Procedure. It is not included in the Python version or the Java version.
By starting OpenCVCamera and CameraViewer, the image of the USB camera is displayed on the monitor. You can connect the OpenCV image processing sample RTC component and apply effects.
OpenCVCamera is a sample that acquires image data of a USB camera and displays it on a monitor with the CameraViewer component. You can also connect an Image processing OpenCV sample RT component between them to apply effects to image data.
Startup command | Function | Configuration parameter |
Affine.bat | Affine transforms the input image | Affine matrix |
BackgroundSubtractionSimple.bat | Outputs the change from the image when the key was input in the input image | Parameter indicating the method of detecting image change |
Binarization.bat | Converts an input image to a binary black and white image | Binarization threshold |
DialationErosion.bat | Perform dialing / erosion processing | Binarization threshold |
Edge.bat | Outputs the first-order derivative image in the X direction, the first-order derivative image in the Y direction, and the Laplacian image (second-order derivative image) | Aperture size |
Findcontour.bat | Extract the outline and display the outline in the image. | Threshold for binarization before processing, level of layering, size of outline at the display, outline approximation method |
Histgram.bat | Displays changes in histogram while changing brightness / contrast of black and white image | Brightness, contrast |
Hough.bat | Line extraction by Hough transform | Hough transform parameters and drawing parameters of detected straight lines |
Perspective.bat | Perspective conversion of image (Convert as viewed from below. | No item |
RockPaperScissors.bat | Judgment of Goocho kipper in image. | Janken judgment threshold for solidity and missing interpolation parameter by dilation / reduction processing |
Rotate.bat | Rotates and scales images | Counterclockwise rotation angle and reduction / enlargement ratio |
Scale.bat | Processes images for scaling | Scale in the X and Y directions |
Sepia.bat | Separates images | Sepia color satulation / hue |
Translate.bat | Performs two-dimensional translation of images | Moving direction |
$ sudo sh pkg_install_ubuntu.sh -l all --yes
$ sudo apt-get install git $ git clone https://github.com/OpenRTM/ImageProcessing.git $ cd ImageProcessing/opencv $ mkdir build $ cd build $ cmake .. $ make $ ./build_linux_package.sh $ sudo dpkg -i imageprocessing_1.2.1_amd64.deb
Please note that it is not included in Python and Java versions of OpenRTM-aist. On Linux, build and install it according to OpenCV Sample Code Build Procedure on Linux.
Chromakey RTC is an OpenCV component example that synthesizes two screens with chroma key. It is used with OpenCVCamera and CameraViewer component.
Chromakey is an RT component that realizes a technique called chroma key synthesis that makes an image taken with a specific color as the background (for example, green) and make it transparent then synthesize it with another screen. In this execution, it uses two OpenCVCamera components to capture two image data. The output uses CameraViewer component.
> cd "\ Program Files \ OpenRTM-aist \ 1.2.1 \ Components \ C++\vc14" > notepad rtc.conf
manager.components.naming_policy: ns_unique
Please note that it is not included in Python and Java versions of OpenRTM-aist. On Linux, build and install it according to OpenCV Sample Code Build Procedure.
ObjectTracking is a sample OpenCV component that tracks an object selected on the screen and show the position by a red oval. It is Used with OpenCVCamera and CameraViewer.
ObjectTracking is a component that tracks the object selected on the screen and indicates its position with a red oval. It is used here with the OpenCVCamera component to capture images from a USB Camera, the CameraViewer component used to display processed images and to select objects with the mouse.
Please note that it is not included in Python and Java versions of OpenRTM-aist. On Linux, build and install it according toOpenCV Sample Code Build Procedure
By starting ImageSubtraction component, the background image is extracted from the input image, the foreground image part is output as a mask image and the background image is output. Used with OpenCVCamera and CameraViewer component. (Note that this component currently does not work properly in a Windows environment, so please use it in Linux (Ubuntu 18.04) environment.)
ImageSubtraction is a component for extracting the background image from the input image. Here, it is used together with OpenCVCamera for capturing images from USB Camera and CameraViewer component for displaying processed images.
$ cd ImageProcessing/opencv/bin $ ./CameraViewerComp
$ cd ImageProcessing/opencv/bin $ ./OpenCVCameraComp
$ cd ImageProcessing/opencv/bin $ ./ImageSubtractionComp
Parameter name | meaning |
control_mode | b and m can be selected. In the case of b, the background image is captured according to the key event. In the case of m, the mode switches between DYNAMIC_MODE, which determines the threshold a pixel by a pixel, and CONSTANT_MODE, which uses one threshold for the entire screen. |
image_height | Specifies the number of pixels in the vertical direction, but does not work in this sample. |
image_width | Specifies the number of pixels in the horizontal direction, but does not work in this sample. |
threshold_coefficient | Coefficient used in DYNAMIC_MODE |
constant_threshold | Threshold used in CONSTANT_MODE |
Please note that it is not included in Python and Java versions of OpenRTM-aist. On Linux, build and install it according to OpenCV Sample Code Build Procedure on Linux.
SubtractCaptureImage is a component that outputs a mask image that extracts the foreground (moving object) from the input image by determining the unchanged part as the background, and is a sample component that updates the background in real-time using the dynamic background subtraction method. You can use it with OpenCVCamera and CameraViewer components.
SubtractCaptureImage considers the input image that does not move as the background and sets it as the background and if a newly added thing on the screen does not move and is kept for a while, it is also judged as a part of the background and incorporate it into the background image. The output includes an input image, a mask image of the foreground (indicating a moving object) a mask image indicating neither a moving object nor a background, a background image, and an image showing the background of a still object. To use this component, start multiple CameraViewers and view multiple output images at the same time, or look at each output image while changing the connection with CameraViewer. You may also want to use the OpenCVCamera component for the input image.
> cd "\Program Files\OpenRTM-aist\1.2.1\ Components\C++\OpenCV\vc14" > notepad rtc.conf
manager.components.naming_policy: ns_unique
Please note that it is not included in Python and Java versions of OpenRTM-aist. On Linux, build and install it according to OpenCV sample code for Linux.
RT component sample with GUI screen. The sample component starts by executing TkCalibGUI.bat. GUI for ImageCalibration component that performs camera calibration.
When this component is executed and a camera component is specified from the selectable list, it is automatically started together with ImageCalibrationComp, and the port connection between the components is also performed automatically. You can save camera images required for calibration and calculate camera parameters by operating the buttons on the GUI.
If installed using the OpenRTM-aist C ++ installer for Windows, it only needs to be executed by running TkCalibGUI.bat.
If you build from source, you need to arrange the execution conditions. This component checks the environment required for execution. If the conditions are not met, the following message dialog will be displayed. Follow the instructions to install.
Message contents | Correspondence processing |
OpenRTM-aist Python is not installed. | OpenRTM-aist Python version You can download it. Please match the OS version (32bit or 64bit) of the installer with the OpenRTM-aist C ++ version. |
Ttk is not installed. | Please install pyttk. It is included in python2.7, but needs to be installed separately in python2.6. |
PIL is not installed. | Please install PIL. |
NumPy is not installed. | Please install numpy. |
rtctree is not installed. | Requires rtctree-3.0.1 or higher The installer will be released soon, but until then, github page Click "Download Zip", download and extract the rtc-master.zip file, and execute setup.py to install. (> Python setup.py install) Add the path to site-packages\rtctree\rtmidl to the system environment variable PYTHONPATH. eg) C:\Python27\Lib\site-packages\rtctree\rtmidl |
Message contents | Required processing |
OpenRTM-aist Python is not installed. | Execute Bulk installation script with -l python option. |
Ttk is not installed. | $ Sudo apt-get install python-tk |
PIL is not installed. | $ Sudo apt-get install python-pil.imagetk |
NumPy is not installed. | $ Sudo apt-get install python-numpy |
rtctree is not installed. | Requires rtctree-3.0.1 or higher Download from github and run setup.py to install. Add PYTHONPATH to ~/.bashrc or other way. export PYTHONPATH = "/usr/local/lib/python2.7/dist-packages/rtctree/rtmidl" |
At first, select the camera component to use from the list. This list shows the camera component names that can be used in the current environment. The selection can be done by the input-box at the right top side of the dialog. OpenCVCameraComp and MFCameraComp can be selected in the environment of VC2019 of Windows 10. Both of them work in the same way, but OpenCVCameraCompp seems to be newer and less dependent on the environment. The ImageCalibration component is started by the execution file started by tkCalibGUI.bat. This component can be started alone by ImageCalibration.bat, but we did not provide stand-alone components to connect to the ImageCalibration component in the release. If you want to use the ImageCalibration component without using tkCalibGUI you may need to create the component which can be connected to ImageCalibration component by yourself.
Click the [All Activate] button to display the camera image. The connection status of all components at this time is as shown below. Components other than TkCalibGUI are started automatically, and components are also connected automatically.
Prepare a checker pattern (calibration pattern). For your reference, we use checkerboard.pdf here. The number of corners of the checker pattern must be specified in the ImageCalibration Configuration. The number of shared vertices of the vertical and horizontal white and black squares of the pattern (checker_h, checker_w) - this is the number of black and white squares-1, and the number of shots (image_num) can also be changed in Configuration.
To capture checker patterns, save (by click [保存] button) the specified number of patterns at various angles to cover the entire screen as much as possible. Click the [確認] button to check the saved image. Clicking the [取り消し] button deletes the image, so please save it again.
After saving the specified number of sheets, the [結果表示] button is enabled. Click this to display the camera parameter values.
The camera parameters are output to the same directory as the component executable file with the file name camera.yml.
%YAML:1.0 calibration_time: "Thu May 22 16:38:06 2014\n" image_width: 640 image_height: 480 board_width: 13 board_height: 9 cameraMatrix: !!opencv-matrix rows: 3 cols: 3 dt: d data: [ 5.8272934483011682e+002, 0., 3.3703801084645710e+002, 0., 5.8023846162074653e+002, 2.2824562602176763e+002, 0., 0., 1. ] distCoeffs: !!opencv-matrix rows: 1 cols: 5 dt: d data: [ -1.4659954975042236e-001, 5.7825601645508595e-001, -3.3745642103035984e-003, 1.2569676956708463e-003, -9.8011775330916773e-001 ]