Skip to content

Meet riders from other apps on a shared velodrome (OpenBikeNet) #69

Open

Description

@RalfLeonFasler

Prerequisite: #68 (laps on loop routes, closes #67). This builds on it, so I would start once #68 is merged.

Goal

Let VeloPopuli riders meet riders of other indoor cycling apps. OpenBikeNet is an open protocol for this: apps report where their riders are on a shared route and see the other apps' riders. Each app keeps its own physics, and nothing else is shared. A public server already runs at wss://openbikenet.cloud/v0 (stats). Anyone can run their own (OpenBikeNet/server), which fits the README's self-hosted servers goal.

I maintain OpenBikeNet and OpenRadlr, the first app that speaks it, so this would be the second app. I'd build it and keep the PR small.

What VeloPopuli already has

Piece Where Use
Remote riders in the engine RideEngine::set_remote / remove_remote (crates/core/src/ride.rs) OBN riders become remote rivals, like group-ride friends
A WebSocket link modelled per ride src-tauri/src/group.rs Template for the OBN link: connect, send position, reconnect
A status line on the ride screen group_status in session.rs "OpenBikeNet · 3 riders from other apps"
Laps on loop routes #67 / #68 OBN positions are on a loop with a lap count (spec 4.3)
Offline built-in route demo_route() in crates/core/src/gpx.rs Pattern for a built-in velodrome

Missing: a velodrome route, the OBN messages, the link, and settings.

Proposal (one PR, after #68)

Route. A built-in velodrome-250: flat, 250 m, closed, next to demo_route() and offline like it. The shared route file is routes/velodrome-250.json. It sits in the route list like the Demo Loop. Riders ride it with laps (#67).

Protocol (pure, in crates/core, unit-tested). Serde types for the v0 spec messages: hello, subscribe, join, update, leave and ping, and from the server welcome, snapshot, joined, updated, left, error and pong. Plus the rules other apps learned the hard way:

  • unknown server message types are ignored;
  • display names are cleaned before showing them;
  • a fatal error means back off;
  • the engine's distance is mapped to the route's [0, 250), and lap to laps finished.

Link (src-tauri, modelled on group.rs).

  • It connects, says hello as velopopuli, subscribes to velodrome-250 in the public room, and joins the rider.
  • It sends update at 1 Hz and leave when the ride ends.
  • It reconnects with backoff and pings after silence (spec 3.5).
  • Other apps' riders show as remote rivals, labelled with their app ("Anna · OpenRadlr").

Smooth riders. Remote riders only move when an update arrives, which looks jerky at 1 Hz. The engine would move them on at their last speed between updates, capped at 2 s. It's a small change to the core, with its own test, and it also smooths group-ride friends.

Settings.

  • An Other apps (OpenBikeNet) section with an on/off switch, off by default, preset to the public server, and a server address you can change.
  • A switch for sharing power and cadence, as the spec's privacy section asks (spec 10).
  • Only the display name you already set is sent.

Kept small for v1.

  • OBN is only on the velodrome.
  • On the velodrome, a ride uses OBN or a group-ride room, not both: Ride with friends is off there while OBN is on.
  • The existing relay and group rides are unchanged.

Open questions

  1. Off by default with the public server preset, or on by default? I'd keep it off: it sends your name and position to a server you didn't pick.
  2. Is a built-in velodrome OK in the route list, or would you rather it only appears when OBN is on? I lean towards always showing it, since it's a nice short loop on its own.

First version (acceptance)

  • velodrome-250 is built in, offline, closed, 250 m ± 0.5 m (core test)
  • OBN messages round-trip against the spec's examples, with the join-then-update order and name cleaning (core tests)
  • Remote riders move on between updates, capped at 2 s (core test)
  • VeloPopuli and OpenRadlr see each other's riders on the velodrome through a local reference server and through openbikenet.cloud; screenshots from both
  • Off by default; with it off, nothing connects
  • README, wiki ("Riding with other apps") and HANDOFF updated

The protocol is v0 and may still change. Route files never change once published (spec 4.2), so the velodrome is stable.

Sources

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions