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_command_address,
|
address=settings.zmq_settings.ri_communication_address,
|
||||||
bind=False,
|
bind=False,
|
||||||
):
|
):
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
@@ -202,6 +202,7 @@ class RICommunicationAgent(BaseAgent):
|
|||||||
vad_agent = VADAgent(audio_in_address=addr, audio_in_bind=bind)
|
vad_agent = VADAgent(audio_in_address=addr, audio_in_bind=bind)
|
||||||
await vad_agent.start()
|
await vad_agent.start()
|
||||||
case "face":
|
case "face":
|
||||||
|
self.logger.warn("yup we here")
|
||||||
face_agent = FacePerceptionAgent(
|
face_agent = FacePerceptionAgent(
|
||||||
settings.agent_settings.face_agent_name,
|
settings.agent_settings.face_agent_name,
|
||||||
address=addr,
|
address=addr,
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
import zmq
|
||||||
|
import zmq.asyncio as azmq
|
||||||
|
from zmq.asyncio import Context
|
||||||
|
|
||||||
from control_backend.agents import BaseAgent
|
from control_backend.agents import BaseAgent
|
||||||
|
|
||||||
|
|
||||||
@@ -12,17 +16,27 @@ class FacePerceptionAgent(BaseAgent):
|
|||||||
def __init__(self, name: str):
|
def __init__(self, name: str):
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
self._last_face_state: bool | None = None
|
self._last_face_state: bool | None = None
|
||||||
|
self._req_socket: azmq.Socket | None = None
|
||||||
|
|
||||||
async def setup(self):
|
async def setup(self):
|
||||||
self.logger.info("Starting FacePerceptionAgent")
|
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())
|
self.add_behavior(self._poll_loop())
|
||||||
|
|
||||||
async def _poll_loop(self):
|
async def _poll_loop(self):
|
||||||
poll_interval = 1.0
|
poll_interval = 1.0
|
||||||
|
|
||||||
|
if self._req_socket is None:
|
||||||
|
self.logger.warn("REQ socket not initialized before poll loop")
|
||||||
|
|
||||||
while self._running:
|
while self._running:
|
||||||
|
if self._req_socket is None:
|
||||||
|
self.logger.debug("REQ socket not initialized in poll loop")
|
||||||
try:
|
try:
|
||||||
# Ask RICommunicationAgent (via main socket)
|
|
||||||
await self._req_socket.send_json({"endpoint": "face", "data": {}})
|
await self._req_socket.send_json({"endpoint": "face", "data": {}})
|
||||||
|
|
||||||
response = await asyncio.wait_for(
|
response = await asyncio.wait_for(
|
||||||
|
|||||||
Reference in New Issue
Block a user