Add clustered GCode support#1730
Open
MitchBradley wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for colon-delimited “clustered” S values on G1 linear moves, intended to allow senders to provide multiple spindle/laser power samples for a single move while reusing the existing planner/spindle pipeline.
Changes:
- Parse
Swords of the formS1:2:3...and gate them to linear motion blocks. - Expand clustered
G1moves into multiple internal linear sub-segments with per-segmentspindle_speed. - Advertise capability via
$Ibuild info as[CLUSTER:16]and add parser coverage for the new syntax.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| FluidNC/src/tests/parser.nc | Adds a clustered-S G1 test line. |
| FluidNC/src/tests/parser-result.txt | Updates expected parser output to accept clustered syntax. |
| FluidNC/src/Report.cpp | Advertises clustered support in build info ([CLUSTER:16]). |
| FluidNC/src/MotionControl.h | Declares mc_clustered_linear_move(...). |
| FluidNC/src/MotionControl.cpp | Implements clustered move expansion into sub-segments. |
| FluidNC/src/GCode.cpp | Parses clustered spindle speed syntax and routes linear moves through clustered expansion. |
Comments suppressed due to low confidence (2)
FluidNC/src/GCode.cpp:304
- gc_execute_line() introduces std::vector for clustered_spindle_speeds. When clustered syntax is used this will allocate from the heap in the hot G-code parsing path, which can increase latency and fragment memory on embedded targets. Consider using a fixed-capacity container (e.g., std::array + count, or a small-vector with an inline buffer) sized to the supported cluster maximum.
bool laserIsMotion = false;
bool nonmodalG38 = false; // Used for G38.6-9
bool isWaitOnInputDigital = false;
std::vector<float> clustered_spindle_speeds;
FluidNC/src/GCode.cpp:870
- When clustered S syntax is present, gc_block.values.s is set to clustered_spindle_speeds.back(). For non-rate-adjusted spindles, Step 4 may sync and apply this (last) S value before motion starts, so the move begins at the wrong spindle speed/power. Consider either restricting clustered S to rate-adjusted (laser) spindles, or applying the first clustered value before motion and only updating the modal spindle_speed state to the last value after the segmented move completes.
if (line[pos] == ':') {
if (!parse_spindle_speed_cluster(line, pos, value, clustered_spindle_speeds)) {
return Error::BadNumberFormat;
}
gc_block.values.s = clustered_spindle_speeds.back();
Comment on lines
368
to
372
| void report_build_info(const char* line, Channel& channel) { | ||
| constexpr size_t max_reported_cluster_size = 16; | ||
|
|
||
| log_stream(channel, "[VER:" << grbl_version << " FluidNC " << git_info << " (" << MCU << "-" << VARIANT << ") :" << line); | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Svalues on linear moves$Ias[CLUSTER:16]Notes