Repository navigation
feat: add service bridge - #5
Merged
Merged
Conversation
Design for dynamic (YAML-configurable) service bridging by backporting GenericService/GenericClient from Rolling's rclcpp into domain_bridge, adapted for Humble's rclcpp API. Made-with: Cursor
Detailed step-by-step plan for implementing dynamic service bridging via GenericService/GenericClient backport from Rolling rclcpp. Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Also fix GenericService to initialize service_handle_ (required on Humble where ServiceBase does not allocate it), register GenericService/GenericClient with node callback groups so the executor can process them, and use rmw_qos_profile_services_default in service_bridge_impl.inc for Humble compatibility. Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
* fix(generic_client): hold pending_requests_ lock across rcl_send_request() The lock was taken after rcl_send_request() returned, so a response that arrived in between was dropped by handle_response() (the sequence number is not registered yet) and the returned future never became ready. rclcpp has always held the lock across the send: rclcpp::Client (since Foxy) and rclcpp::GenericClient (since its initial implementation in ros2/rclcpp#2358) both do. Match that ordering. This is not theoretical for the domain bridge: the client lives on the 'from' domain node and the service on the 'to' domain node, i.e. in different callback groups, so they run on different threads under a multi-threaded or callback-isolated executor. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(process_cmd_line_arguments): apply --from/--to to service bridges The domain id override loop only walked DomainBridgeConfig::topics, so `--from`/`--to` (and therefore the `from_domain`/`to_domain` arguments of domain_bridge.launch.xml) silently did not apply to service bridges. That left topics and services on different domains whenever the launch arguments and the YAML top-level values disagreed. Add a test covering both the default and the overridden case. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(domain_bridge): reject service bridge with equal from/to domain ids bridge_topic() already refuses to bridge when the two domain ids are equal, but the service path had no such check. get_node_for_domain() returns the same node for the same domain id, so with equal ids the GenericClient and the proxy GenericService end up on the same node under the same service name, and the client calls the proxy service itself instead of the real server. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(process_cmd_line_arguments): include parse_domain_bridge_yaml_config.hpp The header calls parse_domain_bridge_yaml_configs() but only included domain_bridge_config.hpp, so it only compiled when the translation unit happened to include parse_domain_bridge_yaml_config.hpp first, as src/domain_bridge.cpp does. The new test includes process_cmd_line_arguments.hpp on its own and exposed this. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * docs: correct the Jazzy notes on the backported generic classes The TODO comments claimed Jazzy needs the virtual method signatures adapted to const reference parameters. It does not: Jazzy's ServiceBase::handle_request() and ClientBase::handle_response() still take std::shared_ptr by value, exactly like Humble's. The const-reference signatures are Rolling-only. Verified by building this branch against Jazzy unchanged. Also note that Jazzy's rclcpp::GenericClient has no async_send_request() overload taking a response callback (ros2/rclcpp#2614 is Rolling only), so swapping it in is not a drop-in replacement for this bridge. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
domain_bridge側もYAML設定だけでサービスをブリッジできるようになっている。本PRはこのRolling版の仕組みをHumble向けにバックポートし、domain_bridgeにサービスブリッジ機能を丸ごと取り込むもの。domain_bridgeでは、サービスブリッジはbridge_service<ServiceT>(name, from, to)というコンパイル時にサービス型を要求するテンプレートAPIしか無く、トピックブリッジと違ってYAMLからは設定できなかった。GenericServiceが存在しない(GenericClientも存在しない)ため、RollingのrclcppからGenericService/GenericClientをdomain_bridgeパッケージ内に移植し、Humbleのrclcpp APIに合わせて調整することで、型情報をコンパイル時に持たずに動的にサービスをブリッジできるようにした。Changes
新規ファイル
include/domain_bridge/generic_service.hpp,src/domain_bridge/generic_service.cpp— RollingからバックポートしたGenericServiceinclude/domain_bridge/generic_client.hpp,src/domain_bridge/generic_client.cpp— RollingからバックポートしたGenericClientinclude/domain_bridge/service_typesupport_helpers.hpp,src/domain_bridge/service_typesupport_helpers.cpp— サービス型を実行時に動的ロードするためのtypesupportヘルパー変更ファイル
include/domain_bridge/domain_bridge.hpp/src/domain_bridge/domain_bridge.cpp— 文字列ベースのbridge_service(service, type, from_domain_id, to_domain_id, options)オーバーロードを追加し、GenericService/GenericClientを使ってコンパイル時型情報なしでサービスをブリッジできるようにしたsrc/domain_bridge/parse_domain_bridge_yaml_config.cpp— YAMLのservices:セクションをパースできるように拡張(トピックと同様、from_domain/to_domain/remapをサービス単位で上書き可能)include/domain_bridge/domain_bridge_config.hpp—ServiceBridge構造体を追加し、DomainBridgeConfigをサービス設定も保持できるように拡張CMakeLists.txt/package.xml— 追加したソースファイルのビルド設定と依存関係examples/example_bridge_config.yaml—services:セクションの設定例を追加テスト
test/domain_bridge/test_generic_service_bridge.cpp— GenericService/GenericClientによるend-to-endのサービスブリッジテストtest/domain_bridge/test_parse_domain_bridge_yaml_config.cpp/test/domain_bridge/config/services.yaml—services:セクションのYAMLパーステストドキュメント
docs/plans/2026-03-12-service-bridge-design.md,docs/plans/2026-03-12-service-bridge-implementation.md— 設計・実装計画(Rolling/Jazzy/Humbleの機能差分比較、検討した代替案などを含む)Example (YAML)