Skip to content

feat: surface offset + balance/TOF safety + CI workflow#4

Merged
Davide-Colabella merged 5 commits into
masterfrom
feature/surface-offset-ci-readme
May 29, 2026
Merged

feat: surface offset + balance/TOF safety + CI workflow#4
Davide-Colabella merged 5 commits into
masterfrom
feature/surface-offset-ci-readme

Conversation

@Davide-Colabella
Copy link
Copy Markdown
Member

Summary

Five-commit branch that covers everything from yesterday's analysis session plus the new CI/CD plumbing:

  1. checkpoint: pre-analysis float behavior baseline — the safety snapshot before the analysis started (refactor from yesterday's direction-of-travel change).
  2. feat: surface target offset + balance/TOF safety hardening — runtime-tunable SURFACE_TARGET_OFFSET_M (new command 18 SURFACE_OFFSET), TOF safe range widened to 85 mm, moveToMax/balance use uToMotorPos(), motor _clampTarget is now symmetric, balance refuses to start without homing, profile.cpp uses the new offset, ESPB parser + protocol contract test updated.
  3. docs: standardize file headers and add current maintainers — uniform header block on every firmware .cpp/.h with module description and current maintainers (Colabella + Benevenga). No behavioural change.
  4. docs(readme): bring README in sync with current firmware — corrects TOF model (VL53L4CD → VL53L7CX), MOTOR_TRAVEL_MM (45 → 35), adds Syringe/Motor Convention and Surface Target Offset sections, fills in commands 14–18 in the command tables, updates the state machine diagram and LED states table, bumps version to 11.2.0.
  5. ci: GitHub Actions workflows + CONTRIBUTING guideci.yml builds all three PlatformIO environments on push/PR, release.yml publishes firmware on v* tags, CONTRIBUTING.md documents the trunk-based git workflow and the one-time branch-protection setup.

Test plan

  • pio run -e espA -e espB -e espA_pool passes locally on all three environments
  • pio test -e espB -f unit_hw/espb_bridge/test_protocol_contract --without-uploading --without-testing compiles (the updated test now asserts count == 18)
  • YAML linted (python3 -c "import yaml; yaml.safe_load(...)")
  • Bench: after merge, flash ESPA and run HOME_MOTOR → check the TOF reaches ≈ 75 mm without "TOF above safe range" intermittent errors
  • Bench: BALANCE without a prior homing must fail with Balance: homing required in the debug log
  • Bench: BALANCE after homing must cycle until Bar02 pressure rises by 5 kPa
  • Bench / pool: SURFACE_OFFSET 0.10 then a shallow PID hold — float top should sit ~10 cm below the surface; changing the offset to 0.05 should shift the equilibrium by ~5 cm
  • Regression: SYRINGE_SET, PID_HOLD, PID_STEP still work identically via both USB direct and ESPB bridge

Notes for the reviewer

  • Yesterday's pre-analysis checkpoint (commit 1) is part of this PR because it was never pushed before — review of that commit can be limited to spot-checking, since it already represented the intended state at the start of today's work.
  • After merge, please push a v11.2.0 tag to trigger the release workflow and confirm the binary publication end-to-end.

- New SURFACE_TARGET_OFFSET_M (default 0.10 m) and CMD_SET_SURFACE_OFFSET (18)
  so the float can hold its top at a configurable depth below the surface.
  Tunable at runtime via the SURFACE_OFFSET command (ESPB bridge + direct USB).
- TOF_SAFE_RANGE_MAX_MM raised 80 → 85 mm to give 10 mm of margin above the
  homing threshold without risking the rear mechanical stop.
- moveToMax() and balance() now use uToMotorPos() instead of hard-coded signs,
  staying consistent with MOTOR_INVERT_LOGICAL.
- MotorController::_clampTarget extended to a symmetric range, matching the
  current geometry where u=1 maps to a negative motor position.
- balance() refactored: deduplicated extend/retract via _balanceStrokeTo helper,
  and refuses to start without a prior homing (was forcing pos=0 — mechanically
  risky).
- profile.cpp surface-hold reference now derived from FLOAT_LENGTH +
  surfaceTargetOffset(); the misleading "logica invertita" comment is gone.
- ESPB parser: SURFACE_OFFSET added to PROTOCOL_COMMANDS and given a dedicated
  arg-parsing block; protocol_contract test updated to cover commands 14–18.
- Uniform header block on every firmware .cpp and .h: filename, 2–4 lines of
  module description, and "Maintainers: Colabella Davide, Benevenga Filippo —
  Team PoliTOcean".
- Updates the existing headers on src/espA/main.cpp and src/espB/main.cpp:
  Fachechi and Gullotta move to "Past contributors"; current maintainers added.
- Adds the same maintainers line to include/config.h, include/float_common.h,
  and the public headers of every module under lib/ (except the upstream
  libraries DebugSerial and RGBLed, which are kept untouched).
- Fixes a stale "VL53L4CD" mention in src/espA/main.cpp module map (sensor was
  swapped to VL53L7CX in 2a74291).

No behavioural change.
- TOF sensor model corrected from VL53L4CD to VL53L7CX (multi-zone 4×4 with
  central-zone mask 0x0660); driver, pin notes, hardware table, mermaid
  diagram, glossary and library links all updated.
- MOTOR_TRAVEL_MM corrected: 45 → 35 mm to match include/config.h.
- New "Syringe / Motor Convention" subsection: explains the u ∈ [0,1] PID
  contract, home / extension semantics, and the TOF safety thresholds
  (75 / 50 / 40 / 85 mm) with their rationale.
- New "Surface Target Offset" subsection covering SURFACE_TARGET_OFFSET_M
  and how to change it at compile time or at runtime.
- FLOAT Commands and GUI/ESPB/ESPA Protocol Contract tables now include the
  previously undocumented commands 14–18 (PARAMS_EXT, SYRINGE_SET, PID_HOLD,
  PID_STEP, SURFACE_OFFSET).
- ESPA State Machine diagram extended with the matching states/transitions.
- LED States table realigned to LEDState (scoped enum in led.h); added a note
  on the deliberate split between LEDState (ESPA) and FloatLEDState (ESPB).
- BALANCE description reflects the new behaviour (requires homing first).
- Version bumped to 11.2.0; changelog entry appended at the bottom.
- New "Direct USB Tuning Commands (ESPA)" subsection documents the line-based
  bench tuning commands accepted on ESPA's serial port.
- .github/workflows/ci.yml: builds all three PlatformIO environments
  (espA, espB, espA_pool) in parallel on push to any branch and on pull
  requests to master. PlatformIO core and per-env build caches keep warm
  runs under a couple of minutes. Concurrency group cancels superseded
  runs on the same ref. Step summary prints the firmware size table.
- .github/workflows/release.yml: on every v* tag, builds the three
  environments, renames the artifacts as <env>-<tag>.bin/.elf, and
  attaches them to a GitHub Release with auto-generated notes.
- CONTRIBUTING.md: documents the trunk-based git workflow, branch and
  commit conventions, PR expectations, the release procedure (tag v*),
  and the one-time branch-protection setup (UI steps and gh CLI command).
- README.md: CI badge in the header and a new "Continuous Integration"
  subsection under DEVELOPMENT AND TESTING, linking to the workflows and
  to CONTRIBUTING.

CI does not run the hardware test suites under test/unit_hw and
test/integration — they need a real ESP32 with motor/TOF/Bar02 wired up.
@Davide-Colabella Davide-Colabella requested a review from Skeitt May 29, 2026 10:10
@Davide-Colabella Davide-Colabella merged commit 5e50f97 into master May 29, 2026
6 checks passed
@Davide-Colabella Davide-Colabella deleted the feature/surface-offset-ci-readme branch May 29, 2026 10:14
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.

2 participants