Fast DDS(以前のバージョンではFast RTPS)はeProsima社が開発しているOMG DDS 2.0、RTPS 2.2仕様の通信ミドルウェアです。
以下ではOpenRTM-aistのFast RTPSプラグインのインストール手順、使用方法を説明します。
※ROS2通信機能がインストール済みの場合、Fast DDS通信機能も利用可能になっているため以下の手順は不要です。
C++版のみの対応です。
以下のサイトからインストーラーをダウンロードしてインストールしてください。
CMake実行時にFASTRTPS_ENABLEのオプションをONにします。
cmake -DORB_ROOT=C:/workspace/omniORB-4.2.3-win64-vc16 -G "Visual Studio 16 2019" -DFASTRTPS_ENABLE=ON ..
その他の手順は通常と同じです。
適当な場所にインストールしてください。
インストールするディレクトリはCMAKE_INSTALL_PREFIXのオプションで設定します。
cmake .. -DCMAKE_INSTALL_PREFIX=C:/workspace/OpenRTM-aist/build/install cmake --build . --config Release --target install
{インストールしたパス}\2.0.0\Components\C++\Examples\vc16のサンプルコンポーネントを実行します。
以下の内容のrtc.confを作成してください。
manager.modules.load_path: {インストールしたパス}\\2.0.0\\ext\\transport manager.modules.preload: FastRTPSTransport.dll manager.components.preconnect: ConsoleOut0.in?interface_type=fast-rtps, ConsoleIn0.out?interface_type=fast-rtps manager.components.preactivation: ConsoleOut0, ConsoleIn0
まずFastRTPSTransport.dllのロードが必要になります。 この設定はmanager.modules.preloadのオプションで設定できます。
次にコネクタ生成時にインターフェース型をfast-rtpsに設定する必要があります。 コネクタの生成はmanager.components.preconnectオプションにより設定します。 この例ではConsoleOut0コンポーネントのinのポート、ConsoleIn0コンポーネントのoutのポートにそれぞれコネクタを生成しています。
ConsoleInComp.exe、ConsoleOutComp.exeを実行すると通信ができるようになります。
asio、TinyXML-2をインストールします。
sudo apt install libasio-dev libtinyxml2-dev
Fast-CDRをビルド、インストールします。
export $OPENRTM_INSTALL_DIR=~/fastdds_install export FASTCDR_VERSION=1.0.23 wget https://github.com/eProsima/Fast-CDR/archive/refs/tags/v${FASTCDR_VERSION}.tar.gz tar xf v${FASTCDR_VERSION}.tar.gz cd Fast-CDR-${FASTCDR_VERSION}/ mkdir build cd build/ cmake .. -DCMAKE_INSTALL_PREFIX=${OPENRTM_INSTALL_DIR} cmake --build . --config Release -- -j$(nproc) cmake --build . --config Release --target install
foonathan/memoryをビルド、インストールします。
export FOONATHAN_MEMORY_VERSION=1.2.1 wget https://github.com/eProsima/foonathan_memory_vendor/archive/refs/tags/v${FOONATHAN_MEMORY_VERSION}.tar.gz tar xf v${FOONATHAN_MEMORY_VERSION}.tar.gz cd foonathan_memory_vendor-${FOONATHAN_MEMORY_VERSION}/ mkdir build cd build cmake .. -DCMAKE_INSTALL_PREFIX=${OPENRTM_INSTALL_DIR} cmake --build . --config Release -- -j$(nproc) cmake --build . --config Release --target install
Fast DDSのビルドにはCMake 3.11以上のバージョンが必要です。 Ubuntu 18.04環境ではaptでインストールされるCMakeのバージョンが3.10のため、新しいバージョンのCMakeをダウンロードしてPATHを設定してください。
wget https://github.com/Kitware/CMake/releases/download/v3.22.3/cmake-3.22.3-linux-x86_64.tar.gz tar xf cmake-3.22.3-linux-x86_64.tar.gz export PATH=~/cmake-3.22.3-linux-x86_64/bin:$PATH
以下のコマンドでFast DDSをビルド、インストールしてください。
export FASTDDS_VERSION=2.5.1 wget https://github.com/eProsima/Fast-DDS/archive/refs/tags/v${FASTDDS_VERSION}.tar.gz tar xf v${FASTDDS_VERSION}.tar.gz cd Fast-DDS-${FASTDDS_VERSION}/ mkdir build cd build cmake .. -Dfastcdr_DIR=${OPENRTM_INSTALL_DIR}/lib/cmake -Dfoonathan_memory_DIR=${OPENRTM_INSTALL_DIR}/lib/foonathan_memory -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${OPENRTM_INSTALL_DIR} cmake --build . --config Release -- -j$(nproc) cmake --build . --config Release --target install
CMake実行時にFASTRTPS_ENABLEのオプションをONにします。
cmake .. -DFASTRTPS_ENABLE=ON -Dfastrtps_DIR=${OPENRTM_INSTALL_DIR}/share/fastrtps/cmake
その他の手順は通常と同じです。
適当な場所にインストールしてください。
インストールするディレクトリはCMAKE_INSTALL_PREFIXのオプションで設定します。
cmake .. -DCMAKE_INSTALL_PREFIX=${OPENRTM_INSTALL_DIR} cmake --build . --config Release --target install
{インストールしたパス}/share/openrtm-2.0/components/c++/examplesのサンプルコンポーネントを実行します。
以下の内容のrtc.confを作成してください。
manager.modules.load_path: {インストールしたパス}/lib/openrtm-2.0/transport manager.modules.preload: FastRTPSTransport.so manager.components.preconnect: ConsoleOut0.in?interface_type=fast-rtps, ConsoleIn0.out?interface_type=fast-rtps manager.components.preactivation: ConsoleOut0, ConsoleIn0
まずFastRTPSTransport.soのロードが必要になります。 この設定はmanager.modules.preloadのオプションで設定できます。
次にコネクタ生成時にインターフェース型をfast-rtpsに設定する必要があります。 コネクタの生成はmanager.components.preconnectオプションにより設定します。 この例ではConsoleOut0コンポーネントのinのポート、ConsoleIn0コンポーネントのoutのポートにそれぞれコネクタを生成しています。
ConsoleInComp、ConsoleOutCompを実行すると通信ができるようになります。
rtc.confでOpenRTM-aistのマネージャ起動時に以下のオプションを設定可能です。 ※開発中のOpenRTM-aistでは使用可能ですが、リリースしたバージョンでは未実装の場合があります。
オプション名 | 設定例 | 内容 |
fast-rtps.xmlprofile.filename | C:/openrtminstall/2.0.0/ext/transport/FastRTPsQoSExample.xml | Fast DDSの設定ファイルを指定する。 |
fast-rtps.participant.name | participant_openrtm | ロードするDomainParticipantのプロファイル名 |
fast-rtps.domain.id | 0 | ドメインのID |
fast-rtps.dds.sec.auth.plugin | builtin.PKI-DH | 認証プラグインの名前 |
fast-rtps.dds.sec.auth.*** | 認証プラグインの設定 | |
fast-rtps.dds.sec.access.plugin | builtin.Access-Permissions | アクセス制御プラグインの名前 |
fast-rtps.dds.sec.access.*** | アクセス制御プラグインの設定 | |
fast-rtps.dds.sec.crypto.plugin | builtin.AES-GCM-GMAC | 暗号化プラグインの名前 |
fast-rtps.dds.sec.crypto.*** | 暗号化プラグインの設定 | |
fast-rtps.dds.sec.log.plugin | builtin.DDS_LogTopic | セキュリティロギングプラグインの名前 |
fast-rtps.dds.sec.log.*** | セキュリティロギングプラグインの設定 |
以下に設定例を記載します。
fast-rtps.xmlprofile.filename: ${OPENRTM_INSTALL_DIR}/transport/FastRTPsQoSExample.xml fast-rtps.participant.name: participant_openrtm
データポート接続時のコネクタプロファイルに設定できるオプションは以下の通りです。
オプション名 | デフォルト値 | オプション | 内容 |
fast-rtps.topic | chatter | DDSトピックの名前。ROS2シリアライザを使う場合は先頭にrt/を付けた名前に自動的に変更する。 | |
fast-rtps.subscriber.name | ロードするSubscriberのプロファイル名 | ||
fast-rtps.subscriber.qos.deadline.period.seconds | 2147483647 | 受信側の最小周期 | |
fast-rtps.subscriber.qos.deadline.period.nanosec | 4294967295 | ||
fast-rtps.subscriber.qos.destinationOrder | BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS | BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS, BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS | |
fast-rtps.subscriber.qos.disablePositiveACKs.enabled | NO | YES, NO | |
fast-rtps.subscriber.qos.disablePositiveACKs.duration.seconds | 2147483647 | ||
fast-rtps.subscriber.qos.disablePositiveACKs.duration.nanosec | 4294967295 | ||
fast-rtps.subscriber.qos.durability.kind | VOLATILE_DURABILITY_QOS | VOLATILE_DURABILITY_QOS, TRANSIENT_LOCAL_DURABILITY_QOS, TRANSIENT_DURABILITY_QOS, PERSISTENT_DURABILITY_QOS | 受信側の堅牢性(VOLATILE_DURABILITY_QOS:変わりやすい、TRANSIENT_LOCAL_DURABILITY_QOS:一時的なローカル設定) |
fast-rtps.subscriber.qos.durabilityService.history_depth | 1 | ||
fast-rtps.subscriber.qos.durabilityService.history_kind | KEEP_LAST_HISTORY_QOS | KEEP_LAST_HISTORY_QOS, KEEP_ALL_HISTORY_QOS | |
fast-rtps.subscriber.qos.durabilityService.max_instances | -1 | ||
fast-rtps.subscriber.qos.durabilityService.max_samples | -1 | ||
fast-rtps.subscriber.qos.durabilityService.max_samples_per_instance | -1 | ||
fast-rtps.subscriber.qos.durabilityService.service_cleanup_delay.seconds | 0 | ||
fast-rtps.subscriber.qos.durabilityService.service_cleanup_delay.nanosec | 0 | ||
fast-rtps.subscriber.qos.latencyBudget.duration.seconds | 0 | ||
fast-rtps.subscriber.qos.latencyBudget.duration.nanosec | 0 | ||
fast-rtps.subscriber.qos.lifespan.duration.seconds | 2147483647 | ||
fast-rtps.subscriber.qos.lifespan.duration.nanosec | 4294967295 | ||
fast-rtps.subscriber.qos.liveliness.announcement_period.seconds | 2147483647 | ||
fast-rtps.subscriber.qos.liveliness.announcement_period.nanosec | 4294967295 | ||
fast-rtps.subscriber.qos.liveliness.kind | AUTOMATIC_LIVELINESS_QOS | AUTOMATIC_LIVELINESS_QOS, MANUAL_BY_PARTICIPANT_LIVELINESS_QOS, MANUAL_BY_TOPIC_LIVELINESS_QOS | |
fast-rtps.subscriber.qos.liveliness.lease_duration.seconds | 2147483647 | 受信側のハートビートの周期 | |
fast-rtps.subscriber.qos.liveliness.lease_duration.nanosec | 4294967295 | ||
fast-rtps.subscriber.qos.ownership.kind | SHARED_OWNERSHIP_QOS | SHARED_OWNERSHIP_QOS, EXCLUSIVE_OWNERSHIP_QOS | |
fast-rtps.subscriber.qos.presentation.access_scope | INSTANCE_PRESENTATION_QOS | INSTANCE_PRESENTATION_QOS, TOPIC_PRESENTATION_QOS, GROUP_PRESENTATION_QOS | |
fast-rtps.subscriber.qos.presentation.coherent_access | NO | YES, NO | |
fast-rtps.subscriber.qos.presentation.ordered_access | NO | YES, NO | |
fast-rtps.subscriber.qos.reliability.kind | BEST_EFFORT_RELIABILITY_QOS | BEST_EFFORT_RELIABILITY_QOS, RELIABLE_RELIABILITY_QOS | 受信側の信頼性(RELIABLE_RELIABILITY_QOS:高信頼、BEST_EFFORT_RELIABILITY_QOS:最高速度) |
fast-rtps.subscriber.qos.reliability.max_blocking_time.seconds | 0 | ||
fast-rtps.subscriber.qos.reliability.max_blocking_time.nanosec | 100000000 | ||
fast-rtps.subscriber.qos.timeBasedFilter.minimum_separation.seconds | 0 | ||
fast-rtps.subscriber.qos.timeBasedFilter.minimum_separation.nanosec | 0 | ||
fast-rtps.subscriber.qos.type_consistency.force_type_validation | NO | YES, NO | |
fast-rtps.subscriber.qos.type_consistency.ignore_member_names | NO | YES, NO | |
fast-rtps.subscriber.qos.type_consistency.ignore_sequence_bounds | YES | YES, NO | |
fast-rtps.subscriber.qos.type_consistency.ignore_string_bounds | YES | YES, NO | |
fast-rtps.subscriber.qos.type_consistency.kind | ALLOW_TYPE_COERCION | DISALLOW_TYPE_COERCION, ALLOW_TYPE_COERCION | |
fast-rtps.subscriber.qos.type_consistency.prevent_type_widening | NO | YES, NO | |
fast-rtps.subscriber.history_memory_policy | PREALLOCATED_WITH_REALLOC_MEMORY_MODE | PREALLOCATED_MEMORY_MODE, PREALLOCATED_WITH_REALLOC_MEMORY_MODE, DYNAMIC_RESERVE_MEMORY_MODE, DYNAMIC_REUSABLE_MEMORY_MODE | |
fast-rtps.subscriber.topic.historyQos.depth | 1 | ||
fast-rtps.subscriber.topic.historyQos.kind | KEEP_LAST_HISTORY_QOS | KEEP_LAST_HISTORY_QOS, KEEP_ALL_HISTORY_QOS | |
fast-rtps.subscriber.times.heartbeatResponseDelay.seconds | 0 | ||
fast-rtps.subscriber.times.heartbeatResponseDelay.nanosec | 5000000 | ||
fast-rtps.subscriber.times.initialAcknackDelay.seconds | 0 | ||
fast-rtps.subscriber.times.initialAcknackDelay.nanosec | 70000000 | ||
fast-rtps.publisher.name | ロードするPublisherのプロファイル名 | ||
fast-rtps.publisher.qos.deadline.period.seconds | 2147483647 | 送信側の最小周期 | |
fast-rtps.publisher.qos.deadline.period.nanosec | 4294967295 | ||
fast-rtps.publisher.qos.destinationOrder | BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS | BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS, BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS | |
fast-rtps.publisher.qos.disablePositiveACKs.enabled | NO | YES, NO | |
fast-rtps.publisher.qos.disablePositiveACKs.duration.seconds | 2147483647 | ||
fast-rtps.publisher.qos.disablePositiveACKs.duration.nanosec | 4294967295 | ||
fast-rtps.publisher.qos.durability.kind | VOLATILE_DURABILITY_QOS | VOLATILE_DURABILITY_QOS, TRANSIENT_LOCAL_DURABILITY_QOS, TRANSIENT_DURABILITY_QOS, PERSISTENT_DURABILITY_QOS | 送信側の堅牢性(VOLATILE_DURABILITY_QOS:変わりやすい、TRANSIENT_LOCAL_DURABILITY_QOS:一時的なローカル設定) |
fast-rtps.publisher.qos.durabilityService.history_depth | 1 | ||
fast-rtps.publisher.qos.durabilityService.history_kind | KEEP_LAST_HISTORY_QOS | KEEP_LAST_HISTORY_QOS, KEEP_ALL_HISTORY_QOS | |
fast-rtps.publisher.qos.durabilityService.max_instances | -1 | ||
fast-rtps.publisher.qos.durabilityService.max_samples | -1 | ||
fast-rtps.publisher.qos.durabilityService.max_samples_per_instance | -1 | ||
fast-rtps.publisher.qos.durabilityService.service_cleanup_delay.seconds | 0 | ||
fast-rtps.publisher.qos.durabilityService.service_cleanup_delay.nanosec | 0 | ||
fast-rtps.publisher.qos.latencyBudget.duration.seconds | 0 | ||
fast-rtps.publisher.qos.latencyBudget.duration.nanosec | 0 | ||
fast-rtps.publisher.qos.lifespan.duration.seconds | 2147483647 | 送信側の未送信データの保持時間 | |
fast-rtps.publisher.qos.lifespan.duration.nanosec | 4294967295 | ||
fast-rtps.publisher.qos.liveliness.announcement_period.seconds | 2147483647 | ||
fast-rtps.publisher.qos.liveliness.announcement_period.nanosec | 4294967295 | ||
fast-rtps.publisher.qos.liveliness.kind | AUTOMATIC_LIVELINESS_QOS | AUTOMATIC_LIVELINESS_QOS, MANUAL_BY_PARTICIPANT_LIVELINESS_QOS, MANUAL_BY_TOPIC_LIVELINESS_QOS | |
fast-rtps.publisher.qos.liveliness.lease_duration.seconds | 2147483647 | 送信側のハートビートの周期 | |
fast-rtps.publisher.qos.liveliness.lease_duration.nanosec | 4294967295 | ||
fast-rtps.publisher.qos.ownership.kind | SHARED_OWNERSHIP_QOS | SHARED_OWNERSHIP_QOS, EXCLUSIVE_OWNERSHIP_QOS | |
fast-rtps.publisher.qos.presentation.access_scope | INSTANCE_PRESENTATION_QOS | INSTANCE_PRESENTATION_QOS, TOPIC_PRESENTATION_QOS, GROUP_PRESENTATION_QOS | |
fast-rtps.publisher.qos.presentation.coherent_access | NO | YES, NO | |
fast-rtps.publisher.qos.presentation.ordered_access | NO | YES, NO | |
fast-rtps.publisher.qos.publishMode.kind | SYNCHRONOUS_PUBLISH_MODE | SYNCHRONOUS_PUBLISH_MODE, ASYNCHRONOUS_PUBLISH_MODE | |
fast-rtps.publisher.qos.reliability.kind | BEST_EFFORT_RELIABILITY_QOS | BEST_EFFORT_RELIABILITY_QOS, RELIABLE_RELIABILITY_QOS | 送信側の信頼性(RELIABLE_RELIABILITY_QOS:高信頼、BEST_EFFORT_RELIABILITY_QOS:最高速度、SYSTEM_DEFAULT) |
fast-rtps.publisher.qos.reliability.max_blocking_time.seconds | 0 | ||
fast-rtps.publisher.qos.reliability.max_blocking_time.nanosec | 100000000 | ||
fast-rtps.publisher.qos.timeBasedFilter.minimum_separation.seconds | 0 | ||
fast-rtps.publisher.qos.timeBasedFilter.minimum_separation.nanosec | 0 | ||
fast-rtps.publisher.qos.type_consistency.force_type_validation | NO | YES, NO | |
fast-rtps.publisher.qos.type_consistency.ignore_member_names | NO | YES, NO | |
fast-rtps.publisher.qos.type_consistency.ignore_sequence_bounds | YES | YES, NO | |
fast-rtps.publisher.qos.type_consistency.ignore_string_bounds | YES | YES, NO | |
fast-rtps.publisher.qos.type_consistency.kind | ALLOW_TYPE_COERCION | DISALLOW_TYPE_COERCION, ALLOW_TYPE_COERCION | |
fast-rtps.publisher.qos.type_consistency.prevent_type_widening | NO | YES, NO | |
fast-rtps.publisher.history_memory_policy | PREALLOCATED_WITH_REALLOC_MEMORY_MODE | PREALLOCATED_MEMORY_MODE, PREALLOCATED_WITH_REALLOC_MEMORY_MODE, DYNAMIC_RESERVE_MEMORY_MODE, DYNAMIC_REUSABLE_MEMORY_MODE | |
fast-rtps.publisher.topic.historyQos.depth | 1 | 送信側の保持するデータ数 | |
fast-rtps.publisher.topic.historyQos.kind | KEEP_LAST_HISTORY_QOS | KEEP_LAST_HISTORY_QOS, KEEP_ALL_HISTORY_QOS | 送信データの保持方法(KEEP_LAST_HISTORY_QOS:すべてのデータを保持、KEEP_LAST_HISTORY_QOS:depthで指定したデータ数だけ保持) |
fast-rtps.publisher.times.heartbeatPeriod.seconds | 3 | ||
fast-rtps.publisher.times.heartbeatPeriod.nanosec | 0 | ||
fast-rtps.publisher.times.initialHeartbeatDelay.seconds | 0 | ||
fast-rtps.publisher.times.initialHeartbeatDelay.nanosec | 12000000 | ||
fast-rtps.publisher.times.nackResponseDelay.seconds | 0 | ||
fast-rtps.publisher.times.nackResponseDelay.nanosec | 5000000 | ||
fast-rtps.publisher.times.nackSupressionDuration.seconds | 0 | ||
fast-rtps.publisher.times.nackSupressionDuration.nanosec | 0 |
以下に設定例を記載します。
manager.components.preconnect: ConsoleOut0.in?interface_type=fast-rtps&fast-rtps.subscriber.name=subscriber_openrtm
Fast DDSはDDS Security仕様のセキュア通信機能を提供しています。
OpenRTM-aistのFast DDSプラグインでセキュア通信機能を使用するためには起動時のオプションを設定する必要があります。 以下に設定例を記載します。
fast-rtps.dds.sec.auth.plugin: builtin.PKI-DH fast-rtps.dds.sec.auth.builtin.PKI-DH.identity_ca: file://C:/workspace/openrtm_test/build/install/2.0.0/ext//transport/mainexamplecacert.pem fast-rtps.dds.sec.auth.builtin.PKI-DH.identity_certificate: file://C:/workspace/openrtm_test/build/install/2.0.0/ext//transport/appexamplecert.pem fast-rtps.dds.sec.auth.builtin.PKI-DH.private_key: file://C:/workspace/openrtm_test/build/install/2.0.0/ext//transport/appexamplekey.pem fast-rtps.dds.sec.crypto.plugin: builtin.AES-GCM-GMAC
Fast DDSのマニュアルの手順で秘密鍵、証明書を作成します。
以下で秘密鍵、自己署名証明書を作成するコマンドを掲載します。 maincaconf.cnfはFast DDSのマニュアルのものを使用します。 出力するファイル名を変更したい場合は適宜maincaconf.cnfの以下の項目を変更してください。
certificate = $dir/mainexamplecacert.pem private_key = $dir/mainexamplecakey.pem
また、req_distinguished_nameの項目は変更して、その内容に応じて変更したappconf.cnfを用意してください。
以下のコマンドを実行します。
type nul > index.txt openssl ecparam -name prime256v1 > ecdsaparam openssl req -nodes -x509 -days 3650 -newkey ec:ecdsaparam -keyout mainexamplecakey.pem -out mainexamplecacert.pem -config maincaconf.cnf openssl ecparam -name prime256v1 > ecdsaparam openssl req -nodes -new -newkey ec:ecdsaparam -config appconf.cnf -keyout appexamplekey.pem -out appexamplereq.pem openssl ca -batch -create_serial -config maincaconf.cnf -days 3650 -in appexamplereq.pem -out appexamplecert.pem
秘密鍵appexamplekey.pem、証明書mainexamplecacert.pem、appexamplecert.pemを使用します。