Skip to content

Commit

Permalink
fix the get_actuator_state logic
Browse files Browse the repository at this point in the history
  • Loading branch information
budzianowski committed Nov 24, 2024
1 parent 60ac285 commit 80cf1b9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pykos/pykos/services/actuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,22 @@ def configure_actuator(self, actuator_id: int, **kwargs: Dict[str, Any]) -> comm
request = actuator_pb2.ConfigureActuatorRequest(**config)
return self.stub.ConfigureActuator(request)

def get_actuators_state(self, actuator_ids: List[int]) -> List[common_pb2.ActionResult]:
def get_actuators_state(self, actuator_ids: List[int] = None) -> List[common_pb2.ActionResult]:
"""Get the state of multiple actuators.
Args:
actuator_ids: List of actuator IDs to query
actuator_ids: List of actuator IDs to query. If None, gets state of all actuators.
Returns:
List of ActuatorStateResponse objects containing the state information
"""
request = actuator_pb2.GetActuatorsStateRequest(actuator_ids=actuator_ids)
request = actuator_pb2.GetActuatorsStateRequest(actuator_ids=actuator_ids or [])
response = self.stub.GetActuatorsState(request)
return response.states
if actuator_ids is None:
return response.states

states = []
for state in response.states:
if state.actuator_id in actuator_ids:
states.append(state)
return states

0 comments on commit 80cf1b9

Please sign in to comment.