feat: cb can communicate face with ri
ref: N25B-397
This commit is contained in:
@@ -268,6 +268,30 @@ class RICommunicationAgent(BaseAgent):
|
||||
if self.pub_socket is not None:
|
||||
await self.pub_socket.send_multipart([topic, data])
|
||||
await asyncio.sleep(settings.behaviour_settings.sleep_s)
|
||||
case "face":
|
||||
# Ask the RI for current face status
|
||||
request = {"endpoint": "face", "data": {}}
|
||||
try:
|
||||
assert self._req_socket is not None
|
||||
await self._req_socket.send_json(request)
|
||||
response = await asyncio.wait_for(
|
||||
self._req_socket.recv_json(), timeout=2.0
|
||||
)
|
||||
|
||||
# Expect response: {"endpoint": "face", "data": True/False}
|
||||
face_status = response.get("data", False)
|
||||
|
||||
topic = b"face"
|
||||
data = json.dumps(face_status).encode()
|
||||
|
||||
if self.pub_socket is not None:
|
||||
await self.pub_socket.send_multipart([topic, data])
|
||||
|
||||
self.logger.debug(f"Face status: {face_status}")
|
||||
|
||||
except Exception as e:
|
||||
self.logger.warning(f"Failed to get face status: {e}")
|
||||
|
||||
case _:
|
||||
self.logger.debug(
|
||||
"Received message with topic different than ping, while ping expected."
|
||||
|
||||
Reference in New Issue
Block a user