Skip to content

Conversation

@dberlin
Copy link
Contributor

@dberlin dberlin commented Aug 30, 2025

This change add supports for forbidden zones of movement.
They are specified as shapes (in WKT format), and any movement
that intersects with a forbidden zone raises a move error.

This is useful when you have a toolchanger or other area that
you want avoided, but it's not the width/length of the entire
bed, so changing the bed size is unhelpful.

The current implementation is very simple - we use shapely to
parse WKT and build an STRtree, and check for intersection
of the move line with the forbidden zones.

Performance implications are ~nil.
If there are no forbidden zones, there is no time spent checking.

In the the common case of 1-2 polygons that basically never intersect,
you add a few x/y point comparisons to notice
the non-intersection. It would actually be more theoretically optimal
in terms of comparisons to add the endstops as lines to the STRtree and
eliminate the existing endstop checks.

But even with an absurd amount of polygons, the per-check time is essentially
non-measurable on an rpi 4/5.

The current PR is not fully done, but works.
Before i went further, wanted to see if anyone else wanted it.

Stuff to still be done:

  1. Update config docs
  2. Add support to other kinematic types
  3. Add tests

Anyway, if folks think it is useful enough, i'll finish it up and flag is as non-draft.

Checklist

  • pr title makes sense
  • added a test case if possible
  • if new feature, added to the readme
  • ci is happy and green

@rogerlz
Copy link
Contributor

rogerlz commented Oct 14, 2025

Thanks for working on this. It is an interesting feature and has been requested multiple times.
Do you have plans to continue and finish documentation and tests?

Copy link
Contributor

@dalegaard dalegaard left a comment

Choose a reason for hiding this comment

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

Overall fine but needs a couple of tweaks.

self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.0)
self.dc_module = None
self.supports_dual_carriage = True
self.forbidden_zones = ForbiddenZones(config)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should move in to the toolhead so all kinematics benefit. Toolhead calls check_move, so the forbidden_zones check_move can go right before that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, i'm on it.

#
# This file may be distributed under the terms of the GNU GPLv3 license.

from shapely import from_wkt, STRtree, LineString
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be lazy-loaded if config.has_section("forbidden_zones") passes. Otherwise, all existing machines are broken until they update dependencies, which I think is a bit extreme. The way LoadCellPrinterProbe does this is fine, as a reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ditto

@dberlin
Copy link
Contributor Author

dberlin commented Oct 16, 2025

Overall fine but needs a couple of tweaks.

Thanks. I'll take care of it all, and update the docs/etc as well.

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.

3 participants