23 lines
812 B
Python
23 lines
812 B
Python
"""Force calibration coefficients and plot defaults from Orisys viewer2d."""
|
|
|
|
from __future__ import annotations
|
|
|
|
# Linear FN → Newtons (y = mx + c), from orisys examples/gui/sensors/adapter.py.
|
|
NORMAL_FORCE_CAL_SLOPE = 3.92685554668795e-05
|
|
NORMAL_FORCE_CAL_OFFSET = 0.0217596967278535
|
|
|
|
# PyQtGraph force-curve tuning from examples/gui/viewer2d/backend.py.
|
|
FORCE_SAMPLE_RATE_HZ = 30.0
|
|
PLOT_BUFFER_POINTS = 120
|
|
PLOT_WINDOW_SEC = PLOT_BUFFER_POINTS / FORCE_SAMPLE_RATE_HZ
|
|
Y_AXIS_MIN_SPAN = 20000.0
|
|
CALIBRATED_FORCE_Y_MIN = -20.0
|
|
CALIBRATED_FORCE_Y_MAX = 20.0
|
|
Y_RANGE_ALPHA = 0.5
|
|
LOWPASS_CUTOFF_HZ = 10.0
|
|
|
|
|
|
def calibrate_normal_force(raw_value: float) -> float:
|
|
"""Convert raw normal-force reading to Newtons using y = mx + c."""
|
|
return NORMAL_FORCE_CAL_SLOPE * float(raw_value) + NORMAL_FORCE_CAL_OFFSET
|