This commit is contained in:
cheng
2026-07-03 11:29:32 +08:00
parent 15088f9810
commit ec15850ffa
112 changed files with 1315 additions and 953 deletions
+1
View File
@@ -0,0 +1 @@
"""Shared path and utility helpers."""
+23
View File
@@ -0,0 +1,23 @@
class ExponentialFilter:
def __init__(self, alpha):
self.alpha = max(0.0, min(1.0, float(alpha)))
self.value = 0.0
self.initialized = False
def update(self, sample):
sample = float(sample)
if not self.initialized:
self.value = sample
self.initialized = True
else:
self.value = self.alpha * sample + (1.0 - self.alpha) * self.value
return self.value
def reset(self):
self.value = 0.0
self.initialized = False
def clamp(value, min_value, max_value):
return max(min_value, min(max_value, value))
+24
View File
@@ -0,0 +1,24 @@
from pathlib import Path
import sys
def _runtime_root():
if getattr(sys, "frozen", False):
exe_dir = Path(sys.executable).resolve().parent
if (exe_dir / "config").exists():
return exe_dir
return Path(getattr(sys, "_MEIPASS", exe_dir)).resolve()
return Path(__file__).resolve().parents[2]
REPO_ROOT = _runtime_root()
PACKAGE_DIR = REPO_ROOT / "gripper"
SDK_DIR = REPO_ROOT / "sdk"
SRC_DIR = REPO_ROOT / "src"
def ensure_project_paths():
for path in (SDK_DIR, SRC_DIR, REPO_ROOT):
path_text = str(path)
if path_text not in sys.path:
sys.path.insert(0, path_text)