nur wenn xyz genaendert, dann senden

This commit is contained in:
ChK
2026-04-07 09:30:46 +02:00
parent 3d33ecd747
commit a47c168a22
11 changed files with 250 additions and 159 deletions

View File

@@ -17,16 +17,9 @@ class GCode{
m = m.split(" ");
if(m[0] == "M1"){
m.forEach((s) => {
if(s.includes("X")){ robot.xMotor += Number(s.substring(1, s.length));}
if(s.includes("x")){ robot.xMotor += Number(s.substring(1, s.length));}
if(s.includes("Y")){ robot.alpha += Number(s.substring(1, s.length));}
if(s.includes("y")){ robot.alpha += Number(s.substring(1, s.length));}
if(s.includes("Z")){ robot.beta += Number(s.substring(1, s.length));}
if(s.includes("z")){ robot.beta += Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("X")){ robot.xMotor += Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("Y")){ robot.alpha += Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("Z")){ robot.beta += Number(s.substring(1, s.length));}
})
}
@@ -118,109 +111,68 @@ class GCode{
}
else if(g[0] == "G1" && robot.moveRelative){
g.forEach((s) => {
if(s.includes("X")){ robot.x += Number(s.substring(1, s.length));}
if(s.includes("x")){ robot.x += Number(s.substring(1, s.length));}
if(s.includes("Y")){ robot.y += Number(s.substring(1, s.length));}
if(s.includes("y")){ robot.y += Number(s.substring(1, s.length));}
if(s.includes("Z")){ robot.z += Number(s.substring(1, s.length));}
if(s.includes("z")){ robot.z += Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("X")){ robot.x += Number(s.substring(1, s.length)); robot.xMotorChanged = true;}
if(s.toUpperCase().includes("Y")){ robot.y += Number(s.substring(1, s.length)); robot.yMotorChanged = true;}
if(s.toUpperCase().includes("Z")){ robot.z += Number(s.substring(1, s.length)); robot.zMotorChanged = true;}
// abc in 2Pi-Angles
if(s.includes("A")){ robot.phi += Number(s.substring(1, s.length));}
if(s.includes("a")){ robot.phi += Number(s.substring(1, s.length));}
if(s.includes("B")){ robot.theta += Number(s.substring(1, s.length));}
if(s.includes("b")){ robot.theta += Number(s.substring(1, s.length));}
if(s.includes("C")){ robot.psi += Number(s.substring(1, s.length));}
if(s.includes("c")){ robot.psi += Number(s.substring(1, s.length));}
if(s.includes("E")){ robot.e += Number(s.substring(1, s.length));}
if(s.includes("e")){ robot.e += Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("A")){ robot.phi += Number(s.substring(1, s.length)); robot.aMotorChanged = true;}
if(s.toUpperCase().includes("B")){ robot.theta += Number(s.substring(1, s.length)); robot.bMotorChanged = true;}
if(s.toUpperCase().includes("C")){ robot.psi += Number(s.substring(1, s.length)); robot.cMotorChanged = true;}
if(s.toUpperCase().includes("E")){ robot.e += Number(s.substring(1, s.length)); robot.eMotorChanged = true;}
});
}
else if(g[0] == "M1" && robot.moveRelative){
calculateFromMotorCoordinates = true;
g.forEach((s) => {
if(s.includes("X")){ robot.xMotor += Number(s.substring(1, s.length));}
if(s.includes("x")){ robot.xMotor += Number(s.substring(1, s.length));}
if(s.includes("Y")){ robot.alpha += Number(s.substring(1, s.length));}
if(s.includes("y")){ robot.alpha += Number(s.substring(1, s.length));}
if(s.includes("Z")){ robot.beta += Number(s.substring(1, s.length));}
if(s.includes("z")){ robot.beta += Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("X")){ robot.xMotor += Number(s.substring(1, s.length)); robot.xMotorChanged = true;}
if(s.toUpperCase().includes("Y")){ robot.alpha += Number(s.substring(1, s.length)); robot.yMotorChanged = true;}
if(s.toUpperCase().includes("Z")){ robot.beta += Number(s.substring(1, s.length)); robot.zMotorChanged = true;}
if(s.includes("A")){ robot.a += Number(s.substring(1, s.length));}
if(s.includes("a")){ robot.a += Number(s.substring(1, s.length));}
if(s.includes("B")){ robot.b += Number(s.substring(1, s.length));}
if(s.includes("b")){ robot.b += Number(s.substring(1, s.length));}
if(s.includes("C")){ robot.c += Number(s.substring(1, s.length));}
if(s.includes("c")){ robot.c += Number(s.substring(1, s.length));}
if(s.includes("E")){ robot.e += Number(s.substring(1, s.length));}
if(s.includes("e")){ robot.e += Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("A")){ robot.a += Number(s.substring(1, s.length)); robot.aMotorChanged = true;}
if(s.toUpperCase().includes("B")){ robot.b += Number(s.substring(1, s.length)); robot.bMotorChanged = true;}
if(s.toUpperCase().includes("C")){ robot.c += Number(s.substring(1, s.length)); robot.cMotorChanged = true;}
if(s.toUpperCase().includes("E")){ robot.e += Number(s.substring(1, s.length)); robot.eMotorChanged = true;}
});
}
// Absolute-Positioning
else if(g[0] == "G1" && !robot.moveRelative){
g.forEach((s) => {
if(s.includes("X")){ robot.x = Number(s.substring(1, s.length));}
if(s.includes("x")){ robot.x = Number(s.substring(1, s.length));}
if(s.includes("Y")){ robot.y = Number(s.substring(1, s.length));}
if(s.includes("y")){ robot.y = Number(s.substring(1, s.length));}
if(s.includes("Z")){ robot.z = Number(s.substring(1, s.length));}
if(s.includes("z")){ robot.z = Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("X")){ robot.x = Number(s.substring(1, s.length)); robot.xMotorChanged = true;}
if(s.toUpperCase().includes("Y")){ robot.y = Number(s.substring(1, s.length)); robot.yMotorChanged = true;}
if(s.toUpperCase().includes("Z")){ robot.z = Number(s.substring(1, s.length)); robot.zMotorChanged = true;}
if(s.includes("A")){ robot.phi = Number(s.substring(1, s.length));}
if(s.includes("a")){ robot.phi = Number(s.substring(1, s.length));}
if(s.includes("B")){ robot.theta = Number(s.substring(1, s.length));}
if(s.includes("b")){ robot.theta = Number(s.substring(1, s.length));}
if(s.includes("C")){ robot.psi = Number(s.substring(1, s.length));}
if(s.includes("c")){ robot.psi = Number(s.substring(1, s.length));}
if(s.includes("E")){ robot.e = Number(s.substring(1, s.length));}
if(s.includes("e")){ robot.e = Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("A")){ robot.phi = Number(s.substring(1, s.length)); robot.aMotorChanged = true;}
if(s.toUpperCase().includes("B")){ robot.theta = Number(s.substring(1, s.length)); robot.bMotorChanged = true;}
if(s.toUpperCase().includes("C")){ robot.psi = Number(s.substring(1, s.length)); robot.cMotorChanged = true;}
if(s.toUpperCase().includes("E")){ robot.e = Number(s.substring(1, s.length)); robot.eMotorChanged = true;}
});
}
else if(g[0] == "M1" && !robot.moveRelative){
calculateFromMotorCoordinates = true;
g.forEach((s) => {
if(s.includes("X")){ robot.xMotor = Number(s.substring(1, s.length));}
if(s.includes("x")){ robot.xMotor = Number(s.substring(1, s.length));}
if(s.includes("Y")){ robot.alpha = Number(s.substring(1, s.length));}
if(s.includes("y")){ robot.alpha = Number(s.substring(1, s.length));}
if(s.includes("Z")){ robot.beta = Number(s.substring(1, s.length));}
if(s.includes("z")){ robot.beta = Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("X")){ robot.xMotor = Number(s.substring(1, s.length)); robot.xMotorChanged = true;}
if(s.toUpperCase().includes("Y")){ robot.alpha = Number(s.substring(1, s.length)); robot.yMotorChanged = true;}
if(s.toUpperCase().includes("Z")){ robot.beta = Number(s.substring(1, s.length)); robot.zMotorChanged = true;}
if(s.includes("A")){ robot.a = Number(s.substring(1, s.length));}
if(s.includes("a")){ robot.a = Number(s.substring(1, s.length));}
if(s.includes("B")){ robot.b = Number(s.substring(1, s.length));}
if(s.includes("b")){ robot.b = Number(s.substring(1, s.length));}
if(s.includes("C")){ robot.c = Number(s.substring(1, s.length));}
if(s.includes("c")){ robot.c = Number(s.substring(1, s.length));}
if(s.includes("E")){ robot.e = Number(s.substring(1, s.length));}
if(s.includes("e")){ robot.e = Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("A")){ robot.a = Number(s.substring(1, s.length)); robot.aMotorChanged = true;}
if(s.toUpperCase().includes("B")){ robot.b = Number(s.substring(1, s.length)); robot.bMotorChanged = true;}
if(s.toUpperCase().includes("C")){ robot.c = Number(s.substring(1, s.length)); robot.cMotorChanged = true;}
if(s.toUpperCase().includes("E")){ robot.e = Number(s.substring(1, s.length)); robot.eMotorChanged = true;}
});
robot.calculatePositionFromMotorAngles();
}
else if(g[0] == "M92"){ // G92 - Set Position --- M92 in Radiant
robot.createMotorPosition();
g.forEach((s) => {
if(s.includes("X")){ robot.xMotor = Number(s.substring(1, s.length));}
if(s.includes("x")){ robot.xMotor = Number(s.substring(1, s.length));}
if(s.includes("Y")){ robot.alpha = Number(s.substring(1, s.length));}
if(s.includes("y")){ robot.alpha = Number(s.substring(1, s.length));}
if(s.includes("Z")){ robot.beta = Number(s.substring(1, s.length));}
if(s.includes("z")){ robot.beta = Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("X")){ robot.xMotor = Number(s.substring(1, s.length)); robot.xMotorChanged = true;}
if(s.toUpperCase().includes("Y")){ robot.alpha = Number(s.substring(1, s.length)); robot.yMotorChanged = true;}
if(s.toUpperCase().includes("Z")){ robot.beta = Number(s.substring(1, s.length)); robot.zMotorChanged = true;}
if(s.includes("A")){ robot.a = Number(s.substring(1, s.length));}
if(s.includes("a")){ robot.a = Number(s.substring(1, s.length));}
if(s.includes("B")){ robot.b = Number(s.substring(1, s.length));}
if(s.includes("b")){ robot.b = Number(s.substring(1, s.length));}
if(s.includes("C")){ robot.c = Number(s.substring(1, s.length));}
if(s.includes("c")){ robot.c = Number(s.substring(1, s.length));}
if(s.includes("E")){ robot.e = Number(s.substring(1, s.length));}
if(s.includes("e")){ robot.e = Number(s.substring(1, s.length));}
if(s.toUpperCase().includes("A")){ robot.a = Number(s.substring(1, s.length)); robot.aMotorChanged = true;}
if(s.toUpperCase().includes("B")){ robot.b = Number(s.substring(1, s.length)); robot.bMotorChanged = true;}
if(s.toUpperCase().includes("C")){ robot.c = Number(s.substring(1, s.length)); robot.cMotorChanged = true;}
if(s.toUpperCase().includes("E")){ robot.e = Number(s.substring(1, s.length)); robot.eMotorChanged = true;}
});
robot.calculatePositionFromMotorAngles();
calculateNew = false;