board rotation
This commit is contained in:
@@ -260,13 +260,14 @@ function buildScene(data) {
|
||||
if (boardMarkers.length > 0) {
|
||||
let minRx = Infinity, maxRx = -Infinity;
|
||||
let minRy = Infinity, maxRy = -Infinity;
|
||||
let markerRz = -27.3;
|
||||
let markerRz = Infinity; // Minimum aller z – tiefster Marker (z=up → kleinstes = am tiefsten)
|
||||
for (const m of boardMarkers) {
|
||||
const [rx, ry, rz] = m.position;
|
||||
if (rx < minRx) minRx = rx; if (rx > maxRx) maxRx = rx;
|
||||
if (ry < minRy) minRy = ry; if (ry > maxRy) maxRy = ry;
|
||||
markerRz = rz;
|
||||
if (rz < markerRz) markerRz = rz;
|
||||
}
|
||||
if (!isFinite(markerRz)) markerRz = -27.3;
|
||||
const pad = 40; // mm Rand
|
||||
const planeW = (maxRx - minRx + 2 * pad) * S;
|
||||
const planeH = (maxRy - minRy + 2 * pad) * S;
|
||||
@@ -290,13 +291,20 @@ function buildScene(data) {
|
||||
const pos = r2vArr(m.position);
|
||||
const detected = detectedIds.has(m.id);
|
||||
if (detected) nDetected++;
|
||||
const color = detected ? 0x22c55e : 0xef4444;
|
||||
const isA0 = m.set === 'A0';
|
||||
// A0: grün (erkannt) / rot (nicht erkannt) andere Sets: blau / dunkelblau
|
||||
const color = isA0
|
||||
? (detected ? 0x22c55e : 0xef4444)
|
||||
: (detected ? 0x3b82f6 : 0x1e40af);
|
||||
|
||||
const sq = makeMarkerSquare(pos, visSize, color);
|
||||
sq.position.y += 0.0005;
|
||||
gMarkers.add(sq);
|
||||
|
||||
const border = makeEdgeBorder(pos, visSize, detected ? 0x4ade80 : 0xfca5a5);
|
||||
const borderCol = isA0
|
||||
? (detected ? 0x4ade80 : 0xfca5a5)
|
||||
: (detected ? 0x60a5fa : 0x3b82f6);
|
||||
const border = makeEdgeBorder(pos, visSize, borderCol);
|
||||
border.position.y += 0.001;
|
||||
gMarkers.add(border);
|
||||
}
|
||||
|
||||
@@ -481,4 +481,75 @@ function initBoard() {
|
||||
result.innerHTML = `<span style="color:#f87171">❌ ${err}</span>`;
|
||||
}
|
||||
});
|
||||
|
||||
// ── Aktion 3: Sets justieren (Kabsch 2D+Z) ─────────────────────────────────
|
||||
document.getElementById('btn-act-align').addEventListener('click', async () => {
|
||||
const setToMove = document.getElementById('act-align-set').value.trim();
|
||||
const result = document.getElementById('act-result');
|
||||
|
||||
if (!setToMove) {
|
||||
result.innerHTML = '<span style="color:#f87171">⚠ Bitte Set-Name eingeben (z.B. "rail").</span>'; return;
|
||||
}
|
||||
|
||||
result.innerHTML = '<span style="color:#555b6e">Justierung läuft …</span>';
|
||||
try {
|
||||
const r = await fetch('/api/robot/align-sets', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ setToMove }),
|
||||
});
|
||||
const data = await r.json();
|
||||
if (!r.ok || data.error) {
|
||||
result.innerHTML = `<span style="color:#f87171">❌ ${data.error ?? `HTTP ${r.status}`}</span>`; return;
|
||||
}
|
||||
const t = data.transform;
|
||||
result.innerHTML =
|
||||
`<span style="color:#22c55e">✅ Set "${setToMove}": ${data.numChanged} Marker verschoben` +
|
||||
` (${data.numMatchingPts} Messpunkte)</span>` +
|
||||
`  Δx=${t.tx} mm Δy=${t.ty} mm Δz=${t.tz} mm` +
|
||||
` θ=${t.thetaDeg}°`;
|
||||
loadBoardTable();
|
||||
} catch (err) {
|
||||
result.innerHTML = `<span style="color:#f87171">❌ ${err}</span>`;
|
||||
}
|
||||
});
|
||||
|
||||
// ── Aktion 4: Zuordnung hinzufügen ─────────────────────────────────────────
|
||||
document.getElementById('btn-act-add').addEventListener('click', async () => {
|
||||
const markerId = document.getElementById('act-add-id').value.trim();
|
||||
const set = document.getElementById('act-add-set').value.trim();
|
||||
const link = document.getElementById('act-add-link').value.trim();
|
||||
const result = document.getElementById('act-result');
|
||||
|
||||
if (!markerId) {
|
||||
result.innerHTML = '<span style="color:#f87171">⚠ Bitte Marker-ID eingeben.</span>'; return;
|
||||
}
|
||||
if (!set && !link) {
|
||||
result.innerHTML = '<span style="color:#f87171">⚠ Bitte mindestens Set oder Link angeben.</span>'; return;
|
||||
}
|
||||
|
||||
result.innerHTML = '<span style="color:#555b6e">Hinzufügen …</span>';
|
||||
try {
|
||||
const r = await fetch('/api/robot/assign-id', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ markerId: parseInt(markerId, 10), set, link }),
|
||||
});
|
||||
const data = await r.json();
|
||||
if (!r.ok) {
|
||||
result.innerHTML = `<span style="color:#f87171">❌ ${data.error ?? `HTTP ${r.status}`}</span>`; return;
|
||||
}
|
||||
if (!data.changed) {
|
||||
result.innerHTML = `<span style="color:#f87171">❌ ${data.error}</span>`; return;
|
||||
}
|
||||
const c = data.change;
|
||||
const info = c.action === 'added'
|
||||
? `neu in Link "${c.newLink}"${c.newSet ? ` Set "${c.newSet}"` : ''}`
|
||||
: `aktualisiert → Link "${c.newLink}"${c.newSet ? ` Set "${c.newSet}"` : ''}`;
|
||||
result.innerHTML = `<span style="color:#22c55e">✅ Marker ${markerId}: ${info}</span>`;
|
||||
loadBoardTable();
|
||||
} catch (err) {
|
||||
result.innerHTML = `<span style="color:#f87171">❌ ${err}</span>`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,6 +72,45 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Aktion 3: Sets justieren (Kabsch 2D+Z) -->
|
||||
<div style="margin-top:14px">
|
||||
<p style="font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:8px">
|
||||
Sets justieren (zu 3b-Messung)
|
||||
</p>
|
||||
<div style="display:flex;flex-wrap:wrap;align-items:center;gap:8px;font-size:12px;color:var(--text)">
|
||||
Set verschieben
|
||||
<input id="act-align-set" type="text" placeholder="rail"
|
||||
style="width:90px;background:#1e293b;border:1px solid #334155;color:#c8cdd8;border-radius:3px;padding:3px 7px;font:inherit;font-size:12px">
|
||||
<button id="btn-act-align"
|
||||
style="background:#1e293b;color:#c8cdd8;border:1px solid #4a9eff;border-radius:3px;padding:4px 14px;cursor:pointer;font:inherit;font-size:12px">
|
||||
Justieren
|
||||
</button>
|
||||
<span style="color:var(--muted);font-size:10px">Rotation (Z-Achse) + Translation → passt Set zu 3b-Messung</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Aktion 4: Zuordnung hinzufügen -->
|
||||
<div style="margin-top:14px">
|
||||
<p style="font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:8px">
|
||||
Zuordnung hinzufügen
|
||||
</p>
|
||||
<div style="display:flex;flex-wrap:wrap;align-items:center;gap:8px;font-size:12px;color:var(--text)">
|
||||
ID
|
||||
<input id="act-add-id" type="number" placeholder="z.B. 210"
|
||||
style="width:90px;background:#1e293b;border:1px solid #334155;color:#c8cdd8;border-radius:3px;padding:3px 7px;font:inherit;font-size:12px">
|
||||
Set
|
||||
<input id="act-add-set" type="text" placeholder="A0"
|
||||
style="width:72px;background:#1e293b;border:1px solid #334155;color:#c8cdd8;border-radius:3px;padding:3px 7px;font:inherit;font-size:12px">
|
||||
Link
|
||||
<input id="act-add-link" type="text" placeholder="Board"
|
||||
style="width:90px;background:#1e293b;border:1px solid #334155;color:#c8cdd8;border-radius:3px;padding:3px 7px;font:inherit;font-size:12px">
|
||||
<button id="btn-act-add"
|
||||
style="background:#1e293b;color:#c8cdd8;border:1px solid #22c55e;border-radius:3px;padding:4px 14px;cursor:pointer;font:inherit;font-size:12px">
|
||||
Hinzufügen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ergebnis-Zeile -->
|
||||
<div id="act-result" style="margin-top:10px;font-size:11px;min-height:18px;color:var(--muted)"></div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user