Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds flags for ACU checking to hwp supervisor, along with tests #802

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

jlashner
Copy link
Collaborator

@jlashner jlashner commented Dec 16, 2024

Description

Motivation and Context

This adds gripper-state monitoring to the HWP monitor process, and adds the following flags to the HWP state which can be checked by the ACU:

  • gripper_state which can be "cold", "warm", "ungripped", or "unknown"
  • is_spinning boolean

How Has This Been Tested?

Along with these changes, I am building out the HWP emulator into a set of integration tests that test the behavior of these flags and other operations.

This has been tested with HWP and ACU hardware on satp1.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@jlashner jlashner marked this pull request as ready for review December 17, 2024 22:27
@jlashner
Copy link
Collaborator Author

jlashner commented Jan 3, 2025

@BrianJKoopman Ended up getting the tests to work properly! Turns out I missed a shutdown call for one of the device_emulators in the hwp emulator. Adding that makes tests clean up correctly, so I reverted the misc changes I made to test the github workflow.

This contains the same update to the HWP supervisor as #805, so if you'd rather just review and merge this one we can close the other one. Thanks!

Copy link
Member

@BrianJKoopman BrianJKoopman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, awesome to see all the tests come together for the supervisor agent. Mostly small documentation related comments. The SIGKILL workaround for getting the tests to run does mean code coverage doesn't get reported, which is unfortunate. It's makes it a bit challenging to understand what really gets tested.

Comment on lines -224 to +232
time.sleep(1)
# time.sleep(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why drop this? (I kind of forget why it was there, probably to give things a second to wrap up. But if it's not needed anymore, perhaps just remove altogether?)

Comment on lines +120 to +128
class GripperState:
instance_id: str
limit_warm_grip_state: List[bool] = field(default_factory=lambda: [False, False, False])
limit_cold_grip_state: List[bool] = field(default_factory=lambda: [False, False, False])
emg: List[bool] = field(default_factory=lambda: [False, False, False])
brake: List[bool] = field(default_factory=lambda: [False, False, False])
grip_state: Literal['cold', 'warm', 'ungripped', 'unknown'] = 'unknown'
last_updated: Optional[float] = None
gripper_max_time_since_update: float = 60.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use a docstring to describe the class and its attributes. On initial look I don't know what emg is, for instance.

self.is_spinning = None
elif now - self.pid_last_updated > self.pid_max_time_since_update:
self.is_spinning = None
elif self.pid_current_freq > self.pid_current_tolerance:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pid_current_tolerance was a bit confusing to me. Perhaps pid_freq_tolerance would be better?

@@ -1283,8 +1400,13 @@ def get_client(id):
gripper=get_client(self.args.hwp_gripper_id),
)

def query_hwp_state(self, session, params) -> Tuple[bool, str]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a docstring.


ops = self.hwp_state.update(test_mode=test_mode)
session.data['monitored_sessions'] = ops
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to this change, I think the documented session.data structure might be slightly out of date. The keys now seem to be 'temperature', 'encoder', 'pmx', 'pid', and 'ups'. Can you confirm and update the docstring?

Comment on lines +73 to +75
cold_limit_pos = 13.0 # mm
warm_limit_pos = 10.0 # mm
limit_tolerance = 1.0 # mm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make these constants all caps, per PEP8.

@@ -45,6 +47,7 @@ def test_scpi_psu_init_psu(wait_for_crossbar, gpib_emu, run_agent, client):

@pytest.mark.integtest
def test_scpi_psu_init_psu_acq_mode(wait_for_crossbar, gpib_emu, run_agent_acq, client):
time.sleep(2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment for why this is needed.

Comment on lines +34 to +36
# don't send SIGINT if we've already sent SIGKILL
if not runner._timedout:
runner.proc.send_signal(signal.SIGKILL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This SIGKILL interrupts the ability for testing coverage to get reported. With this I get no coverage on the HWP PID agent, but if I remove it I see 95% coverage. Is this just for quicker clean up, or are the tests in CI relying on it to function properly? It runs fine on my system without it (with the kill here turned to an interrupt.) This isn't true for the supervisor test, though it has the same coverage reporting issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants