Claude: WebView - SolutionButton
This commit is contained in:
@@ -208,6 +208,14 @@
|
||||
<label>aruco</label>
|
||||
<input type="file" id="fAruco" accept=".json">
|
||||
</div>
|
||||
<div class="file-row">
|
||||
<label>solution</label>
|
||||
<input type="file" id="fSolution" accept=".json">
|
||||
</div>
|
||||
<button id="btnJump" disabled style="width:100%;margin-top:8px;background:var(--accent);
|
||||
color:#06101a;border:none;border-radius:3px;padding:6px;font:inherit;font-size:11px;
|
||||
font-weight:bold;cursor:pointer;opacity:0.45;">Auf Lösung springen</button>
|
||||
<div id="solInfo" style="font-size:10px;color:var(--muted);min-height:12px;margin-top:5px;"></div>
|
||||
</div>
|
||||
|
||||
<!-- test poses -->
|
||||
@@ -559,6 +567,7 @@ for (const [id, grp] of Object.entries(toggles)) {
|
||||
|
||||
let robotData = null;
|
||||
let arucoData = null;
|
||||
let solutionData = null;
|
||||
const joints = { x:0, y:0, z:0, a:0, b:0, c:0, e:0 };
|
||||
|
||||
// ─── slider setup ─────────────────────────────────────────────
|
||||
@@ -646,6 +655,40 @@ document.getElementById('fAruco').addEventListener('change', async e => {
|
||||
rebuild();
|
||||
});
|
||||
|
||||
// ─── solution (robot_state.json) → set joint sliders ───────────
|
||||
function applySolution() {
|
||||
if (!solutionData) { setStatus('keine Lösung geladen'); return; }
|
||||
const mv = solutionData.movements || {};
|
||||
const done = [];
|
||||
for (const k of Object.keys(joints)) {
|
||||
const m = mv[k];
|
||||
if (m == null) continue;
|
||||
let v = (typeof m === 'object') ? (m.value ?? m.value_mm ?? m.value_deg) : m;
|
||||
if (v == null || isNaN(v)) continue;
|
||||
setSlider(k, Number(v));
|
||||
const conf = (typeof m === 'object') ? (m.confidence || '') : '';
|
||||
done.push(k + ((conf === 'low' || conf === 'none') ? '⚠' : ''));
|
||||
}
|
||||
rebuild();
|
||||
const info = document.getElementById('solInfo');
|
||||
if (info) info.textContent = done.length
|
||||
? ('gesetzt: ' + done.join(' ') + ' (⚠ = geringe Konfidenz)')
|
||||
: 'keine movements in der Datei gefunden';
|
||||
setStatus('Auf Lösung gesprungen');
|
||||
}
|
||||
|
||||
document.getElementById('fSolution').addEventListener('change', async e => {
|
||||
if (!e.target.files[0]) return;
|
||||
solutionData = await readJSON(e.target.files[0]);
|
||||
const btn = document.getElementById('btnJump');
|
||||
btn.disabled = false;
|
||||
btn.style.opacity = '1';
|
||||
setStatus('solution (robot_state.json) loaded');
|
||||
applySolution(); // direkt anwenden
|
||||
});
|
||||
|
||||
document.getElementById('btnJump').addEventListener('click', applySolution);
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// Test-pose dropdown
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user