G28 Singularität und Planungen

This commit is contained in:
chk
2026-06-26 11:39:20 +02:00
parent bd1752f567
commit 7639266170
6 changed files with 232 additions and 34 deletions

View File

@@ -1,6 +1,7 @@
// Phase 1: Der reale Roboter arbeitet in -Y (robot.json: Arm1 -> [0,-250,0]).
// alpha=0 muss nach -y zeigen, nicht nach +y. Siehe doc/Info_Koordinaten.md.
const Robot = require('../robot/kinematics/Arm3SegmentLinearX');
const GCode = require('../robot/GCode');
const D = 180 / Math.PI;
describe('Phase 1 — Arm arbeitet in -Y (alpha=0 zeigt nach -y)', () => {
@@ -82,4 +83,25 @@ describe('Phase 1 — Arm arbeitet in -Y (alpha=0 zeigt nach -y)', () => {
const r90 = fkFromMotors(0, 0, 90, 135, 0, xM);
expect(Math.abs(r90.x - xM)).toBeGreaterThan(1);
});
test('G28 Home: saubere Grundstellung (a=0, c=0, Finger entlang -y) — keine Singularitaets-Garbage', () => {
const robot = new Robot(L1, L2, L3);
GCode.receiveGCode(robot, 'G28');
// Motorwerte sauber gesetzt (nicht der IK-Singularitaets-Muell a=135/c=45)
expect(robot.a).toBeCloseTo(0, 9);
expect(robot.c).toBeCloseTo(0, 9);
expect(robot.alpha).toBeCloseTo(0, 9);
expect(robot.beta).toBeCloseTo(0, 9);
// Workspace: voll ausgestreckt entlang -y
expect(robot.x).toBeCloseTo(0, 6);
expect(robot.y).toBeCloseTo(-(L1 + L2 + L3), 6);
expect(robot.z).toBeCloseTo(0, 6);
// Finger (Handgelenk -> Fingerspitze) zeigt nach -y
const hx = robot.x - robot.pX, hy = robot.y - robot.pY, hz = robot.z - robot.pZ;
const n = Math.hypot(hx, hy, hz);
expect(hy / n).toBeCloseTo(-1, 6);
});
});