Skip to content

Laps on loop routes - #68

Merged
pepperstm merged 7 commits into
pepperstm:mainfrom
RalfLeonFasler:feature/loop-laps
Nov 12, 2026
Merged

pepperstm merged 7 commits into
pepperstm:mainfrom
RalfLeonFasler:feature/loop-laps

Conversation

@RalfLeonFasler

@RalfLeonFasler RalfLeonFasler commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Laps on loop routes, as agreed in #67. On a closed route, ride setup offers Laps: Once round (the default, unchanged), 2, 3, 5, 10 or 20 laps, or Until I stop. It isn't offered on open routes.

  • Engine (crates/core/src/ride.rs): distance is still the position on the route, in [0, total]. New fields are lap (from 1) and ridden (total metres). On a ride without laps, ridden == distance at all times, so existing behaviour can't change.
  • At the line: a climb or segment ending at the line is timed on the crossing tick. Then the position wraps and the lap goes up.
  • Climbs and segments are timed again on every lap and keep the fastest. A slower later lap never replaces a faster earlier one from the same ride.
  • Ghosts are off on lap rides, as you suggested. A lap ride never sets the route's best time (counts_for_route_best()).
  • Distance figures: the FIT distance, ride summary, average speed, season goal and badges all count ridden.
  • Bots go round the loop.
  • Group rides: no wire change. GroupLink::send already sends the position on the route, so riders with different lap choices still see each other in the right place.
  • Old library entries: a new route_is_loop command builds the route rather than reading the stored list. Loops imported before this change still get the Laps choice.
  • Ride screen: the HUD shows "Lap 3 of 10 · 24.10 km". Standings gaps are measured round the loop. The "next" profile, the profile markers and the coming-up landmarks carry on across the line.
  • Renderers, both three.js and native:
    • Riders near the line are shown.
    • The tunnel camera, barriers and the glide work across the line.
    • The last lap still ends on the line rather than snapping back to the start.
    • There's no FINISH arch on lap rides.
    • The road mesh now joins up at the line on closed routes (World::road() adds one closing section). Before this, the ground showed through a strip across the road there, which a lap ride crosses every lap.

Closes #67

