Skip to content

rappphg/Nursie

Repository files navigation

Nursie

ROS 2 bridge (Jazzy)

The backend includes a ROS 2 → WebSocket bridge that streams topic updates to clients.

  • WebSocket server: ws://localhost:8765
  • Default topics: /mouvement, /vibration

To run the backend with ROS enabled:

  • cd backend && ./run_with_ros.sh

If ROS is not sourced, the bridge will start but rclpy imports will fail.

Run everything (frontend + backend + ROS bridge + mmWave UART)

Use the repo-level runner:

  • ./run_all.sh start
  • ./run_all.sh status
  • ./run_all.sh stop

To set the ngrok URL, create a repo-level .env and set NGROK_URL:

echo 'NGROK_URL=https://uncompiled-ernestine-subtemperate.ngrok-free.dev' > .env

To enable the mmWave UART reader, set at least MMWAVE_DATA_PORT:

  • MMWAVE_DATA_PORT=/dev/ttyUSB1 MMWAVE_CLI_PORT=/dev/ttyUSB0 MMWAVE_CFG=3D_People_Tracking/chirp_configs/ODS_6m_default.cfg ./run_all.sh start

Viewer UART pour TI mmWave (IWR6843 / IWR6843ISK-ODS) — démo "Vital Signs".

Le script vitals_uart_viewer.py lit le port DATA UART (flux binaire TLV) et affiche en temps réel :

  • breathRate (BPM)
  • heartRate (BPM)
  • états : CONNECTED/DISCONNECTED, SYNCING/STREAMING, PERSON_DETECTED/NO_PERSON + compteur FRAME_ERROR

Il peut aussi (optionnel) envoyer un fichier .cfg au démarrage sur le port CLI UART.

Installation

Python 3 recommandé.

  • Dépendance obligatoire :
    • pyserial
  • Dépendances optionnelles (uniquement si --plot) :
    • numpy, matplotlib

Installation :

pip install pyserial
pip install numpy matplotlib

Commandes

Lancer en lecture DATA uniquement

Si le radar est déjà configuré et en train de streamer (config envoyée par un autre outil) :

python3 vitals_uart_viewer.py --data-port /dev/ttyUSB1

Envoyer un .cfg puis écouter DATA (recommandé)

python3 vitals_uart_viewer.py \
	--cli-port /dev/ttyUSB0 \
	--cfg /path/to/profile.cfg \
	--data-port /dev/ttyUSB1

Notes :

  • Si le .cfg ne contient pas sensorStart, le script envoie automatiquement sensorStart après le fichier.
  • Si --cfg est fourni sans --cli-port, le script tente d’inférer le port CLI depuis --data-port (ex: /dev/ttyUSB1/dev/ttyUSB0, COM6COM5).

Afficher les courbes temps réel

python3 vitals_uart_viewer.py --data-port /dev/ttyUSB1 --plot

Modifier les baudrates

python3 vitals_uart_viewer.py --data-port /dev/ttyUSB1 --data-baud 921600
python3 vitals_uart_viewer.py --cli-port /dev/ttyUSB0 --cli-baud 115200 --cfg profile.cfg --data-port /dev/ttyUSB1

Référence des options CLI

--data-port        (obligatoire) Port série DATA (trames TLV binaires)
--data-baud        Baudrate DATA (défaut: 921600)

--cli-port         (optionnel) Port série CLI (envoi de configuration)
--cli-baud         Baudrate CLI (défaut: 115200)
--cfg              (optionnel) Chemin vers le .cfg à envoyer sur le CLI
--quiet-cli        Ne pas afficher les réponses CLI pendant l’envoi

--plot             Affiche les waveforms coeur/respiration (matplotlib)
--dashboard-hz     Taux de rafraîchissement console (défaut: 10 Hz)
--max-buffer-bytes Taille max du buffer RX (défaut: 2097152)

Dépannage

  • DISCONNECTED : vérifier le bon port (/dev/ttyUSB*, /dev/ttyACM*, COM*) et les droits.
    • Sur Linux, ajouter l’utilisateur au groupe dialout puis se reconnecter.
  • SYNCING qui ne passe jamais en STREAMING :
    • vérifier que le radar est démarré (sensorStart) et que le bon port est utilisé pour DATA (souvent le plus “haut”, ex: ttyUSB1).
    • vérifier le --data-baud (souvent 921600).
  • FRAME_ERROR qui augmente vite :
    • mauvais port/baudrate, ou câble/USB instable.
    • attention à ne pas ouvrir le même port avec plusieurs programmes en parallèle.

Notes techniques (format)

  • Resynchronisation par scan du magic word : 02 01 04 03 06 05 08 07
  • Header : '<Q8I' (40 bytes)
  • TLV header : '<II' (8 bytes)
  • Vital Signs TLV : tlvType=0x410, payload '<2H33f' (136 bytes) <<<<<<< HEAD See .env.example for a complete configuration template.

Escalation phone calls (Twilio)

When ElevenLabs (agent) confirms an emergency (event distress_voice) or when a resident does not respond (event no_response), the backend can place an outbound phone call to the nurse using Twilio.

Required env vars:

  • TWILIO_ACCOUNT_SID
  • Auth (choose one):
    • TWILIO_AUTH_TOKEN
    • TWILIO_API_KEY_SID + TWILIO_API_KEY_SECRET
  • TWILIO_FROM_NUMBER (E.164, e.g. +15551234567)
  • NURSIE_NURSE_PHONE_E164 (one or more E.164 numbers, comma-separated)
  • NURSIE_PUBLIC_BASE_URL (publicly reachable base URL so Twilio can fetch TwiML)

TwiML endpoint:

  • GET/POST /twilio/twiml?alert_id=...&resident_id=...

Note: Twilio must be able to reach NURSIE_PUBLIC_BASE_URL (use a tunnel like ngrok for local dev).

Start verbal check webhook (kick off ElevenLabs)

On fall_detected, the backend can optionally POST to a fast webhook to start the verbal check in ElevenLabs (Webflow/Make/Zapier/serverless).

Env vars:

  • NURSIE_VERBAL_CHECK_WEBHOOK_URL (your webhook endpoint)
  • NURSIE_VERBAL_CHECK_WEBHOOK_TOKEN (optional Bearer token)
  • NURSIE_PUBLIC_BASE_URL (used to build callback_url for /webhooks/elevenlabs) ======= The backend for Nursie AI, built with Flask, MongoDB, and Gemini 1.5 Flash.

Setup

  1. Environment Variables: Copy backend/.env.example to backend/.env and fill in your keys:

    cp backend/.env.example backend/.env
  2. Install Dependencies:

    cd backend
    pip install -r requirements.txt
  3. Run Locally:

    python backend/app.py

API Routes

  • POST /events: Push sensor events.
  • GET /alerts: List active triage alerts.
  • GET /alerts/stream: SSE stream for real-time alerts.
  • POST /webhooks/agent-transcript: Webhook for frontend/device transcripts.
  • POST /webhooks/elevenlabs: Webhook for ElevenLabs conversational AI.
  • GET /voice/next: Fetch and generate the next voice message in queue.

Tech Stack

  • Framework: Flask
  • Database: MongoDB
  • AI: Google Gemini (Triage), ElevenLabs (TTS)
  • Real-time: Server-Sent Events (SSE)

572d3e95f6e0caa1a7e3b3d6d358f5292f998e35

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •