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 -----