Skip to main content

robo-ws-bridge

A Python library implementing the Foxglove WebSocket protocol for streaming robotics data.

Installation

uv add robo-ws-bridge

Features

  • WebSocketBridgeServer: Async server for publishing robotics data over WebSocket
  • WebSocketBridgeClient: Async client for subscribing to data streams
  • Native channel streaming, time synchronization, playback control, subscriptions, and status messages
  • Extensible handlers for parameters, services, client publishing, connection graphs, and assets

Usage

Server Example

import asyncio
from robo_ws_bridge.server import Channel
from robo_ws_bridge import WebSocketBridgeServer

async def main():
    server = WebSocketBridgeServer(host="0.0.0.0", port=8765, name="my-server")

    # Define and advertise a channel
    channel = Channel(
        id=1,
        topic="/sensor/data",
        encoding="json",
        schema_name="SensorData",
        schema='{"type": "object"}',
    )

    await server.start()
    await server.advertise_channel(channel)

    # Publish messages
    while True:
        data = b'{"temperature": 22.5}'
        await server.publish_message(channel.id, data)
        await asyncio.sleep(0.1)

asyncio.run(main())

Playback control

Playback control uses our native async server implementation; it does not depend on the Foxglove SDK. Supplying the recording time range advertises the playbackControl capability; the server accepts the foxglove.sdk.v1 subprotocol by default.

from robo_ws_bridge import (
    PlaybackCommand,
    PlaybackControlRequest,
    PlaybackState,
    PlaybackStatus,
    WebSocketBridgeServer,
)

server = WebSocketBridgeServer(playback_time_range=(start_time_ns, end_time_ns))

async def control(request: PlaybackControlRequest) -> PlaybackState:
    if request.seek_time is not None:
        await recording.seek(request.seek_time)
    await recording.set_speed(request.playback_speed)
    if request.playback_command is PlaybackCommand.PLAY:
        await recording.play()
    else:
        await recording.pause()
    return PlaybackState(
        status=PlaybackStatus.PLAYING if recording.is_playing else PlaybackStatus.PAUSED,
        current_time=recording.current_time,
        playback_speed=recording.speed,
        did_seek=request.seek_time is not None,
    )

server.on_playback_control(control)

Each server endpoint has a unique session ID so reconnecting Foxglove clients discard stale visualization state. Rotate it explicitly when switching runs:

await server.clear_session()

Status IDs provide the same small lifecycle for the Problems panel:

from robo_ws_bridge import StatusLevel

await server.send_status(StatusLevel.ERROR, "Playback failed", status_id="playback")
await server.remove_status(["playback"])

Client Example

import asyncio
from robo_ws_bridge import WebSocketBridgeClient

async def main():
    client = WebSocketBridgeClient("ws://localhost:8765")

    async def handle_message(channel, timestamp, data):
        print(f"{channel['topic']}: {data}")

    async def handle_advertise(channel):
        await client.subscribe(channel["topic"])

    client.on_message(handle_message)
    client.on_advertised_channel(handle_advertise)

    await client.connect()

    # Keep running until interrupted
    try:
        while True:
            await asyncio.sleep(1)
    finally:
        await client.disconnect()

asyncio.run(main())

Protocol Reference

See the Foxglove WebSocket Protocol for protocol details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robo_ws_bridge-0.10.0.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robo_ws_bridge-0.10.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file robo_ws_bridge-0.10.0.tar.gz.

File metadata

  • Download URL: robo_ws_bridge-0.10.0.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for robo_ws_bridge-0.10.0.tar.gz
Algorithm Hash digest
SHA256 43aa78e11db99bc235e219c9ae2ac4df9c3026ec4b0d066228b5367ef73dc190
MD5 d4b0ace2a68d57fc5a26f5ed26f54949
BLAKE2b-256 0a8dd7d0a4871037f4899f57ef64dabba12148ec17d87e0747bb66824d11ea71

See more details on using hashes here.

File details

Details for the file robo_ws_bridge-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: robo_ws_bridge-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for robo_ws_bridge-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cce9fb6e70b8deeb89b5ccd53c764a8544973d07610ee139c73d587896fdafb8
MD5 d9e9eb2995acb9b54e26f0d5600731e2
BLAKE2b-256 182b2982a06268c3a962148609804032857a603e1441382f533163b4ecab0221

See more details on using hashes here.

Release history Release notifications | RSS feed

0.11.0

2 files

This release

0.10.0 This release

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page