init
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""Shared path and utility helpers."""
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user