Ride the drivetrain, command the load in watts
Speed now comes from the drivetrain and the load from the road, which is the way round a bike actually works. Speed is cadence x development, filtered lightly. Power, not cadence, decides whether the rider is driving it: on a direct-drive trainer the flywheel keeps the cranks turning after they stop, so cadence alone reads a healthy 80 rpm for someone doing nothing. Below 15 W the speed runs down to whatever the gradient sustains on no power - zero uphill, a real freewheeling speed on a descent. Stopping on a 3.5% climb used to settle at 22 km/h and stay there, because the model wanted to decelerate and a blend toward the flywheel speed outvoted it; that blend is gone. The D100 sends no cadence over FTMS - it is a rebadged Magene T110 with cadence disabled in firmware (qdomyos-zwift#3282) - so it is inferred from wheel speed, which one sprocket and no freewheel make exact. Its Zwift channel does carry cadence, and is now greeted with RideOn and subscribed on every notifying characteristic, so a measured value is used where one arrives. The load is commanded as power, not gradient. The trainer declares 50-600 W in 1 W steps against 0-6% inclination in 0.1% steps refusing negatives, and whether it acts on 0x11 at all is still unconfirmed. Its power target is a ceiling rather than a setpoint, which is very nearly what a road is: exceed it and the surplus becomes speed. Gravity travels on the same channel as watts, so nothing is lost by leaving 0x11 alone. LoadChannel keeps the gradient path selectable and tested. Virtual shifting reaches the trainer for the first time. The physics load model was written but never called, and a paddle press both shifted a gear in Rust and nudged the gradient in the webview - the shift silently, the tilt visibly, so the paddles looked like a gradient trim. Also: a fixed 12 W drivetrain loss, held as a power because that is how it presents; crank length, so a gear can be reported as the force it puts under the foot; gear and pedal force on the ride screen; a drag-race profile for testing gearing on the flat. Two readout bugs fixed on the way. The rolling windows were trimmed by timestamp but fed on a fixed timer, so every second spent on the ride screen before starting pushed samples at t=0 that could never expire - speed read a fraction of the truth for the first 45 s. And the headline speed was a 45 s mean, which took most of a minute to show a gear change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,9 +3,20 @@
|
||||
# plain `cargo build` produces a binary wired to localhost:1420 that shows a
|
||||
# BLACK WINDOW unless a Vite dev server happens to be running. Incremental
|
||||
# builds take seconds, and this removes a whole class of confusion.
|
||||
set -e
|
||||
#
|
||||
# `pipefail` is load-bearing. This script used to end the build line with
|
||||
# `| tail -3`, which meant the exit status came from `tail` and was always 0:
|
||||
# a build that failed to compile printed three lines of error, `set -e` saw
|
||||
# success, and the script went on to launch whatever binary was already in
|
||||
# target/ — silently, and possibly hours old. Every symptom of that looks like
|
||||
# a code change that "did not work", because the code being run is not the code
|
||||
# on disk. A failed build must stop here.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")" && pwd)"
|
||||
LOG="$ROOT/bikecontrol.log"
|
||||
BIN="$ROOT/target/debug/bikecontrol-app"
|
||||
BUILD_LOG="$ROOT/target/last-build.log"
|
||||
|
||||
# WebKitGTK 2.52 on Wayland + Intel paints black rectangles via its DMABUF
|
||||
# renderer; disabling it costs nothing here (the UI is 2D canvas and CSS).
|
||||
@@ -14,9 +25,38 @@ export WEBKIT_DISABLE_COMPOSITING_MODE=1
|
||||
export RUST_LOG="${RUST_LOG:-debug,btleplug=info,tao=warn,wry=warn}"
|
||||
|
||||
echo "building (embeds the frontend — this is what avoids the black window)..."
|
||||
( cd "$ROOT/src-tauri" && cargo tauri build --debug --no-bundle ) 2>&1 | tail -3
|
||||
mkdir -p "$(dirname "$BUILD_LOG")"
|
||||
|
||||
BIN="$ROOT/target/debug/bikecontrol-app"
|
||||
# Quiet on success, complete on failure. Piping straight to `tail` would hide
|
||||
# the first error of a cascade, which is usually the only one that matters.
|
||||
if ( cd "$ROOT/src-tauri" && cargo tauri build --debug --no-bundle ) >"$BUILD_LOG" 2>&1; then
|
||||
tail -3 "$BUILD_LOG"
|
||||
else
|
||||
status=$?
|
||||
echo
|
||||
echo "════════════════════════════════════════════"
|
||||
echo " BUILD FAILED — not launching."
|
||||
echo "════════════════════════════════════════════"
|
||||
echo
|
||||
cat "$BUILD_LOG"
|
||||
echo
|
||||
if [[ -x $BIN ]]; then
|
||||
echo "There IS an older binary at $BIN (built $(date -r "$BIN" '+%Y-%m-%d %H:%M:%S'))."
|
||||
echo "It is deliberately NOT being launched: running stale code against new"
|
||||
echo "expectations is how an afternoon disappears."
|
||||
fi
|
||||
exit $status
|
||||
fi
|
||||
|
||||
if [[ ! -x $BIN ]]; then
|
||||
echo "build reported success but $BIN is missing" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Say what is actually about to run. The whole point of the machinery above is
|
||||
# that this line can be trusted, so print it where it cannot be missed.
|
||||
echo "=== BikeControl $(date '+%H:%M:%S') ===" > "$LOG"
|
||||
echo "launching $BIN — logging to $LOG"
|
||||
echo "launching $BIN"
|
||||
echo " built: $(date -r "$BIN" '+%Y-%m-%d %H:%M:%S')"
|
||||
echo " logging: $LOG"
|
||||
exec "$BIN" "$@" 2>&1 | tee -a "$LOG"
|
||||
|
||||
Reference in New Issue
Block a user