From cc848a273de8bc59c2a8d91f64c44899ecc78448 Mon Sep 17 00:00:00 2001 From: ykcheungab Date: Wed, 7 Oct 2026 12:26:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=8A=9B=E5=80=BC=E9=98=88?= =?UTF-8?q?=E5=80=BC=E5=A4=84=E7=90=86=E5=B9=B6=E4=BF=9D=E7=95=99=E5=8E=9F?= =?UTF-8?q?=E5=A7=8B=E9=87=87=E6=A0=B7=20=E7=A7=BB=E9=99=A4=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=98=BE=E7=A4=BA=E5=9F=BA=E7=BA=BF=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E9=80=90=E8=BD=B4=E9=98=88=E5=80=BC=E7=BB=9F=E4=B8=80=E4=BD=9C?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E6=9B=B2=E7=BA=BF=E3=80=81=E8=AF=BB=E6=95=B0?= =?UTF-8?q?=E4=B8=8E=E8=AE=B0=E5=BD=95=E8=BE=93=E5=87=BA=EF=BC=8C=E6=A0=87?= =?UTF-8?q?=E5=AE=9A=E6=8B=9F=E5=90=88=E7=BB=A7=E7=BB=AD=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=8E=9F=E5=A7=8B=E9=87=87=E6=A0=B7=E3=80=82=20=E5=85=B1?= =?UTF-8?q?=E4=BA=AB=E5=B1=82=E5=85=A8=E9=87=8F=E6=B5=8B=E8=AF=95=E5=92=8C?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=20Studio=20=E6=B5=8B=E8=AF=95=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/test_force_output_pipeline.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 apps/studio/tests/test_force_output_pipeline.py diff --git a/apps/studio/tests/test_force_output_pipeline.py b/apps/studio/tests/test_force_output_pipeline.py new file mode 100644 index 0000000..e0aa2e5 --- /dev/null +++ b/apps/studio/tests/test_force_output_pipeline.py @@ -0,0 +1,52 @@ +"""One thresholded record fans out without changing calibration inputs.""" + +from types import SimpleNamespace + +import numpy as np + +from orisys_app_shared.force.session import SessionStore +from orisys_studio.recording import RecordingCoordinator + + +class _Capture: + is_recording = False + + def set_alarm_handler(self, handler): + self.alarm_handler = handler + + def on_packet(self, packet, *, sample): + self.sample = sample + + +class _Calibration: + def feed(self, sample): + self.sample = sample + + +def test_output_and_originals_share_frame_across_consumers(): + store = SessionStore() + calibration = _Calibration() + recording = _Capture() + coordinator = RecordingCoordinator( + session_store=store, cal_recorder=calibration, recorder=recording + ) + coordinator.set_force_thresholds(raw=50, newton=0.5) + packet = SimpleNamespace( + frame_id=7, mono_t=7.0, wall_t=1007.0, valid=True, + raw_available=True, force_calibrated=True, + calibrated_axes=("fn", "fx", "fy"), + normal_force_raw=49.0, shear_x_raw=-51.0, shear_y_raw=20.0, + normal_force=0.4, shear_x=-0.6, shear_y=0.1, + ) + output = coordinator.on_packet(packet) + + assert output is recording.sample + assert output.raw_triplet() == (49.0, -51.0, 20.0) + assert output.processed_triplet("raw") == (0.0, -51.0, 0.0) + assert output.processed_triplet("N") == (0.0, -0.6, 0.0) + assert calibration.sample.raw_triplet() == output.raw_triplet() + stored = store.data() + assert stored.frame_ids.tolist() == [7] + assert stored.raw[0].tolist() == [49.0, -51.0, 20.0] + assert stored.output_raw[0].tolist() == [0.0, -51.0, 0.0] + assert np.allclose(stored.output_newtons[0], [0.0, -0.6, 0.0])