feat(python): expand Python bindings with actions, SHM, graph, QoS, and generic bridge#110
Open
YuanYuYuan wants to merge 12 commits intomainfrom
Open
feat(python): expand Python bindings with actions, SHM, graph, QoS, and generic bridge#110YuanYuYuan wants to merge 12 commits intomainfrom
YuanYuYuan wants to merge 12 commits intomainfrom
Conversation
…nd generic bridge Closes the gap between the Python API and Rust API: - Generic message bridge (RawBytesMessage/RawBytesCdrSerdes): any registered message type works for pub/sub and services without per-type factory match statements - Action client/server (PyZActionClient, PyZActionServer): full Python↔Python action support via RawBytesAction/DynActionMessage; uses a global tokio runtime for async ops - Graph discovery: get_topic_names_and_types, get_node_names, get_service_names_and_types, count_publishers, count_subscribers - QoS class (PyQosProfile): type-safe Python QoS with presets and backward-compatible dict support - Context builder: full builder with mode, router, remap, enclave, SHM (with_shm_enabled, with_shm_pool_size, with_shm_threshold), and clean shutdown - Callback subscriptions: create_subscriber(callback=fn) pattern - Node properties: name, namespace, fully_qualified_name - Fix check-example-coverage.nu path after crates/ reorganization
Add with_goal_type_info / with_result_type_info / with_feedback_type_info to ZActionClientBuilder and ZActionServerBuilder so callers can supply type hashes determined at runtime (e.g. from Python message classes). Also relax extract_type_info_from_class to treat __hash__ as optional: inline msgspec structs without a RIHS01 hash now use zero TypeHash and work for Python-to-Python communication without raising an error.
- examples/action_demo.py: CountTo action demo with cancellation support - tests/test_action.py: 7 test cases covering creation, send/result, feedback, status, cancellation, rejection, abort, and timeout - book/src/chapters/python.md: Actions section with message types, server/client lifecycle, GoalStatus table, and interop note
…cle" This reverts commit a79043f.
…gram" This reverts commit 0e55a93.
|
…gs registry Inline msgspec types (like test action types) are not registered in the ros_z_msgs type registry, causing 'Unknown message type' errors in CI. Switch action goal/result/feedback serialization to msgspec.msgpack directly: store Python class objects in the action wrappers and use msgspec.msgpack.encode/decode for Python-to-Python actions, bypassing the CDR registry lookup entirely.
…ructs The server only needs goal_type (to decode incoming goal bytes). Result and feedback are only encoded server-side, not decoded, so no class reference is needed. Remove the dead fields to fix the CI -D warnings build error.
1. `is_cancel_requested` missing `#[getter]`: accessing it as a Python property returned the method object (always truthy), causing the server to cancel every goal after the first feedback. 2. `status_arc` initialized to Unknown: immediately after `send_goal` the status bridge task hadn't fired yet, so `handle.status` returned 0 (Unknown) instead of 1 (Accepted). Initialize to Accepted and read the current watch value on subscription. 3. Cancel requests not handled in polling mode: the server had a background result-request handler but no cancel-request handler. `client.cancel()` sent a cancel service request and waited forever for a reply. Add `handle_cancel_requests_legacy_inner` and spawn it alongside the result handler. 4. `send_goal` hangs when no server is present: the flume channel's persistent sender kept `rx.recv_async()` alive after the Zenoh query expired. Add an 11 s tokio timeout so callers get a clear RuntimeError instead.
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
Expands the
ros_z_pyPython bindings from a minimal 5-type stub to anear-complete API covering pub/sub, services, actions, graph discovery,
QoS, SHM, and context lifecycle.
Key Changes
Generic message bridge — replaced per-type factory match statements with
RawBytesMessage/RawBytesCdrSerdes(identity serializer). Any message typeregistered in
ros_z_msgs_pynow works with pub/sub and services withoutper-type Rust code.
Actions — full Python↔Python action client/server via
RawBytesAction(
DynActionMessagefor Goal/Result/Feedback).ZActionClientandZActionServerare driven from a global tokio runtime; feedback is bridgedfrom tokio
mpsctoflumefor blocking-friendly Python access.Graph discovery —
get_topic_names_and_types,get_node_names,get_service_names_and_types,count_publishers,count_subscribersonZNode.QoS class —
PyQosProfilewith named constructor, static presets(
default,sensor_data,parameters,services), and backward-compatibledict support.
Context builder — added
with_mode,with_router_endpoint,with_remap_rule(s),with_enclave,with_shm_enabled,with_shm_pool_size,with_shm_threshold,and
shutdown()/ context-manager protocol.Callback subscriptions —
create_subscriber(callback=fn)usesbuild_with_callback; queue-based subscriptions unchanged.Node properties —
name,namespace,fully_qualified_name.Fix —
check-example-coverage.nupath corrected after thecrates/reorganisation in #92.