Skip to content

Improve hub:direct unload behavior#720

Open
kekiefer wants to merge 1 commit into
AFCProject:DEVfrom
kekiefer:DEV+hub-direct-unload
Open

Improve hub:direct unload behavior#720
kekiefer wants to merge 1 commit into
AFCProject:DEVfrom
kekiefer:DEV+hub-direct-unload

Conversation

@kekiefer
Copy link
Copy Markdown
Contributor

@kekiefer kekiefer commented May 26, 2026

Major Changes in this PR

In hub:direct mode (toolchanger, single lane driving toolhead) unsetting load_to_hub will keep newly loaded spools from winding all the way out to the toolhead, leaving more of the filament inside the enclosure. What doesn't work in this case is the unload. Since there is no hub to home back to, filament homes back to the load switch, which means that the lane loaded state is lost since that switch is no longer triggered.

This change updates the unload behavior so that hub:direct lanes can be unloaded. It does this by doing the same homing move, but then scootching the filament forward until the load switch is triggered again.

This change also addresses an inconsistency where hub:direct lanes can't be ejected. The sequencing of this now works normally with the working unload routine.

Fixes #719

Notes to Code Reviewers

One inconsistency is that when load_to_hub:False is omitted from the config, the unload routine does not bring the filament back to its load position near the toolhead, it is still unloaded to the position near the load switch. Subsequent loads still work fine though.

How the changes in this PR are tested

Toolchanger setup with hub:direct lanes in both load_to_hub:False and default configurations.

PR Checklist: (Checked-off items are either done or do not apply to this PR)

  • I have performed a self-review of my code
  • CHANGELOG.md is updated (if end-user facing)
  • Documentation updated in AT-Documentation repository
  • Sent notification to software-design/software-discussions channel (as appropriate) requesting review
  • If this PR address a GitHub issue, the issue number is referenced in the PR description

NOTE: GitHub Copilot may be used for automated code reviews, however as it is an automated system, it's suggestions
may not be correct. Please do not rely on it to catch all issues. Please review any suggestions it makes and use your
own judgement to determine if they are correct.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Toolchanger unload support for direct hub lanes to ensure consistent handling during lane transitions.
    • Refined unload movement behavior to reduce unexpected motions and improve reliability of finalization steps.

Review Change Stack

@kekiefer kekiefer requested a review from jimmyjon711 May 26, 2026 05:41
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 99a1cfbc-af10-4863-9701-4c4344fde7fc

📥 Commits

Reviewing files that changed from the base of the PR and between 1b1b83c and 05ff37f.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • extras/AFC.py
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

📝 Walkthrough

Walkthrough

This PR fixes a bug preventing ejection of direct-hub lanes that are loaded but not connected to a toolhead. The fix removes conditional blocking in the eject control flow and updates the unload movement sequence to use a bounded forward-advance retry approach instead of retract-based logic.

Changes

Direct-hub lane ejection support

Layer / File(s) Summary
Direct-hub lane eject control flow
extras/AFC.py
Removed cur_lane.is_direct_hub() condition from the eject branch and deleted the separate handler that prevented ejection. Direct-hub lanes now transition through eject and IDLE states like all other lanes.
Direct-hub unload movement sequence
extras/AFC.py
Replaced retract-based movement logic with a bounded forward-advance retry loop (up to 5 attempts with short_move_dis increments) when prep_state is true and raw_load_state is false.
Changelog documentation
CHANGELOG.md
Added 2026-05-24 entry noting Toolchanger unload support for hub:direct lanes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Assessment against linked issues

Objective Addressed Explanation
Allow ejection of direct lanes not loaded to toolhead [#719]
Update control logic to permit eject when filament is not loaded into toolhead [#719]

Suggested reviewers

  • ejsears

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@extras/AFC.py`:
- Around line 2028-2033: The retry loop for parking can perform 6 moves because
park_tries is incremented then checked with > 5; change the cap so it stops
after 5 attempts: either move the check into the loop condition (e.g., while
park_tries < 5 and not cur_lane.raw_load_state and cur_lane.prep_state) or
change the post-increment check to >= 5; update the block around park_tries,
cur_lane.move_advanced(cur_lane.short_move_dis, SpeedMode.SHORT) and the break
so the loop performs at most five move_advanced calls.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 128bd2c8-df17-41e8-bbe2-3bc60654d03a

📥 Commits

Reviewing files that changed from the base of the PR and between 009d863 and 1b1b83c.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • extras/AFC.py

Comment thread extras/AFC.py
In hub:direct mode (toolchanger, single lane driving toolhead) unsetting
load_to_hub will keep newly loaded spools from winding all the way
out to the toolhead, leaving more of the filament inside the enclosure.
What doesn't work in this case is the unload. Since there is no hub to
home back to, filament homes back to the load switch, which means that
the lane loaded state is lost since that switch is no longer triggered.

This change updates the unload behavior so that hub:direct lanes can be
unloaded. It does this by doing the same homing move, but then scootching
the filament forward until the load switch is triggered again.

This change also addresses an inconsistency where hub:direct lanes can't
be ejected. The sequencing of this now works normally with the working
unload routine.

Fixes AFCProject#719
@kekiefer kekiefer force-pushed the DEV+hub-direct-unload branch from 1b1b83c to 05ff37f Compare May 26, 2026 05:47
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.

1 participant