Skip to content

Commit 474d80c

Browse files
authored
Preserve -1 sentinel before step size conversion in objective.py
1 parent 6e8d51c commit 474d80c

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

uc2rest/objective.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,18 @@ def setPositions(self, x0=None, x1=None, z0=None, z1=None, isBlocking=False):
216216
payload = {"task": path}
217217

218218
# Only include x0 or x1 in JSON if they were explicitly provided
219-
# If x0 == -1, that instructs the MCU to take current motor position
220-
# Divide by signed_step_size to convert user-frame physical units to
221-
# firmware hardware steps, including the direction/polarity sign.
219+
# If a coordinate == -1, that instructs the MCU to take the current
220+
# motor position; preserve the sentinel as-is. Otherwise divide by
221+
# signed_step_size to convert user-frame physical units to firmware
222+
# hardware steps, including the direction/polarity sign.
222223
if x0 is not None:
223-
payload["x0"] = x0 / self._parent.motor.signed_step_size("A")
224+
payload["x0"] = x0 if x0 == -1 else x0 / self._parent.motor.signed_step_size("A")
224225
if x1 is not None:
225-
payload["x1"] = x1 / self._parent.motor.signed_step_size("A")
226+
payload["x1"] = x1 if x1 == -1 else x1 / self._parent.motor.signed_step_size("A")
226227
if z0 is not None:
227-
payload["z0"] = z0 / self._parent.motor.signed_step_size("Z")
228+
payload["z0"] = z0 if z0 == -1 else z0 / self._parent.motor.signed_step_size("Z")
228229
if z1 is not None:
229-
payload["z1"] = z1 / self._parent.motor.signed_step_size("Z")
230+
payload["z1"] = z1 if z1 == -1 else z1 / self._parent.motor.signed_step_size("Z")
230231

231232
nResponses = 1 if isBlocking else 0
232233
r = self._parent.post_json(

0 commit comments

Comments
 (0)