feat(pose_3d): bottone Sincronizza con robot (refetch state + reset target)
This commit is contained in:
1 parent
b852976a4a
commit
18dce0d951
2 files changed
+23
No files matched your search
@@ -512,6 +512,9 @@
|
|||||||
<button id="p3ApplyBtn">Applica (Editor)</button>
|
<button id="p3ApplyBtn">Applica (Editor)</button>
|
||||||
<button id="p3CancelBtn">Annulla modifica</button>
|
<button id="p3CancelBtn">Annulla modifica</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="p3-row">
|
||||||
|
<button id="p3SyncBtn" title="Ricopia la posa attuale del robot negli input">⟳ Sincronizza con robot</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="p3-section">
|
<div class="p3-section">
|
||||||
|
|||||||
@@ -559,6 +559,25 @@ function onCancelClick() {
|
|||||||
updateReadout();
|
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) {
|
function showError(msg) {
|
||||||
$('p3ErrorBox').style.display = 'block';
|
$('p3ErrorBox').style.display = 'block';
|
||||||
$('p3ErrorText').textContent = msg;
|
$('p3ErrorText').textContent = msg;
|
||||||
@@ -574,6 +593,7 @@ function clearError() {
|
|||||||
function bindEditorButtons() {
|
function bindEditorButtons() {
|
||||||
$('p3ApplyBtn').addEventListener('click', onApplyClick);
|
$('p3ApplyBtn').addEventListener('click', onApplyClick);
|
||||||
$('p3CancelBtn').addEventListener('click', onCancelClick);
|
$('p3CancelBtn').addEventListener('click', onCancelClick);
|
||||||
|
$('p3SyncBtn').addEventListener('click', onSyncWithRobot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- mode toggle -----
|
// ----- mode toggle -----
|
||||||
|
|||||||
Reference in new issue
Block a user