Skip to content

Commit

Permalink
fix(hardware-testing): add __init__.py to modules/ so it gets packed …
Browse files Browse the repository at this point in the history
…in the build + other Flex stacker QC fixes. (#16995)

- add an `__init__.py` so it does, this will make it so we can push to the robot.
- change the way we validate no movement when in e-stop
- don't wait for ack from stop_motor `M0` command.
  • Loading branch information
vegano1 authored Nov 27, 2024
1 parent 1c0a01c commit 2b4e657
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
1 change: 1 addition & 0 deletions hardware-testing/hardware_testing/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Module QC Scripts."""
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,15 @@ def __init__(self, port: str, simulating: bool = False) -> None:
if not self._simulating:
self._serial = serial.Serial(port, baudrate=STACKER_FREQ, timeout=60)

def _send_and_recv(self, msg: str, guard_ret: str = "") -> str:
def _send_and_recv(
self, msg: str, guard_ret: str = "", response_required: bool = True
) -> str:
"""Internal utility to send a command and receive the response."""
assert not self._simulating
self._serial.reset_input_buffer()
self._serial.write(msg.encode())
if not response_required:
return "OK\n"
ret = self._serial.readline()
if guard_ret:
if not ret.startswith(guard_ret.encode()):
Expand Down Expand Up @@ -159,7 +164,7 @@ def stop_motor(self) -> None:
"""Stop motor movement."""
if self._simulating:
return
self._send_and_recv("M0\n")
self._send_and_recv("M0\n", response_required=False)

def get_limit_switch(self, axis: StackerAxis, direction: Direction) -> bool:
"""Get limit switch status.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,23 @@ def run(driver: FlexStacker, report: CSVReport, section: str) -> None:

report(section, "trigger-estop", [CSVResult.PASS])

print("try to move X axis...")
driver.move_in_mm(StackerAxis.X, x_limit.opposite().distance(10))
print("X should not move")
report(
section,
"x-move-disabled",
[CSVResult.from_bool(driver.get_limit_switch(StackerAxis.X, x_limit))],
)
print("Check X limit switch...")
limit_switch_triggered = driver.get_limit_switch(StackerAxis.X, x_limit)
if limit_switch_triggered:
report(
section,
"x-move-disabled",
[CSVResult.from_bool(False)],
)
else:
print("try to move X axis back to the limit switch...")
driver.move_in_mm(StackerAxis.X, x_limit.distance(3))
print("X should not move")
report(
section,
"x-move-disabled",
[CSVResult.from_bool(not driver.get_limit_switch(StackerAxis.X, x_limit))],
)

print("try to move Z axis...")
driver.move_in_mm(StackerAxis.Z, z_limit.opposite().distance(10))
Expand All @@ -74,14 +83,23 @@ def run(driver: FlexStacker, report: CSVReport, section: str) -> None:
[CSVResult.from_bool(driver.get_limit_switch(StackerAxis.Z, z_limit))],
)

print("try to move L axis...")
driver.move_in_mm(StackerAxis.L, l_limit.opposite().distance(10))
print("L should not move")
report(
section,
"l-move-disabled",
[CSVResult.from_bool(driver.get_limit_switch(StackerAxis.L, l_limit))],
)
print("Check L limit switch...")
limit_switch_triggered = driver.get_limit_switch(StackerAxis.L, l_limit)
if limit_switch_triggered:
report(
section,
"l-move-disabled",
[CSVResult.from_bool(False)],
)
else:
print("try to move L axis back to the limit switch...")
driver.move_in_mm(StackerAxis.L, l_limit.distance(1))
print("L should not move")
report(
section,
"l-move-disabled",
[CSVResult.from_bool(not driver.get_limit_switch(StackerAxis.L, l_limit))],
)

if not driver._simulating:
ui.get_user_ready("Untrigger the E-Stop")
Expand Down

0 comments on commit 2b4e657

Please sign in to comment.