I see there are various callbacks, but I'm struggling to fully understand them.
Are they called once at the end of the relevant move, or continually during the move?
As the Interpreter parses the GCode which creates coordinated motion segments
to be buffered, it makes the call backs below to inform the application what motion was actually created. Note the Interpreter must always work ahead to keep enough buffered data so that if the PC/Windows/USB stalls for some time the motion will continue un-interrupted. The Interpreter typically works ahead a few lines of GCode but in extreme cases might be working ahead hundreds or thousands of lines. Also the converse is true. A single line of GCode may create several or hundreds of motion segments. Each callback occurs once at the time the Interpreter/Trajectory Planner decides a particular motion segment will be made. KMotionCNC's GCode Viewer basically adds/draws the motion at the time of the callback which is why it always shows the upcoming look ahead path.
Code: Select all
void StraightTraverseCallback(double x, double y, double z, double a, double b, double c, int sequence_number);
void ArcFeedCallback(bool ZeroLenAsFullCircles, double DesiredFeedRate_in_per_sec,
double first_end, double second_end,
double first_axis, double second_axis, int rotation,
double axis_end_point,double a, double b, double c,
double first_start, double second_start, double axis_start_point, int sequence_number, int ID);
void StraightFeedCallback(double DesiredFeedRate_in_per_sec,
double x, double y, double z, double a, double b, double c, int sequence_number, int ID);
Also what do the sequence_number, and ID actually do?
sequence_number advances by one for each line of GCode executed. So if Execution begins on the first line and there are no subroutine calls or loops then the sequence_number will equal the GCode Line number. But in general this will not be the case.
In some cases a single line of GCode has more than one part to it. Mainly when radius compensation is active a single feed can create a feed and arc. The ID identifies which part of the GCode created the motion.
Do I need to use them for generating graphics (from my scan of the interpreter files, it looks like sequence_number is related the GCode line number?), or can I ignore them?
With look ahead halt/resume turns out to be quite complicated. With regard to graphics, when a halt occurs and the machine actually comes to a stop, KMotionCNC erases the look ahead graphics back to where the tool actually stopped. After coming to a stop the sequence number and ID of where we stopped is determined. So all the graphics with a larger sequence number/ID is removed. Because we likely stopped in the middle of a line of GCode, then the graphics beyond the xyz point where we stopped, with the same sequence number and ID, should also be removed. See the function:
int CPath3d::RemovePathEnd(int sequence_number, int ID, double x, double y, double z)