Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 16, 2024
1 parent f753ebe commit 285d353
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
9 changes: 4 additions & 5 deletions socs/agents/hwp_supervisor/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ class HWPClients:
@dataclass
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])
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
Expand All @@ -137,7 +137,6 @@ def _verify_update_time(self) -> None:
elif time.time() - self.last_updated > self.gripper_max_time_since_update:
self.grip_state = 'unknown'


def update(self) -> None:
op = get_op_data(self.instance_id, 'monitor_state', test_mode=False)
if op['status'] != 'ok':
Expand Down
4 changes: 2 additions & 2 deletions socs/testing/device_emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ def create_tcp_relay(self, port):
self._type = 'tcp'
self._sock_bound = False
self._bkg_read = threading.Thread(name='background',
target=self._read_socket,
kwargs={'port': port})
target=self._read_socket,
kwargs={'port': port})
self._bkg_read.start()

# wait for socket to bind properly before returning
Expand Down
14 changes: 7 additions & 7 deletions socs/testing/hwp_emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

import argparse
import logging
import pickle as pkl
import socket
import threading
import time
from dataclasses import dataclass, field, asdict
from typing import List, Optional, Tuple, Dict, Any
import socket
from ocs.ocs_twisted import Pacemaker
import pickle as pkl
import traceback as tb
from dataclasses import asdict, dataclass, field
from typing import Any, Dict, List, Optional, Tuple

import numpy as np
import pytest
from ocs.ocs_twisted import Pacemaker

from socs.agents.hwp_pid.drivers.pid_controller import PID
from socs.testing import device_emulator
import numpy as np


def hex_str_to_dec(hex_value, decimal=3):
Expand Down Expand Up @@ -59,7 +59,7 @@ class PCUState:
)


### Gripper state information, taken from sobonelib: https://github.com/simonsobs/sobonelib/blob/main/hwp_gripper/control/state_monitor.py
# Gripper state information, taken from sobonelib: https://github.com/simonsobs/sobonelib/blob/main/hwp_gripper/control/state_monitor.py


cold_limit_pos = 13.0 # mm
Expand Down
15 changes: 8 additions & 7 deletions tests/integration/test_hwp_supervisor_agent_integration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from socs.testing.hwp_emulator import HWPEmulator
import pytest
import coverage.data
from pprint import pprint
from typing import Generator
from ocs.testing import _AgentRunner, create_client_fixture

import coverage.data
import pytest
from integration.util import docker_compose_file # noqa: F401
from integration.util import create_crossbar_fixture
from pprint import pprint
from ocs.testing import _AgentRunner, create_client_fixture

from socs.testing.hwp_emulator import HWPEmulator

log_dir = "./logs/"

Expand Down Expand Up @@ -180,12 +181,12 @@ def supervisor_agent(
def test_supervisor_grip(hwp_em, supervisor_agent, sup_client):
state = sup_client.monitor.status().session["data"]["hwp_state"]
pprint(state)
assert state["gripper"]["grip_state"] == "ungripped"
assert state["gripper"]["grip_state"] == "ungripped"
pprint(hwp_em.state.gripper.actuators[0])
res = sup_client.grip_hwp()
state = sup_client.monitor.status().session["data"]["hwp_state"]
pprint(hwp_em.state.gripper.actuators[0])
assert state["gripper"]["grip_state"] == "warm"
assert state["gripper"]["grip_state"] == "warm"
pprint(res.session['data'])
assert False

Expand Down

0 comments on commit 285d353

Please sign in to comment.