feat(pose_3d): bottone Sincronizza con robot (refetch state + reset target)

This commit is contained in:
Adriano Dal Pastro committed 2026-05-21 17:08:09 +02:00
1 parent b852976a4a
commit 18dce0d951
2 files changed
+23

No files matched your search

+20
View File
@@ -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 -----