Skip to content

Commit

Permalink
Avoid accumulation of position error
Browse files Browse the repository at this point in the history
  • Loading branch information
jmpinit committed Nov 3, 2023
1 parent 7e3599c commit 512e704
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,12 @@ export class AxiDraw {

// https://corexy.com/theory.html
const steps = {
x: delta.x * STEPS_PER_MM,
y: delta.y * STEPS_PER_MM,
x: Math.floor(delta.x * STEPS_PER_MM),
y: Math.floor(delta.y * STEPS_PER_MM),
};

this.lastCommandedPos = this.targetPos;
this.lastCommandedPos.x += steps.x / STEPS_PER_MM;
this.lastCommandedPos.y += steps.y / STEPS_PER_MM;

await this.#command(async () => {
// Wait for the command to be sent and acknowledged
Expand Down

0 comments on commit 512e704

Please sign in to comment.