From 18dce0d9516f3dff02ab4414c30896ce1cd5f069 Mon Sep 17 00:00:00 2001 From: Adriano Dal Pastro Date: Thu, 21 May 2026 17:08:09 +0200 Subject: [PATCH] feat(pose_3d): bottone Sincronizza con robot (refetch state + reset target) --- web/index.html | 3 +++ web/pose_3d.js | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/web/index.html b/web/index.html index 5fe1fe2..8426b49 100644 --- a/web/index.html +++ b/web/index.html @@ -512,6 +512,9 @@ +
+ +
diff --git a/web/pose_3d.js b/web/pose_3d.js index 4304a49..fbbe657 100644 --- a/web/pose_3d.js +++ b/web/pose_3d.js @@ -559,6 +559,25 @@ function onCancelClick() { updateReadout(); } +async function onSyncWithRobot() { + // Force-refresh dallo stato del robot e ricopia la posa attuale nel target + // (cosi' gli input riflettono il robot, e l'utente puo' partire da li'). + clearError(); + try { + await pollState(); // refresha state.current dal backend + } catch (e) { + // soft fail; pollState gia' logga internamente + } + const side = state.active_side; + if (!side) return; + state.target[side] = null; + // Forza il ghost (e quindi gli input) ad allinearsi sul reale (con fallback arm) + syncGhostsToTargetOrReal(); + updateReadout(); + $('p3Status').textContent = '✓ Sincronizzato con posa robot'; + $('p3Status').className = 'p3-status ok'; +} + function showError(msg) { $('p3ErrorBox').style.display = 'block'; $('p3ErrorText').textContent = msg; @@ -574,6 +593,7 @@ function clearError() { function bindEditorButtons() { $('p3ApplyBtn').addEventListener('click', onApplyClick); $('p3CancelBtn').addEventListener('click', onCancelClick); + $('p3SyncBtn').addEventListener('click', onSyncWithRobot); } // ----- mode toggle -----