G28 Singularität und Planungen
This commit is contained in:
@@ -90,17 +90,21 @@ describe('GCode.receiveGCode', () => {
|
||||
expect(robot.sendCommand).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('G28 setzt Home-Position und löst Bewegung aus', () => {
|
||||
test('G28 setzt Home-Motorwerte direkt (Singularität) und löst Bewegung aus', () => {
|
||||
const robot = createDummyRobot()
|
||||
|
||||
GCode.receiveGCode(robot, 'G28')
|
||||
|
||||
expect(robot.x).toBe(0)
|
||||
expect(robot.z).toBe(0)
|
||||
expect(robot.y).toBe(-(robot.l1 + robot.l2 + robot.l3)) // -y Grundstellung
|
||||
expect(robot.phi).toBeCloseTo(Math.PI / 2)
|
||||
expect(robot.theta).toBeCloseTo(Math.PI / 2)
|
||||
expect(robot.calculateAngles3D).toHaveBeenCalledTimes(1)
|
||||
// Voll ausgestreckt = Handgelenk-Singularität -> Motorwerte DIREKT, dann FK (nicht IK).
|
||||
expect(robot.xMotor).toBe(0)
|
||||
expect(robot.alpha).toBe(0)
|
||||
expect(robot.beta).toBe(0)
|
||||
expect(robot.a).toBe(0)
|
||||
expect(robot.b).toBe(Math.PI) // gerade Hand (Phase-1-Konvention)
|
||||
expect(robot.c).toBe(0)
|
||||
expect(robot.e).toBe(0)
|
||||
expect(robot.calculateAngles3D).not.toHaveBeenCalled()
|
||||
expect(robot.calculatePositionFromMotorAngles).toHaveBeenCalledTimes(1)
|
||||
expect(robot.sendCommand).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user