feat: face recognition agent #53
@@ -38,7 +38,7 @@ class RICommunicationAgent(BaseAgent):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
address=settings.zmq_settings.ri_communication_address,
|
address=settings.zmq_settings.ri_command_address,
|
||||||
bind=False,
|
bind=False,
|
||||||
):
|
):
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
@@ -168,7 +168,7 @@ class RICommunicationAgent(BaseAgent):
|
|||||||
bind = port_data["bind"]
|
bind = port_data["bind"]
|
||||||
|
|
||||||
if not bind:
|
if not bind:
|
||||||
addr = f"tcp://{settings.ri_host}:{port}"
|
addr = f"tcp://localhost:{port}"
|
||||||
else:
|
else:
|
||||||
addr = f"tcp://*:{port}"
|
addr = f"tcp://*:{port}"
|
||||||
|
|
||||||
@@ -268,30 +268,6 @@ class RICommunicationAgent(BaseAgent):
|
|||||||
if self.pub_socket is not None:
|
if self.pub_socket is not None:
|
||||||
await self.pub_socket.send_multipart([topic, data])
|
await self.pub_socket.send_multipart([topic, data])
|
||||||
await asyncio.sleep(settings.behaviour_settings.sleep_s)
|
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 _:
|
case _:
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
"Received message with topic different than ping, while ping expected."
|
"Received message with topic different than ping, while ping expected."
|
||||||
|
|||||||
Reference in New Issue
Block a user