-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UBL G29 J Level on Mesh points #25486
UBL G29 J Level on Mesh points #25486
Conversation
Corrects incorrect variable types in ubl.h that were causing UBL Mesh Levelling (G29 Jx) to tilt meshes incorrectly.
… into bugfix-2.1.x
the nearest mesh points whilst probing.
That should be added so users can find/use this feature. Somewhere under the Lines 2045 to 2049 in 26f96dc
|
Finished proper #ifdef for "UBL_LEVEL_ON_MESH_POINT" and added "UBL_LEVEL_ON_MESH_POINT_FIXED_3POINT" to specify whether it will affect manually defined 3 point probing points.
… into bugfix-2.1.x
Added in #defines to enable the feature, and specify whether or not it applies to fixed 3 point leveling points.
https://github.com/jamespearson04/Marlin/blob/bugfix-2.1.x/Marlin/Configuration.h#L2045-L2065
|
to prevent superfluous calls to "probe.get_three_points(points);" and unneccessary variable initializations when not using 3 point leveling.
Replaces calls to "get_z_correction()" with reads from "z_values[]" when using "UBL_LEVEL_ON_MESH_POINT".
DEBUG(LEVELING) will now report both the farthest probeable points, used for leveling without UBL_LEVEL_ON_MESH_POINT enabled, and the mesh points selected in their place.
Moves the initialization of some variables into the else statement in which they are used, as they are not required outside of this statement.
That should be working now, though I haven't had chance to test it and won't until Monday. There may be a better way of selecting points, as opposed to subdividing the probeable area and selecting the nearest ones. However I can't really see how that would play nicely with the way the leveling grid is specified (G29 Jx -> x*x grid), as the available mesh points are virtually never going to correspond to a square grid, and even so it would only work for one size. A different method of selecting points from the mesh would be required in order to work better than the current system. |
I'm not sure I understand the reasoning for this option. But perhaps I misunderstand the purpose of the It is my understanding that the What am I missing? |
I'm not sure I understand your comment, are you saying the whole feature is unwarranted, or having the defines for it? Because I agree with the latter, I'll gladly change it if others agree it should be the standard.
Without this PR, the selected points for probing aren't even necessarily confined to the mesh, so depending on configuration, the measured value can be compared against extrapolations (or whatever method is used to work out the Z correction beyond the mesh, none of which will yield good values). As a result, with such a configuration, you can probe a fresh mesh with Opting to limit this probing to mesh points means we're comparing pairs of two actual measurements, not a measurement and a inter/extrapolation, eliminating any potential for errors due to them. |
Even without UBL_TILT_ON_MESH_POINTS_3POINT I think this should be confined to the bounds of the mesh. (unless otherwise specified I suppose). Currently it is based on the probing bounds, so If MESH_INSET > PROBING_MARGIN it will perform poorly due to extrapolated points. Marlin/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Lines 1488 to 1498 in 94b5d54
|
This commit updates G29 J to work from the probeable mesh area, as opposed to the whole probeable area, reducing the opportunity for extrapolated values to be used. (can still happen if points lie within area populated by G29 P3)
swap MAX2 for _MAX and MIN2 for _MIN
G29J_MESH_TILT_MARGIN now applies from the mesh border if it is more inset than the probing margin.
I've updated the standard version (non mesh point) to confine the points to the mesh area, as probing outside of it just doesn't make sense, I can't think of a use case where it would be desireable behaviour. A warning has been added for |
I see what you mean. You could use In case you wondered, I made it possible to use closest mesh points even in the case where the mesh points are not explicitly set by the user, because it seems reasonable that you might want to do that sometimes. I expect that picking your own mesh points would be the less common case. And, I made it so the two new options are independent of one another, but I expect most users will enable both if they enable one. |
I don't see that as being too unusual if you were using ABL with a known-flat bed, but since UBL uses a constant for points outside the mesh it is very likely to be invalid most of the time. So, the added warning is a good idea. |
I don't really know how the translation is actually applied, so I can't really say how mathematically correct that portion is, but it does appear to work well when it's using good points, noticeably better than with extrapolated points. Best I can do is assure that this makes it better not worse lol.
Absolutely, but if that's the case you have no need for UBL, you'd be using one of the other leveling variants, so I think it ought to be the norm for UBL. The warning is just for people who were using the G29J margin, as its behaviour will have changed slightly with the associated commit. Not ideal, but necessary to keep |
The const float x_min = _MAX((X_MIN_POS) + (G29J_MESH_TILT_MARGIN), MESH_MIN_X, probe.min_x()),
x_max = _MIN((X_MAX_POS) - (G29J_MESH_TILT_MARGIN), MESH_MAX_X, probe.max_x()),
y_min = _MAX((Y_MIN_POS) + (G29J_MESH_TILT_MARGIN), MESH_MIN_Y, probe.min_y()),
y_max = _MIN((Y_MAX_POS) - (G29J_MESH_TILT_MARGIN), MESH_MAX_Y, probe.max_y()); |
I agree, that's the right way to handle it, I'll add it in. edit: nvm, commit hadn't loaded up for me |
The only other thing I can think of that might be worth improving on is how it handles the mesh being cut off by unprobeable areas (without The black box is the bed, the green box the probeable area. The vertical lines represent mesh columns. Red are manually probed / estimated, blue are measured. Orange dots the generated probe points for 3 point leveling. The leftmost point will be less accurate than the others, as it will be the result of an interpolation between measured and manually probed/estimated (extrapolated) values. This is actually the situation that led to me creating the (This will have the effect of shifting it on to a mesh point as |
Also thank you @thinkyhead for your help on this PR! |
something akin to
|
* [cron] Bump distribution date (2023-03-05) * 🐛 Fix apply_power for SPINDLE_SERVO (MarlinFirmware#25465) * 🐛 Fix Flash EEPROM for STM32G0B1CB (MarlinFirmware#25469) * 🌐 Update Turkish language (MarlinFirmware#25447) * [cron] Bump distribution date (2023-03-06) * 🧑💻 Script to make non-accented languages * 🌐 Update Turkish language Followup to MarlinFirmware#25447 * [cron] Bump distribution date (2023-03-07) * 🌐 DGUS Reloaded non-accented French (MarlinFirmware#25443) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * 🔧 Add DGUS_LCD_UI RELOADED conditions * [cron] Bump distribution date (2023-03-08) * ✨ Extra Z Servo Probe options (MarlinFirmware#21427) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * 🔧 Update some config.ini options * 🔨 VSCode + Devcontainer support (MarlinFirmware#22420) * [cron] Bump distribution date (2023-03-09) * ✨ Z_SAFE_HOMING_POINT_ABSOLUTE (MarlinFirmware#23069) * [cron] Bump distribution date (2023-03-10) * ✨ BTT Octopus Max EZ 1.0, SKR 3.0 / 3.0 EZ (MarlinFirmware#25387) BTT Octopus Max EZ V1.0 (STM32H723VE/ZE), SKR V3.0 / V3.0 EZ (STM32H723VG) * [cron] Bump distribution date (2023-03-11) * 🐛 Fix Anet ET4 SD_SS_PIN (MarlinFirmware#25492) * [cron] Bump distribution date (2023-03-12) * BTT Octopus … followup (MarlinFirmware#25495) Followup to MarlinFirmware#25387 * ⚡️ Exit from ISR on AVR already does sei Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com> * 🎨 Cosmetic stepper updates Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com> * ✨ MAX7219_DEBUG_MULTISTEPPING Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com> * ⚡️ Use hal_timer_t for timing vars Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com> * ⚡️ Use cached la_active state Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com> * ⚡️ Use AxisFlags for step_needed Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com> * [cron] Bump distribution date (2023-03-13) * ⚡️ Major shaper optimization Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com> * ⚡️ Set steps_per_isr in calc_multistep_timer_interval Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com> * 🔧 Expose MULTISTEPPING_LIMIT option Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com> * ⚡️ Optimize speed lookup for AVR Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com> * ⚡️ Update ISR cycle counts Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com> * 📺 DGUS_RELOADED 1.03 (MarlinFirmware#25490) * [cron] Bump distribution date (2023-03-14) * 🐛 Fix Polargraph without Z (MarlinFirmware#25514) * 🐛 Fix long filename read/report (MarlinFirmware#25509) * 🩹 Fix IA_CREALITY float, startup (MarlinFirmware#25493) Followup to MarlinFirmware#25440 * [cron] Bump distribution date (2023-03-15) * 🎨 Misc. formatting * 🎨 Misc. tramming menu cleanup (MarlinFirmware#25519) * 🩹 Fan Menu / Status fixes Followup to MarlinFirmware#21888 * 🩹 Fix DWIN MarlinUI Fan/E/XY (MarlinFirmware#25502) * [cron] Bump distribution date (2023-03-16) * 🔧 Safer default for Z_MIN_PROBE_PIN override (MarlinFirmware#25524) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * ♻️ Refactor PROBE_PT_[123] * ♻️ Refactor UBL 'G29 J' * [cron] Bump distribution date (2023-03-17) * 🚸 Refinements for UBL G29 J (tilt mesh) (MarlinFirmware#25486) * [cron] Bump distribution date (2023-03-18) * 🔧 Optional MPC_AUTOTUNE to save 5.5 - 5.8KB * ✨ Sovol v1.3.1 (Sovol SV06) (MarlinFirmware#25267) * 🧑💻 More IntelliSense-friendly declares * 🎨 Clean up IA_CREALITY includes (MarlinFirmware#25530) * 🎨 Suppress warning (MarlinFirmware#25529) * 🔧 SQUARE_WAVE_STEPPING => EDGE_STEPPING (MarlinFirmware#25526) Co-Authored-By: Scott Lahteine <thinkyhead@users.noreply.github.com> * 🚸 Improve Z-Probe raise for deploy (MarlinFirmware#25498) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * 🐛 Fix LVGL / MKS WiFi long filename (MarlinFirmware#25483) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * 🔨 Fix STM32H723Vx_btt for case-sensitive (MarlinFirmware#25535) * 🐛 Fix FYSETC Cheetah v2.0 Servo/Probe pins (MarlinFirmware#24635) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * 🐛 Prevent MPC E-permm overrun in Load Filament (MarlinFirmware#25531) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * 🚸 Fix / improve LCD_BED_TRAMMING (MarlinFirmware#25425) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * 🔧 Sanity-check PRINTCOUNTER_SAVE_INTERVAL + ESP32 I2S Exp (MarlinFirmware#25527) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * ⚡️ Smart Adaptive Multi-Stepping (MarlinFirmware#25474) * 🚸 Temperature Variance Monitor tweaks (MarlinFirmware#23571) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * 🩹 Fix Ender 2 stock LCD (MarlinFirmware#25538) * ⚡️ Misc. optimizations * [cron] Bump distribution date (2023-03-19) * ✨ REPORT_ADAPTIVE_FAN_SLOWING (MarlinFirmware#25537) * 🩹 Fix a serial_ternary * ✨ Z_SERVO_DEACTIVATE_AFTER_STOW (MarlinFirmware#24215) * 🐛 Avoid step rate overflow (MarlinFirmware#25541) * [cron] Bump distribution date (2023-03-20) * ✨ PROBING_TOOL (MarlinFirmware#24411) * [cron] Bump distribution date (2023-03-22) * ✨ FILAMENT_SWITCH_AND_MOTION (MarlinFirmware#25548) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * 🧑💻 ExtUI::onSetPowerLoss * [cron] Bump distribution date (2023-03-23) * 🎨 calibration_stage => stage * [cron] Bump distribution date (2023-03-24) * 🩹 Reset touch screen calibration on failure (MarlinFirmware#25334) Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> * 🎨 TMC SPI Pins Co-Authored-By: Martin Turski <turningtides@outlook.de> * 🎨 Pins header comments Co-Authored-By: Martin Turski <turningtides@outlook.de> * 🎨 Wrap font includes Co-Authored-By: Martin Turski <turningtides@outlook.de> * 🎨 LPC_SOFTWARE_SPI => SOFTWARE_SPI Co-Authored-By: Martin Turski <turningtides@outlook.de> * 🔨 INI Updates Co-Authored-By: Martin Turski <turningtides@outlook.de> * 🎨 Misc. fixes, cleanup Co-Authored-By: Martin Turski <turningtides@outlook.de> * 🩹 Update TRONXY_V10 SPI_FLASH pins * [cron] Bump distribution date (2023-03-25) * 🩹 Fix Chitu3D V6 default probe pin (MarlinFirmware#25552) * 🔧 Remove TVPM warning (MarlinFirmware#25551) * 🐛 Fix MKS Gen L 2.1 MOSFET pins (MarlinFirmware#25542) * 🩹 Refine MKS boards with a dedicated FAN port (MarlinFirmware#25567) * 🎨 Rename FAN_PIN to FAN0_PIN (MarlinFirmware#25568) * 📝 Fix spelling (MarlinFirmware#25563) * [cron] Bump distribution date (2023-03-26) * 🎨 Timer tweaks * 🔧 Refactor endstop state config (MarlinFirmware#25574) * ✨ AnyCubic Vyper / Vyper LCD (MarlinFirmware#25405) * 🩹 Fix Touch Calibration first point (MarlinFirmware#25298) * 🧑💻 Auto Fan / Cooler Fan updates (MarlinFirmware#25554) * 🐛 Prevent divide-by-zero in calc_timer_interval (MarlinFirmware#25557) * 🔧 Sanity-check for endstop inverting Followup to MarlinFirmware#25574 * 🔧 Clarify axis disable / timeout (MarlinFirmware#25571) * [cron] Bump distribution date (2023-03-27) * 🔨 Fix thread-unsafe deque iteration * 🐛 Fix AnyCubic Vyper ProcessPanelRequest Followup to MarlinFirmware#25405 * 🎨 Suppress a type warning (MarlinFirmware#25575) * ⚡️ Improve TFT DMA for STM32 (MarlinFirmware#25359) * 🐛 Fix M23 long filename support (MarlinFirmware#25540) * [cron] Bump distribution date (2023-03-28) * 🎨 Misc. cleanup * 🔧 Fix up WiFi options (MarlinFirmware#25586) * 🔨 Update config.ini endstop states Followup to MarlinFirmware#25574 * [cron] Bump distribution date (2023-03-29) * 🔧 Impose Hephestos 2 Bed Kit requirements (MarlinFirmware#25585) * 🎨 Remove unused ProUI : UBLValidMesh (MarlinFirmware#25591) * 🔨 Improve Docker local tests support (MarlinFirmware#25583) * 🔨 MarlinSimUI updates (MarlinFirmware#25589) * [cron] Bump distribution date (2023-03-30) * 🩹 Update Trigorilla V006 fan pin Followup to MarlinFirmware#25568 * 🩹 Fix Ender-3 V2 with no fan * 🐛 Fix _HAS_FAN for fan on Pin 0 * 🎨 Refine probe, more debug * 🩹 Fix displayed mix percentages * [cron] Bump distribution date (2023-03-31) * 🔧 DGUS_LCD_UI selectable options * 🔧 Fix SENSORLESS hit state error (MarlinFirmware#25604) * 🧑💻 CardReader adjustments (MarlinFirmware#25611) * [cron] Bump distribution date (2023-04-01) * 🎨 HAS_SHAPING => HAS_ZV_SHAPING * ✨ Fixed-Time Motion with Input Shaping by Ulendo (MarlinFirmware#25394) Co-authored-by: Ulendo Alex <alex@ulendo.io> * 🐛 Fix Long FIlename lookup (MarlinFirmware#25598) * 🌐 Update Italian language (MarlinFirmware#25587) * 🔨 Move Docker local test script Followup to MarlinFirmware#25583 * 🩹 FT_MOTION Followup * 🐛 Ensure root for 'M503 C' * 🐛 Clean up DELTA babystep Z * 🐛 INVERT_*_DIR for FT_MOTION (MarlinFirmware#25637) * 🔧 Move DOGLCD options * 🧑💻 Update pinsformat.js * 📝 Update Ender # labels * [cron] Bump distribution date (2023-04-07) * 🚸 Support CoreXY without Z (MarlinFirmware#25630) * 🎨 Apply const (MarlinFirmware#25643) * update `pins_Aquila_X2.h` to new format --------- Co-authored-by: thinkyhead <thinkyhead@users.noreply.github.com> Co-authored-by: Hans-Christian Ebke <ebke@cs.rwth-aachen.de> Co-authored-by: alextrical <35117191+alextrical@users.noreply.github.com> Co-authored-by: Abdullah YILMAZ <h.abdullahyilmaz@hotmail.com> Co-authored-by: albatorsssx <albator_ssx@hotmail.com> Co-authored-by: Kurt Haenen <Misterke@users.noreply.github.com> Co-authored-by: Sion Williams <sion5@hotmail.co.uk> Co-authored-by: Evgeniy Zhabotinskiy <evg-zhabotinsky@users.noreply.github.com> Co-authored-by: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Co-authored-by: tombrazier <68918209+tombrazier@users.noreply.github.com> Co-authored-by: Neo2003 <Neo2003@users.noreply.github.com> Co-authored-by: jbubik <jbubik@centrum.cz> Co-authored-by: Eduard Sukharev <sukharev.eh@gmail.com> Co-authored-by: Davide Rombolà <davide.rombola@gmail.com> Co-authored-by: dwzg <50058606+dwzg@users.noreply.github.com> Co-authored-by: ellensp <530024+ellensp@users.noreply.github.com> Co-authored-by: jamespearson04 <jamespearson04@hotmail.co.uk> Co-authored-by: Michael Hill <mhill@hillsoftware.com> Co-authored-by: James Gilliland <neclimdul@gmail.com> Co-authored-by: Liam Powell <liam+github@liampwll.com> Co-authored-by: George Fu <nailao_5918@163.com> Co-authored-by: Piotr Paczyński <ppaczyn@gmail.com> Co-authored-by: Farva42 <100859196+Farva42@users.noreply.github.com> Co-authored-by: John Robertson <john@cirtech.co.uk> Co-authored-by: John Lagonikas <39417467+zeleps@users.noreply.github.com> Co-authored-by: StevilKnevil <stevilknevil@hotmail.co.uk> Co-authored-by: FilippoR <filippo.rossoni@gmail.com> Co-authored-by: BIGTREETECH <38851044+bigtreetech@users.noreply.github.com> Co-authored-by: Martin Turski <turningtides@outlook.de> Co-authored-by: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Co-authored-by: Bob Kuhn <bob.kuhn@att.net> Co-authored-by: Alexander Gavrilenko <jmz52@users.noreply.github.com> Co-authored-by: Andrew <18502096+classicrocker883@users.noreply.github.com> Co-authored-by: John Unland <junland.foss@gmail.com> Co-authored-by: Chris Pepper <p3p@p3psoft.co.uk> Co-authored-by: Ulendo Alex <alex@ulendo.io>
Description
G29 J Currently probes the edges of the probeable area, typically not on top of existing mesh points. This means that the mesh Z height value used to compare against is likely to be interpolated, and if the point lies in a mesh area populated by G29 P3 (On the outside of the probed mesh points) it's Z height will almost certainly be innacurate.
This push uses the already existing
find_closest_mesh_point_of_type()
to find the nearest probeable mesh point to each G29 J probe point, and probes there instead. It should work for all enumerations of G29 Jx, assuming sufficient points exist. In the event insufficient points exist, some will most likely be probed twice, which shouldn't have a significant negative effect, but may bias the LSF results (however this is currently untested).Testing on Ender 3 Max and Ender 3 Neo has proven successful.
All that remains is to decide how to handle
PROBE_PT_1_X
etc. Most likely a second define that determines whether their raw position or their nearest mesh point is used.Requirements
Requires Unified Bed Leveling and some kind of probe.
Benefits
Improves G29 J accuracy.
Configurations
Requires the addition of
#define TILT_PROBE_ON_MESH_POINTS
to Configuration.h/Configuration_adv.h.Related Issues
#25485