Skip to content

feat(go): implement Go bindings Phase 1 — pub/sub, codegen, examples#112

Open
YuanYuYuan wants to merge 27 commits intomainfrom
publish/go-phase-1
Open

feat(go): implement Go bindings Phase 1 — pub/sub, codegen, examples#112
YuanYuYuan wants to merge 27 commits intomainfrom
publish/go-phase-1

Conversation

@YuanYuYuan
Copy link
Collaborator

@YuanYuYuan YuanYuYuan commented Feb 26, 2026

Summary

Adds Go pub/sub bindings for ros-z (Phase 1): publisher, subscriber, typed helpers, QoS presets, graph introspection, CDR serialization, and a Go code generation tool for .msg types. No ROS 2 installation required for bundled message types. Quick start: https://zettascalelabs.github.io/ros-z/pr-preview/pr-112/chapters/go_quick_start.html

Key Changes

  • crates/ros-z/src/ffi/ — Rust CGO FFI layer (context, node, publisher, subscriber, serialize, QoS, graph) with cbindgen-generated header
  • crates/ros-z-go/rosz/ — Go rosz package: builder-pattern API for context, node, publisher, subscriber, typed subscriber, QoS, graph introspection, error types, channel-based handlers
  • crates/ros-z-go/testdata/ — CDR serialization tests (no FFI dependency)
  • crates/ros-z-codegen-go/ — Go tool that reads codegen JSON manifest and emits Go message structs with SerializeCDR/DeserializeCDR
  • crates/ros-z-codegen/export_json binary and JSON generator backend, consumed by ros-z-codegen-go
  • crates/ros-z-go/examples/ — talker (publisher), listener (subscriber), channel-based subscriber (subscriber_channel)
  • crates/ros-z-go/justfile — build, codegen, test, and demo targets; no ROS 2 needed for test-go
  • ci.ymlgo-tests job (ubuntu + macos, Go 1.23, no ROS 2)
  • book/ — Go Bindings and Go Quick Start chapters; service/action sections stubbed for v0.2

Acknowledment

This work is sponsored by

Dexory

@github-actions
Copy link

github-actions bot commented Feb 26, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://ZettaScaleLabs.github.io/ros-z/pr-preview/pr-112/

Built to branch gh-pages at 2026-03-05 08:03 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@YuanYuYuan YuanYuYuan changed the title feat(go): Go bindings Phase 1 — pub/sub, codegen, examples feat(go): implement Go bindings Phase 1 — pub/sub, codegen, examples Feb 26, 2026
@YuanYuYuan YuanYuYuan requested a review from JEnoch February 26, 2026 18:00
select {} // block forever
}
```

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing instruction to create hello_sub/go.mod

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added — hello_sub/go.mod block now appears immediately after the subscriber code.


```bash
# Publisher + subscriber in parallel (Ctrl+C to stop)
just -f crates/ros-z-go/justfile demo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing instruction to start the router. If not started, the subscriber receives nothing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — the Run section now starts with Terminal 1 for the router before launching subscriber and publisher.

```

You should see the subscriber printing messages published by the publisher.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add instructions to test against the ROS 2 demo_nodes_cpp. E.g.:

  • on ROS 2 host run ros2 run rmw_zenoh_cpp rmw_zenohd and ros2 run demo_nodes_cpp talker
  • on ros-z-go host, run cargo run --example zenoh_router -- -e tcp/<ROS2_HOST_IP>:7447 and cd hello_sub && CGO_LDFLAGS="-L/path/to/ros-z/target/release" go run main.go

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a dedicated ROS 2 Interoperability chapter covering Rust, Python, and Go against demo_nodes_cpp. It's linked from the Go Quick Start "What's next" section. The chapter focuses on the single-host scenario where one Zenoh router (any flavour — rmw_zenohd, zenohd, Docker, etc.) connects all participants.

@YuanYuYuan YuanYuYuan force-pushed the publish/go-phase-1 branch 2 times, most recently from 7b4f329 to eb77480 Compare March 3, 2026 17:33
@YuanYuYuan YuanYuYuan force-pushed the publish/go-phase-1 branch from eb77480 to 5da6872 Compare March 5, 2026 07:50
@YuanYuYuan
Copy link
Collaborator Author

The port collision issue will be covered in #121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants