Skip to content

feat: add current-loop torque accuracy evaluation tool - #45

Closed
yd-sl wants to merge 1 commit into
mainfrom
feat/tau-accuracy-eval
Closed

yd-sl wants to merge 1 commit into
mainfrom
feat/tau-accuracy-eval

Conversation

@yd-sl

@yd-sl yd-sl commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds tools/tau_eval, a pipeline implementing issue nexform-tech/litearm-benchmark#1: record every q/dq/tau status frame from the arm, replay the firmware's world-frame rigid-body inverse dynamics (RNEA) over it, and report how large the current-loop torque estimate's error is — with per-joint metrics, SVG figures, a Markdown report and error-source attribution.

tau is the motor's current-derived torque (p->tor × direction from the DM feedback frame), so the reported residual is the composite error of the current loop plus the model. It cannot be split into calibration vs. model error without a torque sensor or raw phase current; the report states this limitation explicitly.

Changes

  • tools/tau_eval/: stdlib-only package (Python 3.9+) with cli.py, collect.py, analyze.py, model.py, rnea.py, filters.py, plots.py, report.py and run.py; no numpy/matplotlib, figures are plain SVG.
  • Three excitation scenarios: a watchdog-fed static hold, a low-speed sine with analytic dq, and slow multi-pose moves streamed as smoothstep move_js references (avoids movej arrival timeouts on a bench whose gravity vector differs from the firmware default).
  • Analysis chain: uniform resampling, zero-phase Butterworth filters on q/dq and tau, central-difference ddq, RNEA, edge trim; every option and the model snapshot are persisted for offline reproduction via run.py analyze <dir>.
  • Diagnostics attribute residual structure to gravity/current-loop bias, friction, inertia and timing delay, and print concrete next steps.
  • tools/tau_eval/examples/make_synthetic.py runs collect → analyze → plot → report without hardware.
  • tests/test_tau_eval.py: firmware gravity golden probe, mass-matrix/RNEA consistency, filter/resampling properties, CSV round-trip, soft-limit validation, and a synthetic end-to-end run that also asserts the time series spans the full plot area.
  • runs/ is added to .gitignore; generated artifacts are never committed.

Testing

  • python3 -m pytest -q → 744 passed, 22 skipped (includes the 11 new tau_eval tests).
  • Synthetic end-to-end: mean RMSE ≈ 3e-6 N·m, 33 valid SVG figures, report rendered.
  • Real arm (firmware Litearm1.10.0-7J, bench gravity +Y, --gravity 0,9.81,0): all three scenarios recorded with flags=0x2C0 (enabled, MOVE_JS, no fault, no watchdog trip); mean RMSE hold 0.48, sine 0.36, poses 0.45 N·m.

Issues

Refs nexform-tech/litearm-benchmark#1

Issue #44 asks for a collect -> inverse dynamics -> error visualization
pipeline that judges how accurate the firmware's current-loop torque
estimate is. tools/tau_eval records every q/dq/tau status frame, replays
the firmware's world-frame RNEA over it, and writes per-joint metrics,
SVG figures and a Markdown report.

- three scenarios: a watchdog-fed static hold, a low-speed sine and
  slow multi-pose moves streamed as smoothstep move_js references;
- stdlib-only analysis: zero-phase Butterworth filters, central-difference
  ddq, uniform resampling, pure-SVG plotting, no numpy/matplotlib;
- diagnostics separate gravity/bias, friction, inertia and delay evidence
  and print concrete next steps;
- every option and the model snapshot are persisted, so an analysis can
  be reproduced offline with `run.py analyze <dir>`;
- examples/make_synthetic.py runs the whole pipeline without hardware.

Refs #44
@yd-sl yd-sl closed this Oct 29, 2026
@yd-sl
yd-sl deleted the feat/tau-accuracy-eval branch October 29, 2026 08:27
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.

1 participant