This PR adds a sanityCheckMovement method, which is used to slightly adjust a requested pen movement, to avoid impossibly slow pen movements on any axis. This fixes #139.
I've made what I think are fixes to a couple of issues I encountered along the way:
The duration calculation when rendering the move command (note penDown is called indirectly from getPosChangeData) would use the pen state at the current buffer tip, rather than the pen state for that movement
The "absolute" branch of `getPosChangeData would use the x/y coordinates of the current pen tip, which may not bear any relation to where we want the pen to go
I was also tempted to change centToSteps to output rounded values, so we can reduce rounding elsewhere, but wasn't feeling bold enough. I can see pen.x/pen.y might end up as non-integer in a couple of places where they're set from cncserver.utils.centToSteps(cncserver.bot.park), which I assume is undesirable.
Note the value returned by the API will be "honest" about the position of the pen in steps, rather than pretending no adjustment occurred.
I'm opening this PR as draft for feedback/in case I've made any fundamental misunderstanding anywhere.
This PR adds a
sanityCheckMovement
method, which is used to slightly adjust a requested pen movement, to avoid impossibly slow pen movements on any axis. This fixes #139.I've made what I think are fixes to a couple of issues I encountered along the way:
The duration calculation when
render
ing the move command (notepenDown
is called indirectly fromgetPosChangeData
) would use the pen state at the current buffer tip, rather than the pen state for that movementThe "absolute" branch of `getPosChangeData would use the x/y coordinates of the current pen tip, which may not bear any relation to where we want the pen to go
I was also tempted to change
centToSteps
to output rounded values, so we can reduce rounding elsewhere, but wasn't feeling bold enough. I can seepen.x
/pen.y
might end up as non-integer in a couple of places where they're set fromcncserver.utils.centToSteps(cncserver.bot.park)
, which I assume is undesirable.Note the value returned by the API will be "honest" about the position of the pen in steps, rather than pretending no adjustment occurred.
I'm opening this PR as draft for feedback/in case I've made any fundamental misunderstanding anywhere.