From 757eb012002c0f7b61d5b819babb72c09c4967b4 Mon Sep 17 00:00:00 2001 From: Adriano Dal Pastro Date: Wed, 20 May 2026 12:07:11 +0200 Subject: [PATCH] feat(deps): aggiungi front_camera() e tab_right_arm_cfg() --- src/presa_mano/api/_deps.py | 11 +++++++++++ tests/test_deps_right_arm.py | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/test_deps_right_arm.py diff --git a/src/presa_mano/api/_deps.py b/src/presa_mano/api/_deps.py index a3f61d2..a9e50c6 100644 --- a/src/presa_mano/api/_deps.py +++ b/src/presa_mano/api/_deps.py @@ -26,6 +26,12 @@ def nuwa() -> NuwaClient: return NuwaClient(c["base_url"], timeout_s=c.get("timeout_s", 5.0), api_key=c.get("api_key")) +def front_camera() -> NuwaClient: + """Camera depth montata sulla fronte del robot (servizio Nuwa-like in docker).""" + c = _svc(get_config(), "front_camera") + return NuwaClient(c["base_url"], timeout_s=c.get("timeout_s", 5.0)) + + def marker() -> MarkerClient: c = _svc(get_config(), "marker_finder") return MarkerClient(c["base_url"], timeout_s=c.get("timeout_s", 5.0)) @@ -132,3 +138,8 @@ def samples_file_path(side: str | None = None) -> Path: def depth_correction_path() -> Path: """Where the depth-bias correction state (params + samples) is persisted.""" return data_dir() / "depth_correction.json" + + +def tab_right_arm_cfg() -> dict[str, Any]: + """Blocco di config per la tab Braccio DX. Restituisce {} se mancante.""" + return get_config().get("tab_right_arm", {}) or {} diff --git a/tests/test_deps_right_arm.py b/tests/test_deps_right_arm.py new file mode 100644 index 0000000..7cccd85 --- /dev/null +++ b/tests/test_deps_right_arm.py @@ -0,0 +1,23 @@ +"""Verifica che _deps esponga front_camera() e tab_right_arm_cfg().""" +from __future__ import annotations + +from presa_mano.api import _deps +from presa_mano.clients import NuwaClient + + +def test_front_camera_returns_nuwa_client_with_config_base_url(): + cam = _deps.front_camera() + assert isinstance(cam, NuwaClient) + # base_url da config.yaml (stripped della trailing slash dal client) + assert cam.base_url.startswith("http") + # Deve essere DIVERSO dall'URL della nuwa principale + assert cam.base_url != _deps.nuwa().base_url + + +def test_tab_right_arm_cfg_returns_dict_with_required_keys(): + cfg = _deps.tab_right_arm_cfg() + assert cfg["yolo_class"] == "pestello" + for key in ("yolo_conf_front", "yolo_conf_wrist", "move_offset_camera_mm", + "axis_sign_cam_to_wrist", "max_step_m", "z_floor_m", + "home_pose", "custom_pose"): + assert key in cfg