Gestures in the CB. #36

Merged
9828273 merged 16 commits from feat/cb2ri-gestures into dev 2025-12-16 09:24:26 +00:00
Showing only changes of commit db5504db20 - Show all commits

View File

@@ -3,9 +3,8 @@ import json
import logging
import zmq.asyncio
from fastapi import APIRouter, HTTPException, Request
from fastapi import APIRouter, Request
from fastapi.responses import StreamingResponse
from pydantic import ValidationError
from zmq.asyncio import Context, Socket
from control_backend.core.config import settings
@@ -28,18 +27,10 @@ async def receive_command_speech(command: SpeechCommand, request: Request):
:param command: The speech command payload.
:param request: The FastAPI request object.
"""
# Validate and retrieve data.
try:
validated = SpeechCommand.model_validate(command)
except ValidationError as e:
raise HTTPException(
status_code=422, detail=f"Payload is not valid SpeechCommand: {e}"
) from e
topic = b"command"
pub_socket: Socket = request.app.state.endpoints_pub_socket
await pub_socket.send_multipart([topic, validated.model_dump_json().encode()])
await pub_socket.send_multipart([topic, command.model_dump_json().encode()])
return {"status": "Speech command received"}
@@ -56,18 +47,10 @@ async def receive_command_gesture(command: GestureCommand, request: Request):
:param command: The speech command payload.
:param request: The FastAPI request object.
"""
# Validate and retrieve data.
try:
validated = GestureCommand.model_validate(command)
except ValidationError as e:
raise HTTPException(
status_code=422, detail=f"Payload is not valid GestureCommand: {e}"
) from e
topic = b"command"
pub_socket: Socket = request.app.state.endpoints_pub_socket
await pub_socket.send_multipart([topic, validated.model_dump_json().encode()])
await pub_socket.send_multipart([topic, command.model_dump_json().encode()])
return {"status": "Gesture command received"}