CSV anzeigen
This commit is contained in:
@@ -105,7 +105,7 @@
|
||||
table.dtbl tr:hover td { background: #1a1f2b; }
|
||||
.row-1cam td:first-child::before { content: ''; }
|
||||
.cell-hi { color: #fbbf24; } /* amber: trianguliert */
|
||||
.cell-lo { color: #fde68a; } /* hell: nur 2D */
|
||||
.cell-lo { color: #dde3ec; } /* hell: nur 2D */
|
||||
.cell-unk { color: #3b82f6; } /* blau: fremd */
|
||||
.cell-mut { color: var(--muted); }
|
||||
</style>
|
||||
@@ -124,7 +124,7 @@
|
||||
<div class="legend">
|
||||
<span><span class="dot" style="background:#22c55e"></span>Erkannt</span>
|
||||
<span><span class="dot" style="background:#ef4444"></span>Nicht erkannt</span>
|
||||
<span><span class="dot circle" style="background:#fde68a"></span>Erkannt (nur 2D)</span>
|
||||
<span><span class="dot circle" style="background:#dde3ec"></span>Erkannt (nur 2D)</span>
|
||||
<span><span class="dot circle" style="background:#fbbf24"></span>Gemessen (3b)</span>
|
||||
<span><span class="dot circle" style="background:#3b82f6"></span>Fremd (3b)</span>
|
||||
<span><span class="dot" style="background:#9b7bff"></span>Kamera</span>
|
||||
@@ -361,7 +361,7 @@ function buildScene(data) {
|
||||
if (detectedIds.has(m.id) && !Object.hasOwn(measuredById, m.id)) {
|
||||
nDetectedNotTriangulated++;
|
||||
const pos = r2vArr(m.position);
|
||||
gMeasured.add(makeSphere(pos, 0.0055, 0xfde68a));
|
||||
gMeasured.add(makeSphere(pos, 0.0055, 0xdde3ec));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
@@ -38,4 +38,11 @@
|
||||
></iframe>
|
||||
</div>
|
||||
|
||||
<div class="section full">
|
||||
<h2>Marker-Positionen (letzter Run)</h2>
|
||||
<div id="board-marker-table-wrap" style="overflow-x:auto;margin-top:10px;">
|
||||
<p style="font-size:12px;color:var(--muted);padding:4px 0">(Erscheint nach einem Board-Run mit ≥2 Kameras)</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -77,6 +77,7 @@ def load_marker_info(robot_path: str) -> Dict[int, dict]:
|
||||
if mid >= 0:
|
||||
out[mid] = {
|
||||
"link": link_name,
|
||||
"set": mk.get("set", ""), # z.B. "A0"
|
||||
"position_mm": mk.get("position"), # [x_mm, y_mm, z_mm] robot coords
|
||||
}
|
||||
return out
|
||||
@@ -158,6 +159,7 @@ def main() -> None:
|
||||
markers_out.append({
|
||||
"marker_id": int(mid),
|
||||
"link": marker_info.get(mid, {}).get("link", "unknown"),
|
||||
"set": marker_info.get(mid, {}).get("set", ""),
|
||||
"position_m": [float(v) for v in center],
|
||||
"position_mm": [float(v * 1000.0) for v in center],
|
||||
"normal": [float(v) for v in normal],
|
||||
@@ -195,7 +197,7 @@ def main() -> None:
|
||||
with open(csv_path, "w", newline="", encoding="utf-8") as fcsv:
|
||||
w = csv.writer(fcsv)
|
||||
# Marker-Tabelle
|
||||
w.writerow(["marker_id", "link", "num_cameras",
|
||||
w.writerow(["marker_id", "link", "set", "num_cameras",
|
||||
"x_mm", "y_mm", "z_mm",
|
||||
"nx", "ny", "nz",
|
||||
"model_x_mm", "model_y_mm", "model_z_mm",
|
||||
@@ -219,7 +221,7 @@ def main() -> None:
|
||||
row_model = ["", "", "", "", ""]
|
||||
|
||||
w.writerow([
|
||||
mid, link, m["num_cameras"],
|
||||
mid, link, m.get("set", ""), m["num_cameras"],
|
||||
round(px, 2), round(py, 2), round(pz, 2),
|
||||
round(mnx, 5), round(mny, 5), round(mnz, 5),
|
||||
*row_model,
|
||||
|
||||
Reference in New Issue
Block a user