spin Marker Callibration

This commit is contained in:
chk
2026-06-15 09:23:21 +02:00
parent 375ee4cf69
commit 15d4175fd1
18 changed files with 1191 additions and 239 deletions

View File

@@ -23,7 +23,7 @@ describe("calculate() row223 Ellbow-Rotation Tests", () => {
test('berechnet y-Durchschnitt für Base / Arm1 / Joint1', async () => {
const markersPath = path.resolve('./test/snapshots/snapshot_video0_1778407171886_two_cam.json');
const robotPath = path.resolve('./public/robot.json');
const robotPath = path.resolve('./test/fixtures/robot_legacy.json');
const foundMarkers = JSON.parse(fs.readFileSync(markersPath, 'utf8'));
const jsonRobot = JSON.parse(fs.readFileSync(robotPath, 'utf8'));
@@ -40,7 +40,7 @@ describe("calculate() row223 Ellbow-Rotation Tests", () => {
test('berechnet X-Durchschnitt für Base / Arm1 / Joint1', async () => {
const markersPath = path.resolve('./test/snapshots/snapshot_video0_1775406055428_two_cam.json');
const robotPath = path.resolve('./public/robot.json');
const robotPath = path.resolve('./test/fixtures/robot_legacy.json');
const foundMarkers = JSON.parse(fs.readFileSync(markersPath, 'utf8'));
const jsonRobot = JSON.parse(fs.readFileSync(robotPath, 'utf8'));

View File

@@ -8,7 +8,7 @@ const { calculate } = require('../public/calculateAngles');
describe('calculateAngles minimal test', () => {
it('should run calculate() with loaded JSON files', async () => {
// Pfade auflösen
const robotPath = path.resolve(__dirname, '../public/robot.json');
const robotPath = path.resolve(__dirname, '../test/fixtures/robot_legacy.json');
const snapshotPath = path.resolve(
__dirname,
'../test/snapshots/snapshot_video0_1778845508432_two_cam.json'

39
test/fixtures/robot_legacy.json vendored Normal file
View File

@@ -0,0 +1,39 @@
{
"recognized":{"x":null, "y":null, "z": null, "a":null, "b":null, "c":null, "e": null},
"Elements":["Board","Base","Arm1","Joint1","Arm2","Finger1","Finger2"],
"ElementLength":{"Arm1":250, "Arm2":250, "Finger1":100, "Finger2":100},
"Joints":{
"jointA":{"name":"Slider", "type":"lninear", "axis":[1,0,0],"parent":"Board","child":"Base"},
"jointB":{"name":"Shoulder","type":"revolute","axis":[1,0,0],"parent":"Base","child":"Arm1","origin":[-89.5, 115, 52], "originSource":[null, "229_198_Foto_5_2026", "Fuson"]},
"jointC":{"name":"EllbowLift","type":"revolute","axis":[1,0,0],"parent":"Arm1","child":"Joint1", "origin":[null, null, null]},
"jointD":{"name":"EllbowTwist","type":"revolute","axis":[0,1,0],"parent":"Joint1","child":"Arm2", "origin":[null, null, null]}
},
"MarkerType":"DICT_4X4_250",
"Marker":[
{"id":205,"on":"Board","position":[0.80, -0.090, 0.0]},
{"id":207,"on":"Board","position":[0.80, 0.0, 0.0]},
{"id":208,"on":"Board","position":[0.50, -0.090, 0.0]},
{"id":210,"on":"Board","position":[0.00, 0.0, 0.0]},
{"id":211,"on":"Board","position":[0.20, 0.0, 0.0]},
{"id":214,"on":"Board","position":[0.40, 0.0, 0.0]},
{"id":215,"on":"Board","position":[0.20, -0.090, 0.0]},
{"id":217,"on":"Board","position":[0.60, -0.090, 0.0]},
{"id":200,"on":"Base","relPos":[-163.8, 6.5, 55], "relPosSource":["226_FotoAverage_5_2026",null,null]},
{"id":201,"on":"Base","relPos":[-164.8, 97.5, 74.5], "relPosSource":["226_FotoAverage_5_2026",null,null]},
{"id":204,"on":"Base","relPos":[-158.5,152.5,111]},
{"id":198,"on":"Arm1","relPos":[-89.5,-160, 35],"relPosSource":["Fusion",null,null]},
{"id":229,"on":"Arm1","relPos":[-89.5,-250, 35],"relPosSource":["Fusion",null,null]},
{"id":242,"on":"Arm1","relPos":[-89.5,-250,-35]},
{"id":243,"on":"Arm1","relPos":[-89.5,-285, 0]},
{"id":222,"on":"Joint1", "relPos":[0,0, -35]},
{"id":226,"on":"Joint1", "relPos":[0,0, 35]},
{"id":228,"on":"Arm2", "relPos":[-24.75, 112, 24.75], "relPosSource":["Fusion","Fusion","Fusion"]},
{"id":223,"on":"Arm2", "relPos":[-28.67,112,-20.08], "relPosSource":["Fusion","Fusion","Fusion"]},
{"id":218,"on":"Arm2", "relPos":[35,112,0], "relPosSource":["Fusion","Fusion","Fusion"]},
{"id":219,"on":"Arm2", "relPos":[35,219,0], "relPosSource":["Fusion","Fusion","Fusion"]}
]
}

View File

@@ -27,7 +27,7 @@ describe("calculate() row223 Ellbow-Rotation Tests", () => {
const markersPath2 = path.resolve('./test/snapshots/snapshot_video0_1778406621349_two_cam.json');
const markersPath3 = path.resolve('./test/snapshots/snapshot_video0_1778407153025_two_cam.json');
const markersPath4 = path.resolve('./test/snapshots/snapshot_video0_1778407171886_two_cam.json');
const robotPath = path.resolve('./public/robot.json');
const robotPath = path.resolve('./test/fixtures/robot_legacy.json');
const foundMarkers1 = JSON.parse(fs.readFileSync(markersPath1, 'utf8'));
const foundMarkers2 = JSON.parse(fs.readFileSync(markersPath2, 'utf8'));

View File

@@ -0,0 +1,46 @@
/**
* spinNormalize.test.js
* Unit-Tests für server/spinNormalize.cjs
*
* Sichert ab, dass der Spin-Normalisierer alle Randfälle korrekt behandelt,
* insbesondere negative Werte (z.B. 0 90 = 90 → 270).
*/
const { normalizeSpinDeg } = require('../server/spinNormalize.cjs');
describe('normalizeSpinDeg', () => {
test('Standardwerte 0 / 90 / 180 / 270 bleiben unverändert', () => {
expect(normalizeSpinDeg(0)).toBe(0);
expect(normalizeSpinDeg(90)).toBe(90);
expect(normalizeSpinDeg(180)).toBe(180);
expect(normalizeSpinDeg(270)).toBe(270);
});
test('Wert 360 wird auf 0 normalisiert', () => {
expect(normalizeSpinDeg(360)).toBe(0);
expect(normalizeSpinDeg(720)).toBe(0);
expect(normalizeSpinDeg(450)).toBe(90);
});
test('Negative Werte werden korrekt umgerechnet', () => {
expect(normalizeSpinDeg(-90)).toBe(270); // 0 90 → 270
expect(normalizeSpinDeg(-180)).toBe(180);
expect(normalizeSpinDeg(-270)).toBe(90);
expect(normalizeSpinDeg(-360)).toBe(0);
expect(normalizeSpinDeg(-1)).toBe(359);
});
test('Strings werden als Zahlen interpretiert', () => {
expect(normalizeSpinDeg('90')).toBe(90);
expect(normalizeSpinDeg('-90')).toBe(270);
});
test('Ergebnis liegt immer in [0, 360)', () => {
const inputs = [-720, -359, -1, 0, 1, 89, 90, 179, 270, 359, 360, 450, 720, 1080];
for (const v of inputs) {
const r = normalizeSpinDeg(v);
expect(r).toBeGreaterThanOrEqual(0);
expect(r).toBeLessThan(360);
}
});
});