G92 senden besser
This commit is contained in:
@@ -7,9 +7,15 @@
|
||||
* exakt die Homing-Semantik. Die Achsbuchstaben bilden 1:1 auf die Motorachsen
|
||||
* ab: X→xMotor, Y→alpha, Z→beta, A→a, B→b, C→c, E→e.
|
||||
*
|
||||
* Die Homing-Kette (4b: Arm1→y, Ellbow→z, Arm2→a, Hand→b) bestimmt c (Palm) und
|
||||
* e (Greifer) nicht. Entscheidung: fehlende Achsen als 0 mitsenden
|
||||
* (`fillMissingWithZero`), damit G92 alle 7 Achsen trägt.
|
||||
* Bekannte Achsen werden immer mit ihrem realen Wert gesendet. Welche Achsen
|
||||
* bekannt sind, hängt vom Pfad ab:
|
||||
* - 5_pose_estimation.py (Fallback) liefert alle 7 (x,y,z,a,b,c,e),
|
||||
* - die 4b-Primärkette (Arm1→y … Hand→b) liefert nur x,y,z,a,b.
|
||||
* Eine Achse, die wirklich fehlt oder als unbeobachtbar `null` markiert ist,
|
||||
* wird per Default WEGGELASSEN — der Driver lässt nicht genannte Achsen
|
||||
* unverändert (M92 setzt nur Achsen mit endlichem Zahlenwert), statt eine
|
||||
* unbekannte Position fälschlich als 0 zu behaupten. `fillMissingWithZero`
|
||||
* erzwingt bei Bedarf das alte 0-Auffüllen.
|
||||
*
|
||||
* CommonJS, damit Jest (CJS) und der ESM-Server dieselbe Funktion nutzen
|
||||
* (gleiches Muster wie spinNormalize.cjs / homingXEstimate.cjs).
|
||||
@@ -24,9 +30,9 @@ const AXES = [
|
||||
/**
|
||||
* @param {Record<string, number|null>} state flacher Joint-State (accumulated_state)
|
||||
* @param {{decimals?: number, fillMissingWithZero?: boolean}} [opts]
|
||||
* @returns {string} z.B. "G92 X192.73 Y35.99 Z-30.88 A-1.70 B12.34 C0.00 E0.00"
|
||||
* @returns {string} z.B. "G92 X164.57 Y-2.09 Z60.58 A86.75 B-46.97 C-64.91 E22.59"
|
||||
*/
|
||||
function buildG92(state = {}, { decimals = 2, fillMissingWithZero = true } = {}) {
|
||||
function buildG92(state = {}, { decimals = 2, fillMissingWithZero = false } = {}) {
|
||||
const parts = [];
|
||||
for (const [key, axis] of AXES) {
|
||||
const num = Number(state?.[key]);
|
||||
|
||||
Reference in New Issue
Block a user