-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do G2 and G3 interpret I and J in 'Incremental IJ mode' or 'Absolute IJ mode'? #431
Comments
I believe that we are operating in incremental mode for I and J. From a quick look at the code around line 690 in Gcode.cpp:
I think assuming that if the values are omitted to use 0 is a sign that we're in incremental mode, and then the current position + value makes sense for incremental mode. I'm not sure I have seen gcode generated using absolute mode before...which is strange because for XY coordinates absolute mode is the norm |
That's the center of the issue 😁. Why the problem with a negative relative value for J? Is that an invalid value? It doesn't seem like it should be. Maybe where centerX and centerY are used in Motion::arc() in a atan() calculation to calculate the starting- and endingAngles |
OK, some headway. For the first gcode, Motion::arc() sees these values:
for the second one:
It looks to me like the center of X-10Y-1 is invalid for an endpoint X-1.94Y1.5. Motion::arc() is going to use centerX and centerY to calculate the incremental movement steps that move the bit as g-code simulator suggests. That will result in an endpoint different from the valued X2 and Y2 that the gcode passed to the arc() function. Bam! Position Error. |
Nice work!!! |
And that's the answer.
if they don't match, we're using relative mode, and that proves to be true:
Now, what to do? Flag an error, or move X2,Y2 relative to I,J? |
This one we could flag when the file is loaded, right? If so I say we show a popup that the file contains some invalid gcode and it can be run, but the results may be unpredictable |
In order to flag it we would need to put the calcs in GC gcodeCanvas, I suppose in drawArc(), yes? I've been trying to figure out the trig to calculate the relative endpoint X,Y, but Mr. Hagberg's trig class was 54 years ago... |
I remember it being complicated and then putting it in the category of "things I would solve when they come up" and nobody has come up with a gcode file that was causing trouble before... 😀 |
Working in GC gcodeCanvas::drawArc(), comparing the distance from the I,J centerpoint to the startPoint and to the endPoint, MakerCam does a pretty terrible job of picking an I,J that's equidistant from the start- and endpoints. I guess mostly it doesn't matter, as we don't often see issues, but how to tell when it will matter? Rounding is a possibility, using the Advanced Setting 'digits' (though the wording might be changed to 'Rounding instead of 'Truncate'). How about, instead of failing to load the questionable gcode, we put a line in the log like
Also, how about making that line segment some bright color, and maybe fatter as well? Then we can troubleshoot bad gcode files before anyone has wasted plywood 😁 |
I think both of these are phenomenal ideas |
From a discussion in Issue #426. A partner issue in GC #708
There's a good summary here in the section 'Center Format Arc:'. I haven't dug in yet, but I wonder whether we're interpreting I and J in 'Incremental IJ mode' or 'Absolute IJ mode'.
The text was updated successfully, but these errors were encountered: