Conversation
| self.run_and_validate(clients.driver_iboot.set_outlet, kwargs=kw) | ||
| for outlet in state.outlets: | ||
| set_outlet_state(outlet, False) | ||
| with ensure_spin_stop(hwp_state, self.log): |
There was a problem hiding this comment.
I think this doesn't need to be a context manager -- I think this is the equivalent of just running an undecorated ensure_spin_stop(...).
A context manager would normally be used to express the following:
- allocate / obtain / lock some resource
- do some stuff that needs that resource
- free / release / unlock that resource
But here you're just using it to raise an error if some condition is not met prior to "do some stuff" -- there's no cleanup step.
| if action is None: | ||
| requested = state.__class__.__name__ | ||
| cur = self.control_state_machine.action | ||
| cur_state_type = cur.cur_state_info.state_type | ||
| return False, f"{requested} is rejected as {cur_state_type} is in progress." |
There was a problem hiding this comment.
These lines are repeated a bunch of times ... can you deduplicate it? E.g.
if action is None:
return False, self._rejected_action_message(state)
There was a problem hiding this comment.
There's actually a race condition here, though (state could go idle right before you generate the error message). It would be better to create this message inside the request_new_action function, where lock is held, and return message from there.
action, err_msg = self.control_state_machine.request_new_action(state)
if action is None:
return False, err_msg
|
Thanks for the suggestions @mhasself |
Description
Implemeted two safeties.
Modified request_new_actions not to abort action in progress by default. Only abort_action will abort it.
Added additional spin check for disable_driver_board and power_cycle_gripper.
Motivation and Context
This resolves #1105 and #1106
How Has This Been Tested?
Tested on satp3 on 2026/9/29
disable_driver_board fails when hwp is spinning and idle, due to spin check.
new action (disable_driver_board) is rejected when hwp is spinning up.
new action (disable_driver_board) is rejected when hwp is spinning down.
Checklist:
AI Usage Disclosure
Not used