x-axis justierung: lines 3

This commit is contained in:
chk
2026-06-10 20:41:42 +02:00
parent fa91a36da9
commit 74a3cfada2
5 changed files with 257 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ import { fileURLToPath } from 'url';
import process from 'process';
import { spawn } from 'child_process';
import { WebcamClient } from './webcamClient.js';
import { assignByZRange, removeMarkerAssignment, alignSetToMeasured, assignMarkerId } from './editRobot.js';
import { assignByZRange, removeMarkerAssignment, alignSetToMeasured, assignMarkerId, adoptXAxis } from './editRobot.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@@ -864,6 +864,31 @@ app.post('/api/robot/assign-id', async (req, res) => {
}
});
/**
* POST /api/robot/adopt-x-axis
* Dreht alle Marker-Positionen in robot.json so, dass die gemessene Richtung
* zur neuen X-Achse [1,0,0] wird. Rotation um den A0-Schwerpunkt.
* Body: { direction: [vx, vy, vz] }
*/
app.post('/api/robot/adopt-x-axis', async (req, res) => {
try {
const { direction } = req.body ?? {};
if (!Array.isArray(direction) || direction.length < 3) {
return res.status(400).json({ error: '"direction" muss ein Array [vx,vy,vz] sein.' });
}
const result = await adoptXAxis(ROBOT_JSON, { direction });
console.log(
`robot/adopt-x-axis dir=[${direction.map(v => Number(v).toFixed(4)).join(', ')}]` +
`${result.numChanged} Marker, Ursprung=[${result.origin.join(', ')}]` +
` XY=${result.angleXYdeg}° XZ=${result.angleXZdeg}°`,
);
return res.json(result);
} catch (err) {
console.error('robot/adopt-x-axis error:', err);
return res.status(500).json({ error: String(err) });
}
});
/**
* POST /api/calibration/upload-npz
* Liest {camera}_calibration.npz aus der aktuellen Session und