Spaces:
Running
Download README.md from thelamapi/Next-Balance: direct link, hf CLI and curl.
- Browser
- Download file 3.57 kB
-
https://huggingface.co/spaces/thelamapi/Next-Balance/resolve/main/README.md
- Command line
-
hf download hf://spaces/thelamapi/Next-Balance/README.md
-
curl -L -o README.md https://huggingface.co/spaces/thelamapi/Next-Balance/resolve/main/README.md
title: Next Balance
emoji: ⚖️
colorFrom: green
colorTo: gray
sdk: static
app_file: index.html
pinned: false
license: apache-2.0
short_description: Adaptive vs PID control under payload changes (simulation)
Next Balance
Next Balance keeps a simulated lift platform at 0.5 m while its payload changes at t≈4 s and friction rises at t≈7 s. It compares a fixed PID controller with an adaptive controller that estimates mass, viscous friction and Coulomb friction online (recursive least squares on filtered signals) and rescales its control law. Simulation only.
Model: https://huggingface.co/thelamapi/Next-Balance — set load change, actuator delay, sensor noise and friction; both controllers re-run in the browser.
Results on held-out scenarios (200 seeds per split, same disturbances for both controllers)
| Split | Controller | Max deviation after load change, mean / p90 (m) | Settling time, median (s) | Settled | Control energy (kN²·s) |
|---|---|---|---|---|---|
| nominal | Fixed PID | 0.144 / 0.283 | 1.97 | 81% | 0.061 |
| nominal | Adaptive (Next Balance) | 0.140 / 0.263 | 5.03 | 96% | 0.052 |
| stress | Fixed PID | 0.286 / 0.540 | 2.19 | 68% | 0.098 |
| stress | Adaptive (Next Balance) | 0.292 / 0.504 | 5.10 | 90% | 0.094 |
Stress split by condition (mean max deviation in m, settled rate):
| Condition | n | PID | Adaptive | PID settled | Adaptive settled |
|---|---|---|---|---|---|
| heavy_load_change(dm>4kg) | 121 | 0.322 | 0.406 | 73% | 88% |
| load_removed(dm<0) | 10 | 0.234 | 0.035 | 20% | 100% |
| long_delay(>=40ms) | 88 | 0.447 | 0.359 | 51% | 82% |
| high_noise(>2mm) | 143 | 0.294 | 0.310 | 65% | 90% |
Paired wins (adaptive better on the same scenario): nominal max deviation 86/200, stress max deviation 69/200, stress energy 148/200. Settling time is measured from the load change until the platform last leaves a ±1 cm band (the later friction change counts). Runs that leave the band within the final 0.5 s count as not settled.
Replay video: the first held-out stress scenario and the stress scenario with the adaptive controller's largest deviation.
Method
- Plant: m(z̈+g) = u(t−delay) − c·ż − F·tanh(ż/0.01), dt = 10 ms, force limited to [0, 400] N, platform 2.0 kg.
- Shared α-β estimator (α=0.3, β=0.05). Both controllers only know the nominal payload.
- Fixed PID: Kp=300, Ki=400, Kd=80 plus nominal gravity feed-forward.
- Adaptive: RLS (λ=0.99) on [m, c, F] with state-variable filters (ω=10.0 rad/s); control u = m̂(ωn²e − 2ζωn v + ki∫e + g) + ĉv (F̂ is estimated but not fed back because it chatters with noisy velocity), ωn=6, ζ=0.7, ki=30. The delay value is given to the controller to align its regression.
- The 0.5 m target is approached with a 1 s ramp starting at t = 0.5 s.
- Both gain sets come from grid searches of the same size and cost (IAE + 0.5·energy) on 40 tuning seeds; test seeds are disjoint.
- The browser runs a line-by-line JavaScript port; Node parity on 6 fixed runs: max abs difference 8.459899447643693e-14.
Usage
python inference.py --dm 8 --delay 4 --noise 0.003 # prints metrics for both controllers
python inference.py --selftest
Limitations
- 1-D rigid-body model; no structural flexibility, actuator dynamics beyond pure delay, or sensor bias.
- The adaptive controller is told the actuator delay; an unknown delay would need estimation.
- Results are from simulation on NVIDIA L4; no physical platform was tested.
