From 37da9992baff4dc6d389c1a0cf58ff5d18f6a97e Mon Sep 17 00:00:00 2001 From: JobvAlewijk Date: Sat, 17 Jan 2026 14:02:34 +0100 Subject: [PATCH] feat: added face detection and communication with RI ref: N25B-397 --- .../communication/ri_communication_agent.py | 3 ++- .../agents/perception/face_rec_agent.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/control_backend/agents/communication/ri_communication_agent.py b/src/control_backend/agents/communication/ri_communication_agent.py index 9aaf0db..8e845e5 100644 --- a/src/control_backend/agents/communication/ri_communication_agent.py +++ b/src/control_backend/agents/communication/ri_communication_agent.py @@ -38,7 +38,7 @@ class RICommunicationAgent(BaseAgent): def __init__( self, name: str, - address=settings.zmq_settings.ri_command_address, + address=settings.zmq_settings.ri_communication_address, bind=False, ): super().__init__(name) @@ -202,6 +202,7 @@ class RICommunicationAgent(BaseAgent): vad_agent = VADAgent(audio_in_address=addr, audio_in_bind=bind) await vad_agent.start() case "face": + self.logger.warn("yup we here") face_agent = FacePerceptionAgent( settings.agent_settings.face_agent_name, address=addr, diff --git a/src/control_backend/agents/perception/face_rec_agent.py b/src/control_backend/agents/perception/face_rec_agent.py index 1369aa6..af20199 100644 --- a/src/control_backend/agents/perception/face_rec_agent.py +++ b/src/control_backend/agents/perception/face_rec_agent.py @@ -1,5 +1,9 @@ import asyncio +import zmq +import zmq.asyncio as azmq +from zmq.asyncio import Context + from control_backend.agents import BaseAgent @@ -12,17 +16,27 @@ class FacePerceptionAgent(BaseAgent): def __init__(self, name: str): super().__init__(name) self._last_face_state: bool | None = None + self._req_socket: azmq.Socket | None = None async def setup(self): self.logger.info("Starting FacePerceptionAgent") + + if self._req_socket is None: + self._req_socket = Context.instance().socket(zmq.REQ) + self._req_socket.connect("tcp://localhost:5559") + self.add_behavior(self._poll_loop()) async def _poll_loop(self): poll_interval = 1.0 + if self._req_socket is None: + self.logger.warn("REQ socket not initialized before poll loop") + while self._running: + if self._req_socket is None: + self.logger.debug("REQ socket not initialized in poll loop") try: - # Ask RICommunicationAgent (via main socket) await self._req_socket.send_json({"endpoint": "face", "data": {}}) response = await asyncio.wait_for(