import test from 'node:test' import assert from 'node:assert/strict' import { createRobot } from '../src/facade/robot' test('robot generates a bounded linear trajectory, kinematics and controller export', () => { const robot = createRobot(); robot.addJoint({ id: 'J1', label: 'Base', minimum: -180, maximum: 180, linkLength: 2 }); robot.addJoint({ id: 'J2', label: 'Arm', minimum: -90, maximum: 90, linkLength: 1 }); robot.addWaypoint({ id: 'home', values: [0, 0] }); robot.addWaypoint({ id: 'pick', values: [90, 45] }); const snapshot = robot.generateLinearTrajectory(4); assert.equal(snapshot.status, 'generated'); assert.equal(snapshot.trajectory.length, 5); assert.equal(robot.validateTrajectory().valid, true); assert.deepEqual(robot.forwardKinematics([0, 0]), { position: [3, 0, 0], maxReach: 3 }); assert.deepEqual(robot.workspace(), { maxReach: 3, jointCount: 2 }); assert.ok(robot.collisions([{ id: 'home-obstacle', min: [2.9, -0.1, -0.1], max: [3.1, 0.1, 0.1] }]).length > 0); assert.match(robot.exportController(), /"trajectory"/); assert.equal(robot.exportCsv().trim().split('\n').length, 6) }) test('robot rejects waypoints outside joint limits', () => { const robot = createRobot(); robot.addJoint({ id: 'J1', label: 'Base', minimum: -1, maximum: 1 }); assert.throws(() => robot.addWaypoint({ id: 'bad', values: [2] }), /joint limit/) })