CSV anzeigen
This commit is contained in:
@@ -222,6 +222,136 @@ function initCameraNpz() {
|
||||
});
|
||||
}
|
||||
|
||||
// ── Board: Marker-Tabelle ─────────────────────────────────────────────────────
|
||||
|
||||
async function loadBoardTable() {
|
||||
const wrap = document.getElementById('board-marker-table-wrap');
|
||||
if (!wrap) return;
|
||||
|
||||
const th = (a) => `style="text-align:${a};padding:3px 8px;border-bottom:1px solid #2a2d35;white-space:nowrap;background:#1e293b;color:#555b6e;font-weight:normal"`;
|
||||
const td = (a, x = '') => `style="padding:2px 8px;border-bottom:1px solid #111418;text-align:${a};white-space:nowrap;${x}"`;
|
||||
|
||||
try {
|
||||
const r = await fetch('/api/board/latest');
|
||||
if (!r.ok) throw new Error(`HTTP ${r.status}`);
|
||||
const data = await r.json();
|
||||
|
||||
if (!data.runDir) {
|
||||
wrap.innerHTML = '<p style="font-size:11px;color:#555b6e;padding:4px 0">Noch kein Board-Run vorhanden.</p>';
|
||||
return;
|
||||
}
|
||||
const meas = data.measuredMarkers;
|
||||
if (!meas?.markers?.length) {
|
||||
wrap.innerHTML = `<p style="font-size:11px;color:#555b6e;padding:4px 0">Run: ${data.runDir} – kein 3b-Output (≥2 Kameras erforderlich).</p>`;
|
||||
return;
|
||||
}
|
||||
|
||||
// Modell-Info aus robot.json
|
||||
const boardMarkers = data.robot?.links?.Board?.markers ?? [];
|
||||
const modelMap = {};
|
||||
for (const m of boardMarkers) modelMap[m.id] = m;
|
||||
|
||||
const f1 = v => (v == null ? '–' : Number(v).toFixed(1));
|
||||
const f2 = v => (v == null ? '–' : Number(v).toFixed(2));
|
||||
const f4 = v => (v == null ? '–' : Number(v).toFixed(4));
|
||||
|
||||
const markers = [...meas.markers].sort((a, b) => {
|
||||
if (a.link !== b.link) return a.link === 'Board' ? -1 : 1;
|
||||
return a.marker_id - b.marker_id;
|
||||
});
|
||||
|
||||
let html = `<p style="font-size:10px;color:#555b6e;margin-bottom:4px">
|
||||
Run: ${data.runDir} · ${markers.length} Marker trianguliert
|
||||
</p>
|
||||
<table style="border-collapse:collapse;font-size:11px;font-family:inherit;width:100%">
|
||||
<thead><tr>
|
||||
<th ${th('left')}>ID</th>
|
||||
<th ${th('left')}>Set</th>
|
||||
<th ${th('left')}>Link</th>
|
||||
<th ${th('right')}>Kam.</th>
|
||||
<th ${th('right')}>x mm</th>
|
||||
<th ${th('right')}>y mm</th>
|
||||
<th ${th('right')}>z mm</th>
|
||||
<th ${th('right')}>nx</th>
|
||||
<th ${th('right')}>ny</th>
|
||||
<th ${th('right')}>nz</th>
|
||||
<th ${th('right')}>dist mm</th>
|
||||
<th ${th('right')}>Δz mm</th>
|
||||
<th ${th('right')}>Kante mm</th>
|
||||
</tr></thead>
|
||||
<tbody>`;
|
||||
|
||||
for (const m of markers) {
|
||||
const model = modelMap[m.marker_id];
|
||||
const set = m.set ?? model?.set ?? '–';
|
||||
const [px, py, pz] = m.position_mm;
|
||||
const [mnx, mny, mnz] = m.normal;
|
||||
|
||||
let dist = '–', dz = '–';
|
||||
if (model && m.link === 'Board') {
|
||||
const [mx, my, mz] = model.position;
|
||||
const ddx = px - mx, ddy = py - my, ddz = pz - mz;
|
||||
dist = Math.sqrt(ddx * ddx + ddy * ddy + ddz * ddz).toFixed(2);
|
||||
dz = ddz.toFixed(2);
|
||||
}
|
||||
|
||||
const col = m.link === 'Board' ? '' : 'color:#3b82f6;';
|
||||
html += `<tr>
|
||||
<td ${td('left', col)}>${m.marker_id}</td>
|
||||
<td ${td('left', col)}>${set}</td>
|
||||
<td ${td('left', col)}>${m.link}</td>
|
||||
<td ${td('right', col)}>${m.num_cameras}</td>
|
||||
<td ${td('right', col)}>${f1(px)}</td>
|
||||
<td ${td('right', col)}>${f1(py)}</td>
|
||||
<td ${td('right', col)}>${f1(pz)}</td>
|
||||
<td ${td('right', col)}>${f4(mnx)}</td>
|
||||
<td ${td('right', col)}>${f4(mny)}</td>
|
||||
<td ${td('right', col)}>${f4(mnz)}</td>
|
||||
<td ${td('right', col)}>${dist}</td>
|
||||
<td ${td('right', col)}>${dz}</td>
|
||||
<td ${td('right', col)}>${f1(m.edge_length_mm)}</td>
|
||||
</tr>`;
|
||||
}
|
||||
html += `</tbody></table>`;
|
||||
|
||||
// Kamera-Tabelle
|
||||
const cams = meas.cameras ?? [];
|
||||
if (cams.length > 0) {
|
||||
html += `<p style="font-size:10px;color:#555b6e;margin-top:12px;margin-bottom:4px">KAMERAS</p>
|
||||
<table style="border-collapse:collapse;font-size:11px;font-family:inherit;width:auto">
|
||||
<thead><tr>
|
||||
<th ${th('left')}>ID</th>
|
||||
<th ${th('right')}>x mm</th>
|
||||
<th ${th('right')}>y mm</th>
|
||||
<th ${th('right')}>z mm</th>
|
||||
<th ${th('right')}>dir_x</th>
|
||||
<th ${th('right')}>dir_y</th>
|
||||
<th ${th('right')}>dir_z</th>
|
||||
</tr></thead>
|
||||
<tbody>`;
|
||||
for (const c of cams) {
|
||||
const [cx, cy, cz] = c.position_mm ?? [null, null, null];
|
||||
const [dx, dy, dz] = c.direction ?? [null, null, null];
|
||||
html += `<tr>
|
||||
<td ${td('left', 'color:#4a9eff;')}>${c.camera_id}</td>
|
||||
<td ${td('right')}>${f1(cx)}</td>
|
||||
<td ${td('right')}>${f1(cy)}</td>
|
||||
<td ${td('right')}>${f1(cz)}</td>
|
||||
<td ${td('right')}>${f4(dx)}</td>
|
||||
<td ${td('right')}>${f4(dy)}</td>
|
||||
<td ${td('right')}>${f4(dz)}</td>
|
||||
</tr>`;
|
||||
}
|
||||
html += `</tbody></table>`;
|
||||
}
|
||||
|
||||
wrap.innerHTML = html;
|
||||
|
||||
} catch (err) {
|
||||
if (wrap) wrap.innerHTML = `<p style="color:#f87171;font-size:11px">Fehler: ${err}</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Board ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
function initBoard() {
|
||||
@@ -233,6 +363,9 @@ function initBoard() {
|
||||
logBoard.scrollTop = logBoard.scrollHeight;
|
||||
}
|
||||
|
||||
// Tabelle beim ersten Öffnen des Tabs befüllen
|
||||
loadBoardTable();
|
||||
|
||||
document.getElementById('btn-board-run').addEventListener('click', async () => {
|
||||
logB('Board-Erkennung wird gestartet …');
|
||||
const btn = document.getElementById('btn-board-run');
|
||||
@@ -257,6 +390,8 @@ function initBoard() {
|
||||
if (frame?.contentWindow) {
|
||||
frame.contentWindow.postMessage({ type: 'reload' }, '*');
|
||||
}
|
||||
// Marker-Tabelle aktualisieren
|
||||
loadBoardTable();
|
||||
}
|
||||
} else {
|
||||
logB(`❌ Beendet mit Exit-Code ${evt.exitCode}`);
|
||||
|
||||
Reference in New Issue
Block a user