Repository navigation
Description
Status: done
Part of #3652 (step 2).
TL;DR
Goal: Every route file that the web planner or the phone writes from planned points has fewer points, and its climb is exactly the climb of all its points.
Problem: The converter keeps a point at each height change of 1 m (ele_keep_m, firmware/obc-route/src/convert.rs:263, :304): a cycling line has about 41 to 43 points per km, a hiking line about 63 to 68. A plain 3 m step, measured from the last kept point, loses climb, because the header climb comes from the kept points only.
Decision: For points_to_obcr only, a point stays when its height differs by ELE_DEADBAND_M (3 m) or more from the dead-band reference of the points already kept (band.smoothed()), not from the last kept point. Then every point that the dead band books is kept, and the header climb equals the climb of all points.
Systems: navigation, simulators
Contracts: specs/obcr-route.md §5 (one sentence)
Size: S (one emitter rule, its tests, one spec sentence, about 100 lines)
Facts
-
The header climb is the dead band (3 m,
obc_elevation::ELE_DEADBAND_M) over the kept points only (Encoder::emit,convert.rs:700-712; header:450); "to climb" on the device is scaled to it (profile.rs:200-207). -
The height rule compares the pending point with the last kept point (
convert.rs:386-387). A point kept for a bend moves that base away from the dead-band reference: heights 100, 101 (kept at a bend), 103, 100 book +3/−3 over all points, but 0 over the kept points with a plain 3 m rule. -
Measured on real routed lines of the test plans (
/media/timo/OSM1/tmp/explore-3506/long-trips-design/tools/ascent.py, a model of the shipped decimator, each day encoded alone as a day route is; output intools/ascent.out):Plan Rule Points/km Climb of the plan Worst day Largest day route Cycling 32 days, 1,972 km, 38,118 m 1 m from last kept (today) 42.8 exact 0 m 3,518 3 m from last kept 24.5 −50 m (−0.13 %) −26 m 1,969 3 m from the dead-band reference 26.9 exact 0 m 2,186 Cycling 64 days, 3,916 km, 70,380 m 1 m from last kept 40.9 exact 0 m 3,531 3 m from last kept 23.9 −145 m (−0.21 %) −25 m 1,968 3 m from the dead-band reference 26.2 exact 0 m 2,168 Hiking 32 days, 716 km, 34,179 m 1 m from last kept 67.8 exact 0 m 2,176 3 m from last kept 47.1 −53 m (−0.16 %) −15 m 1,541 3 m from the dead-band reference 50.9 exact 0 m 1,680 Hiking 64 days, 1,448 km, 59,804 m 1 m from last kept 63.0 exact 0 m 2,469 3 m from last kept 42.9 −109 m (−0.18 %) −15 m 1,548 3 m from the dead-band reference 46.3 exact 0 m 1,688 The plain rule loses up to 26 m on a day (10 to 21 days of each plan lose more than 5 m), so it is rejected: a climb figure must never clearly undercount. The reference rule keeps the climb exact and costs about 10 % more points than the plain rule, 25 to 37 % fewer than today.
-
points_to_obcr(convert.rs:164) writes the routes of the web planner (builder/wasm/src/convert_web.rs:34obc_convert_line_to_obcr→builder/wasm/src/convert.rs:170line_to_obcr→points_to_obcr) and of the phone (sim/phone/host/src/route_codec.rs:130, the staticlib that the iOS app links). The device's own writers (nav.rs:73-76,splice.rs:56-60,trim.rs:264) set their own step and do not change.
Plan
ObcrEmitter(convert.rs:226): a new fieldele_keep_from_band: bool(false ininit_in_placeandempty), and a methodkeep_booked_elevation()that setsele_keep_m = ELE_DEADBAND_M as i16andele_keep_from_band = true. In the height rule (convert.rs:386-387): withele_keep_from_band, the base isself.enc.band.smoothed()(rounded to whole metres); when it isNone(no known height yet, or after a pause), the base is the last kept point, as today.points_to_obcr: callemitter.keep_booked_elevation()afterObcrEmitter::new.specs/obcr-route.md§5, the decimator line: "A line written from planned points keeps each point whose height differs by the elevation dead-band or more from the dead-band reference of the kept points, so the stored ascent and descent equal those of all points."
Tests
firmware/obc-route/src/convert.rstests: a bent line (a point kept for a bend) with a crest of less than 3 m after the bend, as in Facts: the header ascent and descent ofpoints_to_obcrequal aDeadBandover all input heights; the point count is lower than with a 1 m step.firmware/obc-route/tests/cases/convert.rs:296-299("Too Long") usesele: (k % 2); with the new rule about 55 points stay and the call no longer fails. Change it toele: ((k % 2) * 3) as i16, so every point stays and the route is still too long.- The wasm test (
builder/wasm/src/convert.rs:460) comparesline_to_obcrwithpoints_to_obcrand stays green. No guard baseline changes (climbs.jsongoes directly intosegment_climbs). firmware/tools/resource_baseline.json: the new field can growObcrEmitter, which lives in device arenas (nav.rs:541,splice.rs:103), andresource_guard.py(check_report,:902-915) fails on any drift of the compile-time allocations. Check the resource report of the head build in CI. If an entry changed, the pull request re-pins the changed entries ofresource_baseline.jsonfrom that head build's report (never from a rebuild of the base) and lists each figure old → new; if nothing changed, it says so.- The Swift test
companion-ios/Packages/OBCKit/Tests/OBCTransportTests/RouteObjectCodecTests.swift:115-121zig-zags with steps of 12 m or more and stays green; it needs macOS and runs in CI.
For the pull request text
Effects for the rider, one line each:
- Each phone route already on the bike computer shows "on device, out of date" once (the phone compares a fresh encode,
MainScreenModel.swift:479-485); the next upload sends it again, smaller. - The phone no longer recognises its old uploads by their content (
adoptByContent,MainScreenModel.swift:443-457); an old copy without its link is uploaded again. - Plans that the web planner sent before keep their 1 m files until they change (the web sends only plans in
waiting,sync.ts:120).
Checks
obc test -p obc-route,obc test -p obc-ios-host,obc exec cargo clippy -p obc-route --all-targets -- -D warnings(same forobc-ios-host).python3 -I /media/timo/OSM1/tmp/explore-3506/long-trips-design/tools/ascent.py SERVICE PLAN PROFILE DAYSwith the route service oftools/run.sh, for the 4 test plans: the new rule gives an exact climb and a worst day of 0 m. If the code differs from the model, change the model to match the code first.- In
builder/web:npx vitest run src/lib/device-sync/sync.test.tsafterobc suites preparerebuilt the bridge.
Done when
- The checks pass; CI runs the Swift tests; the resource figures are in the pull request.
- Note: the planner's climb adds every rise of its samples (
profile-data.ts:53-63), and the bike computer books a 3 m dead band; the two figures differ by design, so the check compares the bike computer with itself, before and after. - The owner's check, on his bike computer: before installing anything, he notes the climb that the bike computer shows for each day of one phone trip and for one route sent from the web planner. Then he installs the new phone app (
obc ios-companion) and the new web planner build, sends the same phone trip and the same web route again, and reads the climbs again. Pass when each day of the phone trip and the web route show the same climb as before, within 1 m (the web planner sends a plan as one route until Device sync: send a trip of up to 32 days as day routes and a trip object #3711); fail when one shows less.
Public docs: no change.
Activity
timohueser commentedon Nov 19, 2026
The owner decided: #3718 merges on the measured proof (the climb in the route files equals the climb of all points on every day of the four test plans). His check on the bike computer (the climb of a phone trip and of a web route before and after, within 1 m) is done once, together with the device check of #3711.
Generated by Claude Code