Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
9.49k stars 5.32k forks source link

(mesh bed leveling) : spiralize the grid ==> NOW WORKING ;-) #638

Closed aeropic closed 6 years ago

aeropic commented 6 years ago

I just would want to modify the bed_mesh.py in order to follow a spiral pattern from the center of the bed plate instead of the zig zag one. (As the homing point, in my case, is the center of the bed, I want to suppress an initial move to the corner and also to finish by the front left corner of the bed to allow better access to the head for a cleaning at that location...)

It seems this could be a very simple mod, but before doing it I would want to be confirmed that the order the probe locations are stored into the "points" array does not matter ? I mean can I store my points in spiral rather than in zig zag with the points.append((posx, posy)) instruction?

Thanks

points = [] for i in range(y_cnt): for j in range(x_cnt): if not i % 2:

move in positive directon

                pos_x = min_x + j * x_dist
            else:
                # move in negative direction
                pos_x = max_x - j * x_dist
            points.append((pos_x, pos_y))
Arksine commented 6 years ago

The way in which the points are stored matters. The finalize() function expects the points to return in a zig-zag fashion so that it can correctly organize the table of z-values used to generate the mesh. This is why I chose to procedurally generate the points, so that the user didn't enter invalid points that would confuse mesh generation.

aeropic commented 6 years ago

Thanks Eric, I'll see if it still worths the extra effort ;-)

aeropic commented 6 years ago

@Arksine , well, I tried but I must say I'm stuck very quickly ;-( (did I mention I am a fully noob in python ?)

I cannot even add one simple line in your code, just trying to insert a log line stalls everything eg : replacing this line logging.info('bed_mesh: generated points') by this one is OK logging.info('bed_mesh: my generated points')

but duplicating it does not work... logging.info('bed_mesh: my generated points') logging.info('bed_mesh: my generated points') ==> It compiles but it does not run anymore...

What do I do wrong ? I admire you, fluent people in python !!!!

Arksine commented 6 years ago

@aeropic Most likely its a formatting issue. For example, if your editor is inserting tabs instead of spaces for indentation the interpreter won't like mixing them.

aeropic commented 6 years ago

Bingo, the editor replaced the 4 spaces by one tab! And I've now learnt my first lesson of Python ;-) Thanks, now the fun will begin ... I keep you informed!

aeropic commented 6 years ago

Just for the fun , I eventually did it which helped me to better understand the mesh levelling code ;-).

It is working like a charm with, to my eyes, the advantages to both minimize the traject of the probe and exit at the point (0,0) which is easier to clean the noozle on the fly ...

Fell free to keep it and merge it in the product if you thibnk it worths. (Mind the G28 line which is commented)

self.gcode.run_script_from_command("G28")

Thanks again for the great work done here. Alain

aeropic commented 6 years ago

As this post is referenced in #681, I suggest we can close it !