Skip to content

Add ROS 2 talker/listener template in Swift#62

Open
Joannis wants to merge 5 commits into
mainfrom
feat/ros2-talker-listener-swift
Open

Add ROS 2 talker/listener template in Swift#62
Joannis wants to merge 5 commits into
mainfrom
feat/ros2-talker-listener-swift

Conversation

@Joannis

@Joannis Joannis commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

Adds swift/ros2-talker-listener — the canonical ROS 2 talker/listener demo in Swift, packaged as a two-service app group.

  • Built on swift-ros2, a pure-Swift ROS 2 client (no rclcpp, no C++ interop) that speaks the ROS 2 wire format directly over CycloneDDS.
  • talker: publishes std_msgs/String ("Hello World: N") on /chatter at 1 Hz. listener: subscribes and logs each message.
  • Uses the Humble wire format over CycloneDDS multicast, so the Swift nodes join the same ROS 2 graph as the repo's existing Humble-based Python templates (ros2 topic echo /chatter from a Humble node sees them).
  • Two host-networked services (talker, listener) in one wendy.json app group; payoff is wendy device logs.
  • Registered in meta.json (languages: ["swift"]) and documented in the root README.md.

Design + plan

  • docs/superpowers/specs/2026-07-01-ros2-talker-listener-swift-design.md
  • docs/superpowers/plans/2026-07-01-ros2-talker-listener-swift.md

Validation

Rendered the template from tracked files (tokens substituted), docker build both services clean, and ran the pair — the talker publishes and the listener receives every message over real CycloneDDS across two containers:

talker:   Publishing: 'Hello World: 1' …
listener: Listening on /chatter...
          I heard: 'Hello World: 2' …

Two build issues found and fixed during validation (see commits):

  • CycloneDDS 0.10.5 fails to configure on Debian bookworm's GNU make 4.3 (ddsperf type-gen) → build with -DBUILD_DDSPERF=OFF.
  • Swift print block-buffers on a pipe so wendy device logs stayed empty → log via unbuffered FileHandle.standardOutput (the Swift 6 stdout global is off-limits under strict concurrency).

Not yet run on a physical device; local flow was verified by running the listener in the talker's network namespace (deterministic loopback multicast).

🤖 Generated with Claude Code

https://claude.ai/code/session_01VQ3DosZiiBU97p3YN1HwxQ

Joannis and others added 5 commits July 1, 2026 15:02
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ3DosZiiBU97p3YN1HwxQ
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ3DosZiiBU97p3YN1HwxQ
Two-service app group (talker + listener) using swift-ros2 over CycloneDDS,
ROS 2 Humble wire format. Registered in meta.json and root README.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ3DosZiiBU97p3YN1HwxQ
…rror)

Keeping BUILD_IDLC on (ddsc needs it for builtin types) and disabling the
ddsperf tool fixes the "target pattern contains no '%'" configure failure on
Debian bookworm's GNU make 4.3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ3DosZiiBU97p3YN1HwxQ
Swift's `print` block-buffers when stdout is a pipe, so a long-running node
never flushed. Write each line straight to FileHandle.standardOutput instead
(the Swift 6 stdout global can't be used from strict-concurrency code).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ3DosZiiBU97p3YN1HwxQ
Copilot AI review requested due to automatic review settings July 1, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Swift template implementing the canonical ROS 2 Humble talker/listener demo using the pure-Swift swift-ros2 client over CycloneDDS, packaged as a two-service Wendy app group and wired into repo metadata/docs for discoverability.

Changes:

  • Introduces swift/ros2-talker-listener/ with talker and listener SwiftPM executables, each built into its own container image.
  • Adds Wendy template metadata (template.json) and app-group configuration (wendy.json) with host-network entitlements for DDS multicast discovery.
  • Registers and documents the new template in meta.json, the root README.md, and adds design/plan docs under docs/superpowers/.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
swift/ros2-talker-listener/wendy.json Defines a two-service app group (talker + listener) with host networking.
swift/ros2-talker-listener/template.json Declares template variables (APP_ID, ROS_DOMAIN_ID) and description.
swift/ros2-talker-listener/README.md Template-specific usage and interoperability notes.
swift/ros2-talker-listener/talker/Sources/talker/main.swift Swift ROS 2 publisher implementation (1 Hz chatter).
swift/ros2-talker-listener/talker/Package.swift SwiftPM manifest for the talker service.
swift/ros2-talker-listener/talker/Dockerfile Builds CycloneDDS from source and the talker binary in a multi-stage image.
swift/ros2-talker-listener/talker/.swift-version Pins Swift toolchain version for talker.
swift/ros2-talker-listener/listener/Sources/listener/main.swift Swift ROS 2 subscriber implementation (logs chatter).
swift/ros2-talker-listener/listener/Package.swift SwiftPM manifest for the listener service.
swift/ros2-talker-listener/listener/Dockerfile Builds CycloneDDS from source and the listener binary in a multi-stage image.
swift/ros2-talker-listener/listener/.swift-version Pins Swift toolchain version for listener.
README.md Adds a top-level section documenting the new Swift ROS 2 template.
meta.json Registers ros2-talker-listener as a Swift template in repo metadata.
docs/superpowers/specs/2026-07-01-ros2-talker-listener-swift-design.md Design doc for the template implementation.
docs/superpowers/plans/2026-07-01-ros2-talker-listener-swift.md Detailed implementation/validation plan for the template.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

let msg = StringMsg(data: "Hello World: \(count)")
try pub.publish(msg)
log("Publishing: '\(msg.data)'")
try await Task.sleep(nanoseconds: 1_000_000_000)
Comment on lines +7 to +9
RUN apt-get update && apt-get install -y --no-install-recommends \
cmake git build-essential \
&& rm -rf /var/lib/apt/lists/*
Comment on lines +7 to +9
RUN apt-get update && apt-get install -y --no-install-recommends \
cmake git build-essential \
&& rm -rf /var/lib/apt/lists/*
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