How it was tested

  • 8 new core tests:
    • wrapping and lap count
    • finishing after N laps
    • a loop without laps finishing exactly as before
    • laps ignored on open routes
    • bots lapping
    • no ghosts on lap rides
    • a segment ending at the line, timed every lap, keeping the fastest
    • a mid-loop climb timed again every lap
  • I also reverted the "keep the fastest lap" check once, to confirm the segment test catches it.
  • npm run check passes locally (clippy only warns, in lines this PR doesn't touch), and on CI on my fork.
  • Smoke runs on Linux (Xvfb, software rendering, simulated rider): the Demo Loop with VP_SMOKE_LAPS=2 VP_SMOKE_AT=99999. The ride starts 50 m before the line and crosses it. The HUD text reads Lap 2 of 2 · 16.07 km, and the bots carry on round the loop.
Just before the line (lap 1) Just past the line (lap 2)
before after
  • Not tested: the native renderer, which only runs on macOS. Its changes compile and follow the three.js ones line by line, but I haven't run them. Could you give a lap ride across the line a quick look on a Mac?

  • npm run check passes locally

  • Tested on: Linux (Docker, Xvfb), three.js renderer, simulated rider; no hardware

Documentation

  • README (features / project status) updated, or not needed
  • Wiki source in docs/wiki/ updated, or not needed (Riding.md, Laps section)
  • HANDOFF.md updated if structure, formats, decisions or traps changed
  • Cache format version bumped if cached data changed shape: not needed, no stored shape changed

Anything unfinished or risky?

  • Group standings don't show who is a lap ahead; the gap is measured round the loop.
  • Tunnel across the line: a tunnel that crosses the start/finish line won't switch to the tunnel camera on a lap ride.
  • Very short loops: on a loop under about 1 km, barrier sections near the line can be drawn twice. That's harmless, apart from using up the instance cap.
  • Follow-ups, as discussed in Laps on loop routes #67:
    • FIT lap messages
    • a choice of whether the workout or the laps end the ride
    • a best-single-lap ghost

🤖 Generated with Claude Code

RalfLeonFasler and others added 7 commits November 7, 2026 14:20
The ride engine can now lap a closed route: distance stays the position
on the loop while lap and ridden count up, and recording uses ridden.
Ghosts are off on lap rides; climbs and segments are timed every lap and
keep the fastest. Engine only; the UI and ride wiring follow.
Tested with eight new core tests; existing ride tests unchanged.

Refs pepperstm#67

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lap rides now record, summarise and count towards goals by total distance ridden, and never set the route's best time. The ride request takes laps; the ride state reports lap and ridden; route_is_loop builds the route so old library entries offer laps.
Core is tested by gate (fmt, prettier, tsc, clippy, tests); src-tauri was not compiled locally and is checked by CI.

Refs pepperstm#67

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A closed route now offers a Laps choice in ride setup (once round, 2 to
20, or until I stop). On a lap ride the HUD shows the lap and total
distance, and the glide, standings, landmarks and profiles wrap round
the loop. Tested with tsc and Prettier; not run in the app.

Refs pepperstm#67

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rivals, the chase camera and the crowd barriers now carry on across the
start line on a lap ride instead of clamping at 0 or the end; the FINISH
arch is left out. Distances wrap with wrapGap/wrapDist (page) and the
same arithmetic in the native renderer, and the finish at distance ==
total is not folded back to the start.
Page checked by gate (tsc, Prettier); native renderer checked by CI build.

Refs pepperstm#67

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Explain the Laps choice on closed routes in the README, the wiki's
Riding page and HANDOFF: distance on the loop versus ridden, the
lap-ride rules agreed in pepperstm#67, and the wrap-around traps. Update the
core test count to 107. Not yet smoke-run in the app.

Refs pepperstm#67

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The road mesh ran from the first route sample to the last, so on a
closed route the ground showed through a strip across the road at the
line, which a lap ride crosses every lap. A closed route's road now has
one more section, the first again, with the texture carried on; both
renderers take the section count from the mesh. Also lists
VP_SMOKE_LAPS with the smoke-test variables.

Tested: road mesh test checks the closing section; npm run check
passes; smoke runs across the line on the Demo Loop (three.js).

Refs pepperstm#67

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs pepperstm#67

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RalfLeonFasler
RalfLeonFasler marked this pull request as ready for review November 7, 2026 21:05
@RalfLeonFasler

Copy link
Copy Markdown
Contributor Author

Hi! A gentle ping on this one, no rush. It still merges cleanly into main.

Heads-up: #74 (pluggable connectors) also changes src-tauri/src/commands.rs and web/src/ui/RideSetup.tsx, so the two PRs will conflict. If you'd rather merge #74 first, I'm happy to rebase this one onto it. Just let me know which order suits you.

@pepperstm

Copy link
Copy Markdown
Owner

Sorry Ralf, getting around to all the PR's today!

@pepperstm
pepperstm merged commit 6c7752c into pepperstm:main Nov 12, 2026
6 checks passed
@pepperstm pepperstm mentioned this pull request Nov 12, 2026
5 of 6 tasks
pepperstm added a commit that referenced this pull request Nov 12, 2026
## What

Herne Hill Velodrome as a built-in track: the 450 m outdoor track in
south London, at its real place, ridden in laps. It's on the home screen
as "Herne Hill Velodrome", and ride setup asks which way round:
anticlockwise as raced, or clockwise.

**Builds on #68 (laps)**, now merged.

## The track

- The route is the measuring line, exactly 450 m from the finish line.
That's on the home straight just north of the pavilion, as on the aerial
photos. It's the same oval as OpenBikeNet's `herne-hill-450`
(OpenBikeNet/protocol#6), so riders from other apps line up.
- Banked 7° on the straights, rising to 26° in the bends. Riders lean
with it.
- Painted with the light-blue côte d'azur, the black, red and blue
lines, the finish line, the 200 m line and the pursuit lines. The paint
stays on the inside whichever way you ride.
- A galvanised railing on a kerb round the outside, plain-coloured
boards along the straights (no real brands), and floodlights with arms
over the track.

## The grounds

- The pavilion: brick below, cedar above with the glazed club room,
seating steps up to the terrace, dark columns, the wave roof curling
over at the back, and the striped loop emblem on the south wall. No
Olympic rings.
- North of it: the bleachers, the club's containers, the white canopy on
three masts, paving and a car park.
- In the middle: the junior track, the hard standing, the path in, and
the small shelter.
- The ground is laid level and kept clear of trees and map buildings.
Houses, roads and the railway round it come from the map as usual. No
START/FINISH arches or village signs.

## Checked

- `npm run check` passes, with 6 new tests: lap length and start point,
both directions, banking, the track look, no race barriers, level ground
and an empty infield.
- Checked a live preview in demo mode on both renderers, riding each way
round (`VP_SMOKE_ROUTE=herne-hill` or `herne-hill-clockwise`).
- Not yet ridden with a trainer.

## Not sure about

- The buildings are sized from OpenStreetMap and photos, so they're
close but not surveyed.
- The track is drawn round the measuring line, so it sits a few metres
inside the real one. The buildings are placed by their distance from the
drawn edge, so they still stand as close to it as they really do.
@pepperstm pepperstm mentioned this pull request Nov 12, 2026
pepperstm added a commit that referenced this pull request Nov 12, 2026
Version 0.3.10: laps (#68, by Rallensooo), Herne Hill Velodrome (#75), signposted road routes (#77), your Strava routes (#78), the Dreeve connector and pluggable connectors (#74, #83, by Jörn), remembered sensors (#79), smooth bends with lean (#81) and the Linux Bluetooth fix (#84).
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.

Laps on loop routes

2 participants