// __tests__/Robot.inverseKinematics.test.js const Robot = require('../robot/Robot.js'); const GCode = require('../robot/GCode.js'); describe("Robot G92", () => { test("ReadPosition -> calculatePositionFromMotorAngles()", () => { // === Instanz A: Vorwärts-Kinematik (XYZ -> Motorwinkel) === const L1 = 300; const L2 = 200; const L3 = 10; const A = new Robot(L1, L2, L3) // Beispiel-Eingabe A.x = 0; A.y = 310; A.z = 0; A.phi = -Math.PI/2; A.theta = Math.PI/2; A.psi = 0; A.e = 0; A.calculateAngles3D(); var strGCode = `G92 X${A.xMotor} Y${A.alpha} Z${A.beta} A${A.a} B${A.b} C${A.c}` const T = new Robot(L1, L2, L3) console.log("GCode: " + strGCode); GCode.receiveGCode(T, strGCode); const EPS = 0.01; // 1/1000 mm Genauigkeit expect(T.xMotor).toBeCloseTo(A.xMotor, EPS); expect(T.alpha).toBeCloseTo(A.alpha, EPS); expect(T.beta).toBeCloseTo(A.beta, EPS); expect(T.x).toBeCloseTo(A.x, EPS); expect(T.y).toBeCloseTo(A.y, EPS); expect(T.z).toBeCloseTo(A.z, EPS); }); });