included low pass filter in package and add to plot_data example
This commit is contained in:
@@ -27,8 +27,17 @@ def resource_path(*parts: str) -> Path:
|
||||
|
||||
|
||||
def default_config_path() -> str:
|
||||
"""Default ORY-FINGER config name (resolves to dd02-ov via alias)."""
|
||||
return "dd02"
|
||||
"""Default ORY-FINGER config name (packaged stem ``finger``)."""
|
||||
return "finger"
|
||||
|
||||
|
||||
def require_gui_extras() -> None:
|
||||
try:
|
||||
import open3d # noqa: F401
|
||||
from PyQt5 import QtWidgets # noqa: F401
|
||||
import pyqtgraph # noqa: F401
|
||||
except ImportError as exc:
|
||||
raise SystemExit('GUI example requires: pip install "orisys[gui]"') from exc
|
||||
|
||||
|
||||
def configure_frozen_runtime() -> None:
|
||||
|
||||
@@ -11,6 +11,7 @@ from typing import Any, Optional
|
||||
import cv2
|
||||
import numpy as np
|
||||
import orisys
|
||||
from orisys.signal_processing import calibrate_normal_force
|
||||
|
||||
from .roi_geometry import (
|
||||
build_roi_warp,
|
||||
@@ -22,10 +23,6 @@ from .roi_geometry import (
|
||||
)
|
||||
|
||||
|
||||
NORMAL_FORCE_CAL_SLOPE = 3.92685554668795e-05
|
||||
NORMAL_FORCE_CAL_OFFSET = 0.0217596967278535
|
||||
|
||||
|
||||
@dataclass
|
||||
class FrameSnapshot:
|
||||
"""Normalized per-frame payload consumed by the Qt viewer."""
|
||||
@@ -49,11 +46,6 @@ class FrameSnapshot:
|
||||
record_frame: Optional[np.ndarray] = None
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
class SensorAdapter(ABC):
|
||||
"""Common interface between Qt and concrete sensor backends."""
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from typing import Literal, Optional, Sequence, Tuple
|
||||
import cv2
|
||||
import numpy as np
|
||||
import orisys
|
||||
from scipy.signal import butter, filtfilt
|
||||
from orisys.signal_processing import lowpass_filter
|
||||
|
||||
FORCE_SAMPLE_RATE_HZ = 30.0
|
||||
PLOT_BUFFER_POINTS = 120
|
||||
@@ -61,32 +61,6 @@ class ForcePlotState:
|
||||
y_ranges: Tuple[Tuple[float, float], Tuple[float, float], Tuple[float, float]]
|
||||
|
||||
|
||||
def lowpass_filter(
|
||||
data,
|
||||
cutoff_hz: float,
|
||||
sample_rate_hz: float = FORCE_SAMPLE_RATE_HZ,
|
||||
order: int = 2,
|
||||
) -> np.ndarray:
|
||||
"""Zero-phase Butterworth low-pass for uniformly sampled 1-D data."""
|
||||
y = np.asarray(data, dtype=np.float64)
|
||||
if cutoff_hz == 0:
|
||||
return y.copy()
|
||||
if y.size == 0:
|
||||
return y
|
||||
|
||||
nyquist = 0.5 * sample_rate_hz
|
||||
if cutoff_hz < 0 or cutoff_hz >= nyquist:
|
||||
raise ValueError(
|
||||
f"cutoff_hz must be in (0, {nyquist}) for sample_rate_hz={sample_rate_hz}"
|
||||
)
|
||||
|
||||
b, a = butter(order, cutoff_hz / nyquist, btype="low")
|
||||
padlen = 3 * (max(len(b), len(a)) - 1)
|
||||
if y.size <= padlen:
|
||||
return y.copy()
|
||||
return filtfilt(b, a, y)
|
||||
|
||||
|
||||
def ensure_bgr(img: Optional[np.ndarray]) -> Optional[np.ndarray]:
|
||||
if img is None:
|
||||
return None
|
||||
|
||||
@@ -111,7 +111,7 @@ class QtViewerWindow(QMainWindow):
|
||||
self.btn_config.setObjectName("btnConfig")
|
||||
self.btn_config.clicked.connect(self._select_config)
|
||||
bar.addWidget(self.btn_config)
|
||||
self.config_edit = QLineEdit("./config/ddjx01.json")
|
||||
self.config_edit = QLineEdit("box")
|
||||
bar.addWidget(self.config_edit, 1)
|
||||
|
||||
self.btn_reset = QPushButton("重置")
|
||||
|
||||
@@ -137,7 +137,7 @@ class SettingsPanelWidget(QWidget):
|
||||
root.addWidget(self._caption("Config"))
|
||||
config_row = QHBoxLayout()
|
||||
config_row.setSpacing(6)
|
||||
self.config_edit = QLineEdit("dd02")
|
||||
self.config_edit = QLineEdit("finger")
|
||||
config_row.addWidget(self.config_edit, 1)
|
||||
self.btn_browse_config = QPushButton("…")
|
||||
self.btn_browse_config.setFixedWidth(32)
|
||||
|
||||
Reference in New Issue
Block a user