Koordinaten + offset

bei den Achsen-Koordinaten hat ein Offset gefehlt.

Zudem braucht es systematische Tests
This commit is contained in:
chk
2026-05-21 21:31:14 +02:00
parent 60c38570ef
commit 56c45f6b2f
3 changed files with 133 additions and 12 deletions

View File

@@ -0,0 +1,55 @@
const { calculate } = require('../public/calculateAngles');
function foundMarkers(y, robot, a=0, translate=[0,0,0]){
const alphaPi = y * Math.PI / 180;
const pos20 = [0,Math.sin(alphaPi)*10,Math.cos(alphaPi)*10]
m = {"markers": [
{"id": 20, "position_mm": pos20 }
]}
return m
}
robot = {
"Elements":["Base", "Arm1"],
"ElementLength":{"Arm1":250, "Joint1": 89.5, "Arm2":250, "Finger1":100, "Finger2":100},
"Joints":{
"jointB":{"name":"Shoulder","type":"revolute","axis":[1,0,0],"parent":"Base","child":"Arm1","origin":[-89.5,0,0], "originSource":[null, "test", "test"]},
"jointC":{"name":"Ellbow","type":"revolute","axis":[1,0,0],"parent":"Arm1","child":"Joint1", "origin":[-89.5, -250, 0]},
"jointD":{"name":"EllbowTwist","type":"revolute","axis":[0,1,0],"parent":"Joint1","child":"Arm2", "origin":[0, -250, 0]}
},
"Marker":[
{"id":20, "on":"Arm1", "relPos":[0,0,10]},
{"id":40, "on":"Arm2", "relPos":[0,200,35]},
{"id":41, "on":"Arm2", "relPos":[0,160,35]}
],
"recognized":{"x":null, "y":null, "z":null}
}
function normalizeAngleDeg(angle) {
return ((angle % 360) + 360) % 360;
}
describe('calculateAngles minimal test', () => {
it('should run calculate() artificially created robot & testData', async () => {
var result = calculate(foundMarkers(45, robot), robot);
expect(result).toBeDefined();
expect(robot.recognized.y).toBeDefined();
expect(robot.recognized.y).toBeCloseTo(45,2);
})
});

View File

@@ -0,0 +1,56 @@
const { calculate } = require('../public/calculateAngles');
function foundMarkers(alpha, robot){
const alphaPi = alpha * Math.PI / 180;
m = {"markers": [{"id": 0, "position_mm":[0,Math.sin(alphaPi)*10,Math.cos(alphaPi)*10]}]}
return m
}
robot = {
"Elements":["Base", "Arm1"],
"ElementLength":{"Arm1":250, "Arm2":250, "Finger1":100, "Finger2":100},
"Joints":{
"jointB":{"name":"Shoulder","type":"revolute","axis":[1,0,0],"parent":"Base","child":"Arm1","origin":[0,0,0], "originSource":[null, "test", "test"]},
},
"Marker":[
{"id":0, "on":"Arm1", "relPos":[0,0,10]}
],
"recognized":{"x":null, "y":null, "z":null}
}
function normalizeAngleDeg(angle) {
return ((angle % 360) + 360) % 360;
}
describe('calculateAngles minimal test', () => {
it('should run calculate() artificially created robot & testData', async () => {
for (let alpha = -180; alpha <= 181; alpha += 15) {
var result = calculate(foundMarkers(alpha, robot), robot);
expect(result).toBeDefined();
expect(robot.recognized.y).toBeDefined();
expect(robot.recognized.y).toBeCloseTo(alpha,2);
}
})
it('should run calculate() artificially created robot & testData 2', async () => {
for (let alpha = -30; alpha <= 761; alpha += 15) {
var result = calculate(foundMarkers(alpha, robot), robot);
expect(result).toBeDefined();
expect(robot.recognized.y).toBeDefined();
expect(normalizeAngleDeg(robot.recognized.y)).toBeCloseTo(normalizeAngleDeg(alpha),2);
}
})
});