Skip to content

Commit

Permalink
flake8 and bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jlashner committed Dec 16, 2024
1 parent 984a05c commit 79e0362
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
16 changes: 7 additions & 9 deletions socs/agents/hwp_supervisor/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,13 @@ def update_temp_state(self, test_mode=False):
if op['status'] != 'ok':
self.temp = None
self.temp_status = 'no_data'
return
return op

fields = op['data']['fields']
if self.temp_field not in fields:
self.temp = None
self.temp_status = 'no_data'
return
return op

self.temp = fields[self.temp_field]['T']

Expand Down Expand Up @@ -564,10 +564,10 @@ def update(self, test_mode=False) -> Dict[str, Any]:
now = time.time()
with self.lock:
ops = {
'temperature': self.update_temp_state(),
'encoder': self.update_enc_state(),
'pmx': self.update_pmx_state(),
'pid': self.update_pid_state(),
'temperature': self.update_temp_state(test_mode=test_mode),
'encoder': self.update_enc_state(test_mode=test_mode),
'pmx': self.update_pmx_state(test_mode=test_mode),
'pid': self.update_pid_state(test_mode=test_mode),
'ups': self.update_ups_state(),
}

Expand Down Expand Up @@ -1472,13 +1472,11 @@ def monitor(self, session, params) -> Tuple[bool, str]:
}
}

kw = {'test_mode': test_mode, 'log': self.log}

while session.status in ['starting', 'running']:
now = time.time()
session.data['timestamp'] = now

ops = self.hwp_state.update()
ops = self.hwp_state.update(test_mode = test_mode)
session.data['monitored_sessions'] = ops
session.data['hwp_state'] = asdict(self.hwp_state)

Expand Down
5 changes: 1 addition & 4 deletions socs/testing/hwp_emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
import time
import traceback as tb
from dataclasses import asdict, dataclass, field
from typing import Any, Dict, List, Optional, Tuple
from typing import 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
Expand Down Expand Up @@ -477,8 +476,6 @@ def raise_error():
return pkl.dumps({"result": False, "log": []})
elif (not state.is_cold) and new_pos >= warm_limit_pos:
state.actuators[act_idx].pos = warm_limit_pos
print("HEREEE")
print(state.actuators[act_idx])
return pkl.dumps({"result": False, "log": []})
else:
state.actuators[act_idx].pos = new_pos
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/test_hwp_supervisor_agent_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,8 @@ def test_supervisor_grip(hwp_em, supervisor_agent, sup_client) -> None:
state = get_hwp_state(sup_client)
pprint(state)
assert state["gripper"]["grip_state"] == "ungripped"
pprint(hwp_em.state.gripper.actuators[0])
res = sup_client.grip_hwp()
sup_client.grip_hwp()
state = get_hwp_state(sup_client)
pprint(hwp_em.state.gripper.actuators[0])
assert state["gripper"]["grip_state"] == "warm"


Expand Down

0 comments on commit 79e0362

Please sign in to comment.