Skip to content

Add clustered GCode support#1730

Open
MitchBradley wants to merge 5 commits into
mainfrom
Clustering
Open

Add clustered GCode support#1730
MitchBradley wants to merge 5 commits into
mainfrom
Clustering

Conversation

@MitchBradley

Copy link
Copy Markdown
Collaborator

Summary

  • add support for colon-delimited clustered S values on linear moves
  • expand clustered moves into internal linear sub-segments so the existing spindle and planner pipeline can be reused
  • advertise support through $I as [CLUSTER:16]
  • add parser coverage for clustered syntax

Notes

Copilot AI review requested due to automatic review settings May 13, 2026 00:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 S words of the form S1:2:3... and gate them to linear motion blocks.
  • Expand clustered G1 moves into multiple internal linear sub-segments with per-segment spindle_speed.
  • Advertise capability via $I build 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 thread FluidNC/src/MotionControl.cpp
Comment thread FluidNC/src/Report.cpp
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);

Comment thread FluidNC/src/GCode.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants