using ros communication features
#contents
C++ Version
Windows
Installing ROS
Follow the instructions on the following website to install Ros4Win onto a USB drive.
If rpt does not work correctly because the repository URL has changed, first modify the src\rpt\ros4win.py file if it has not already been updated.
#PKG_REPO_BASE="http://hara.jpn.com/cgi/" #Before modification
PKG_REPO_BASE="http://hara-jp.com/cgi/" #After modification
Install Ros4Win using the following commands.
git clone https://github.com/haraisao/rpt
cd rqt
python src\rpt\rpt.py update
python src\rpt\rpt.py install ros_base
python src\rpt\rpt.py install ros_setup
Building OpenRTM-aist
First, set the CMAKE_PREFIX_PATH and ROS_HOME_DRIVE environment variables with the following commands.
The following example assumes that the USB drive is mounted as drive D:. If your USB drive is assigned a different drive letter, replace D: with the appropriate drive letter.
set ROS_HOME_DRIVE=D:
set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%ROS_HOME_DRIVE%/opt/ros/melodic/share
Before proceeding with the remaining steps, configure the ROS environment with the following command.
D:\opt\ros\melodic\ros_setup.bat
Enable the ROS_ENABLE option when running CMake.
cmake -DORB_ROOT=C:/workspace/omniORB-4.2.3-win64-vc14 -DCORBA=omniORB -G "Visual Studio 16 2019" -A x64 -DROS_ENABLE=ON ..
The remaining steps are the same as the standard build procedure.
After building, install OpenRTM-aist.
cmake --build . --config Release --target install
Operation Check
Create the following rtc.conf.
manager.modules.load_path: C:\\workspace\\openrtm\\build_omni\\devel\\bin\\Release
manager.modules.preload: ROSTransport.dll
manager.components.preconnect: ConsoleOut0.in?interface_type=ros&marshaling_type=ros:std_msgs/Float32&ros.topic=chatter&ros.node.name=ConsoleOut0, ConsoleIn0.out?interface_type=ros&marshaling_type=ros:std_msgs/Float32&ros.topic=chatter&ros.node.name=ConsoleIn0
manager.components.preactivation: ConsoleOut0, ConsoleIn0
| : manager.modules.load_path | Specifies the location of the serializer module (ROSTransport.dll). |
| : manager.modules.preload | Specifies the serializer module used for ROS communication. On Windows, specify ROSTransport.dll. |
| : manager.components.preconnect | Configures connector creation. Set ros for interface_type, specify the corresponding serializer name for marshaling_type, and assign any desired topic name to ros.topic. |
The message types supported by the OpenRTM-aist serializer module (ROSTransport.dll) are listed below.
Start the RTCs to verify operation.
Launch Clink with the following command.
D:\opt\start_ros.bat
Perform the remaining steps from the Clink environment.
Run the following files. Place the modified rtc.conf in the same directory as the executable file corresponding to the Visual Studio version specified when OpenRTM-aist was installed (by default, under the VC14 directory in Examples).
${OpenRTM_INSTALL_DIR}\2.0\Components\C++\Examples\ConsoleInComp.exe
${OpenRTM_INSTALL_DIR}\2.0\Components\C++\Examples\ConsoleOutComp.exe
Ubuntu
Installing ROS
Install ROS using the following commands.
$ export ROS_DISTRO=melodic
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
$ sudo apt-get -y update
$ sudo apt-get -y install ros-${ROS_DISTRO}-ros-base
$ sudo rosdep init
$ rosdep update
Configure your shell for ROS as follows. This configures both future bash sessions and the currently running shell.
$ echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
Building OpenRTM-aist
Enable the ROS_ENABLE option when running CMake.
$ cmake -DCORBA=omniORB -DCMAKE_BUILD_TYPE=Release -DROS_ENABLE=ON ..
The remaining steps are the same as the standard build procedure.
After building, install OpenRTM-aist.
$ cmake --build . --target install
Operation Check
Create the following rtc.conf. Place this file in the current working directory from which the following RTC components will be started.
manager.modules.load_path: /usr/local/lib/openrtm-2.0/transport/
manager.modules.preload: ROSTransport.so
manager.components.preconnect: ConsoleOut0.in?interface_type=ros&marshaling_type=ros:std_msgs/Float32&ros.topic=chatter&ros.node.name=ConsoleOut0, ConsoleIn0.out?interface_type=ros&marshaling_type=ros:std_msgs/Float32&ros.topic=chatter&ros.node.name=ConsoleIn0
manager.components.preactivation: ConsoleOut0, ConsoleIn0
| : manager.modules.load_path | Specifies the location of the serializer module (ROSTransport.so). |
| : manager.modules.preload | Specifies the serializer module used for ROS communication. On Ubuntu, specify ROSTransport.so. |
| : manager.components.preconnect | Configures connector creation. Set ros for interface_type, specify the corresponding serializer name for marshaling_type, and assign any desired topic name to ros.topic. |
The message types supported by the OpenRTM-aist serializer module (ROSTransport.so) are listed below.
Start ConsoleInComp and ConsoleOutComp to verify operation.
Start each component from a separate terminal.
$ /usr/local/share/openrtm-2.0/components/c++/examples/ConsoleInComp
$ /usr/local/share/openrtm-2.0/components/c++/examples/ConsoleOutComp
Python Version
Windows
Installing ROS
Install ROS on a USB drive by following the instructions on the following page.
Installing OpenRTM-aist
Install OpenRTM-aist 1.2 or later using the installer.
Obtain the OpenRTM-aist Python source code.
Install the OpenRTM-aist Python version with the following commands.
python setup.py build
python setup.py install
Operation Check
Run start_ros.bat twice to open two command windows configured for the ROS environment.
D:\opt\start_ros.bat
In one of the windows, start roscore.
roscore
In the other window, add the directory where OpenRTM-aist is installed to PYTHONPATH.
set PYTHONPATH=%PYTHONPATH%;C:\Python37\Lib\site-packages;C:\Python37\Lib\site-packages\OpenRTM_aist;C:\Python37\Lib\site-packages\OpenRTM_aist\utils;C:\Python37\Lib\site-packages\OpenRTM_aist\RTM_IDL
Create the following rtc.conf. (Create rtc.conf in the directory from which the RTC executable is run. If you use the sample batch files, place it in the directory containing the executable started by the batch file.)
manager.modules.load_path: C:\\Python37\\Lib\\site-packages\\OpenRTM_aist\\ext\\transport\\ROSTransport
manager.modules.preload: ROSTransport.py
manager.components.preconnect: ConsoleOut0.in?interface_type=ros&marshaling_type=ros:std_msgs/Float32&ros.topic=chatter&ros.node.name=ConsoleOut0, ConsoleIn0.out?interface_type=ros&marshaling_type=ros:std_msgs/Float32&ros.topic=chatter&ros.node.name=ConsoleIn0
manager.components.preactivation: ConsoleOut0, ConsoleIn0
| : manager.modules.load_path | Specifies the location of the serializer module (ROSTransport.py). |
| : manager.modules.preload | Specifies the serializer module used for ROS communication. For Python, specify ROSTransport.py. |
| : manager.components.preconnect | Configures connector creation. Set ros for interface_type, specify the corresponding serializer name for marshaling_type, and assign any desired topic name to ros.topic. |
The message types supported by the OpenRTM-aist serializer module (ROSTransport.py) are listed below.
Start the RTCs using the above rtc.conf to verify operation.
Ubuntu
Installing ROS
Install ROS by following the same procedure as for the C++ version.
Installing OpenRTM-aist
Install the following packages.
$ sudo apt-get install python-omniorb-omg omniidl-python doxygen
Install the Python version of OpenRTM-aist with the following commands.
$ git clone https://github.com/OpenRTM/OpenRTM-aist-Python
$ cd OpenRTM-aist-Python
$ python setup.py build
$ sudo python setup.py install
Operation Check
Create the following rtc.conf. (Create rtc.conf in the current working directory from which the RTC is executed.)
manager.modules.load_path: /usr/local/lib/python2.7/dist-packages/OpenRTM_aist/ext/transport/ROSTransport/
manager.modules.preload: ROSTransport.py
manager.components.preconnect: ConsoleOut0.in?interface_type=ros&marshaling_type=ros:std_msgs/Float32&ros.topic=chatter&ros.node.name=ConsoleOut0, ConsoleIn0.out?interface_type=ros&marshaling_type=ros:std_msgs/Float32&ros.topic=chatter&ros.node.name=ConsoleIn0
manager.components.preactivation: ConsoleOut0, ConsoleIn0
| : manager.modules.load_path | Specifies the location of the serializer module (ROSTransport.py). |
| : manager.modules.preload | Specifies the serializer module used for ROS communication. For Python, specify ROSTransport.py. |
| : manager.components.preconnect | Configures connector creation. Set ros for interface_type, specify the corresponding serializer name for marshaling_type, and assign any desired topic name to ros.topic. |
The message types supported by the OpenRTM-aist serializer module (ROSTransport.py) are listed below.
Start the RTCs with the following commands to verify operation.
$ python /usr/local/share/openrtm-2.0/components/python/SimpleIO/ConsoleIn.py
$ python /usr/local/share/openrtm-2.0/components/python/SimpleIO/ConsoleOut.py
Connection Options
C++
The following options can be specified in the connector profile when connecting data ports.
| Option Name | Default Value | Available Values | Description |
|---|---|---|---|
| marshaling_type | Serializer type. Values such as ros:std_msgs/Float32 can be specified. | ||
| ros.topic | chatter | Topic name | |
| ros.roscore.host | localhost | Host name of the ROS Master | |
| ros.roscore.port | 11311 | Port number of the ROS Master | |
| ros.node.name | Name of the ROS node | ||
| ros.node.anonymous | NO | YES, NO | |
| ros.so_keepalive | YES | YES, NO | |
| ros.tcp_nodelay | YES | YES, NO | YES: Set the ROS node name to a UUID. NO: Set the ROS node name to rtcomp. |
| ros.tcp_keepcnt | 9 | ||
| ros.tcp_keepidle | 60 | ||
| ros.tcp_keepintvl | 10 |
Python
The following options can be specified in the connector profile when connecting data ports.
| Option Name | Default Value | Available Values | Description |
|---|---|---|---|
| marshaling_type | Serializer type. Values such as ros:std_msgs/Float32 can be specified. | ||
| ros.topic | chatter | Topic name | |
| ros.roscore.host | localhost | Host name of the ROS Master | |
| ros.roscore.port | 11311 | Port number of the ROS Master | |
| ros.node.name | Name of the ROS node | ||
| ros.node.anonymous | NO | YES,NO | |
| ros.so_reuseaddr | YES | YES,NO | |
| ros.so_keepalive | YES | YES,NO | |
| ros.tcp_nodelay | YES | YES,NO | YES: Set the ROS node name to a UUID. NO: Set the ROS node name to rtcomp. |
| ros.tcp_keepcnt | 9 | ||
| ros.tcp_keepidle | 60 | ||
| ros.tcp_keepintvl | 10 | ||
| ros.sock.timeout | 60 |
Simple Operation Check
When OpenRTM-aist is built and installed, a configuration file for a simple operation check of ROSTransport is also installed.
Start roscore with the following commands.
Windows
D:\opt\ros\melodic\ros_setup.bat
roscore
Start ConsoleOutComp using the following commands.
D:\opt\ros\melodic\ros_setup.bat
%RTM_ROOT%\ext\environment-setup.omniorb.vc16.bat
%RTM_ROOT%\Components\C++\Examples\vc16\ConsoleOutComp.exe -f %RTM_ROOT%\ext\transport\rtc.ros.conf
Ubuntu
Start roscore with the following commands.
source /opt/ros/melodic/setup.bash
roscore
Start ConsoleOutComp using the following commands.
source /opt/ros/melodic/setup.bash
source ${OPENRTM_INSTALL_DIR}/etc/environment-setup.sh
${OPENRTM_INSTALL_DIR}/share/openrtm-2.0/components/c++/examples/ConsoleOutComp -f ${OPENRTM_INSTALL_DIR}/etc/transport/rtc.ros.conf