This commit is contained in:
Sgr A* VMT
2024-02-03 20:49:59 +08:00
parent 138e773ef8
commit dca8c54210

18
idm.py
View File

@@ -598,9 +598,9 @@ class IDMProbe:
def _get_trapq_position(self, print_time):
move = None
if self._last_trapq_move:
last = self._last_trapq_move
last = self._last_trapq_move[0]
last_end = last.print_time + last.move_t
if last.print_time <= print_time <= last_end:
if last.print_time <= print_time < last_end:
move = last
if move is None:
ffi_main, ffi_lib = chelper.get_ffi()
@@ -608,8 +608,8 @@ class IDMProbe:
count = ffi_lib.trapq_extract_old(self.trapq, data, 1, 0.0, print_time)
if not count:
return None, None
move = data[0]
self._last_trapq_move = move
self._last_trapq_move = data
move = data[0]
move_time = max(0.0, min(move.move_t, print_time - move.print_time))
dist = (move.start_v + .5 * move.accel * move_time) * move_time
pos = (move.start_x + move.x_r * dist, move.start_y + move.y_r * dist,
@@ -1585,9 +1585,9 @@ class IDMMeshHelper:
return points
def calibrate(self, gcmd):
self.min_x, self.min_y = coord_fallback(gcmd, "MESH_MIN", float,
self.min_x, self.min_y = coord_fallback(gcmd, "MESH_MIN", convert_float,
self.def_min_x, self.def_min_y, lambda v, d: max(v, d))
self.max_x, self.max_y = coord_fallback(gcmd, "MESH_MAX", float,
self.max_x, self.max_y = coord_fallback(gcmd, "MESH_MAX", convert_float,
self.def_max_x, self.def_max_y, lambda v, d: min(v, d))
self.res_x, self.res_y = coord_fallback(gcmd, "PROBE_COUNT", int,
self.def_res_x, self.def_res_y, lambda v, _d: max(v, 3))
@@ -1987,6 +1987,12 @@ def arc_points(cx, cy, r, start_angle, span):
return points
def convert_float(data):
toFloat=float(data)
if np.isinf(toFloat) or np.isnan(toFloat):
raise ValueError(f"Convert error when trying to convert string \"{data}\" into float")
return toFloat
def coord_fallback(gcmd, name, parse, def_x, def_y, map=lambda v, d: v):
param = gcmd.get(name, None)
if param is not None: