spin Marker Callibration
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
* überschrieben; bei Bedarf Backup-Strategie ergänzen).
|
||||
*/
|
||||
import fsPromises from 'fs/promises';
|
||||
import { createRequire } from 'module';
|
||||
const { normalizeSpinDeg } = createRequire(import.meta.url)('./spinNormalize.cjs');
|
||||
|
||||
// ── I/O ───────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -609,3 +611,33 @@ export async function setJointOriginYZ(robotPath, { linkName, y, z }) {
|
||||
newOrigin: [...joint.origin],
|
||||
};
|
||||
}
|
||||
|
||||
// ── Aktion 8: Arm-Marker Spin setzen ─────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Setzt den `spin`-Wert eines Arm-Markers in robot.json.
|
||||
* Body: { linkName, markerId, spin }
|
||||
* spin: absolute Gradzahl (0 / 90 / 180 / 270) oder relativer Delta (+90, -90, +180)
|
||||
* — hier wird immer die *neue absolute* Gradzahl erwartet.
|
||||
*
|
||||
* @returns {{ changed, linkName, markerId, oldSpin, newSpin } | { changed: false, error }}
|
||||
*/
|
||||
export async function setArmMarkerSpin(robotPath, { linkName, markerId, spin }) {
|
||||
const robot = await readRobot(robotPath);
|
||||
const linkData = robot.links?.[linkName];
|
||||
if (!linkData) return { changed: false, error: `Link '${linkName}' nicht gefunden.` };
|
||||
|
||||
const markers = linkData.markers ?? [];
|
||||
const idx = markers.findIndex(m => Number(m.id) === Number(markerId));
|
||||
if (idx === -1) {
|
||||
return { changed: false, error: `Marker ${markerId} in Link '${linkName}' nicht gefunden.` };
|
||||
}
|
||||
|
||||
const oldSpin = markers[idx].spin ?? 0;
|
||||
const newSpin = normalizeSpinDeg(spin);
|
||||
markers[idx].spin = newSpin;
|
||||
|
||||
await writeRobot(robotPath, robot);
|
||||
|
||||
return { changed: true, linkName, markerId: Number(markerId), oldSpin, newSpin };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user