WebSocket backend for the Robocoop medical assistance robot. Bridges the robot hardware (via ROS/rosbridge) to the dashboard frontend.
- Connects to the robot via rosbridge (WebSocket → ROS topics)
- Reads battery voltage from
/battery, converts it to a percentage - Broadcasts real-time robot state to all connected dashboard clients
- Records audit events (robot connected/disconnected, battery low, emergency stop)
- Supports mock mode for frontend development without a physical robot
Dashboard (frontend)
│ WebSocket ws://host:8765
▼
app/server.py — lifecycle, signal handling
app/websocket_handler.py — client connections, message routing
app/backend_context.py — dependency container (single init point)
│
├── modules/robot/ — state store + telemetry pipeline
├── modules/audit/ — event logging + history
└── adapters/ — robot communication layer
│
├── mock_adapter.py — no-op, always connected (dev)
└── rosbridge_adapter.py — real robot via rosbridge WebSocket
│
└── rosbridge_client.py — pure WebSocket transport
│
rosbridge server (ws://robot:9090)
│
ROS topics (/battery, ...)
src/
robocoop_backend/
robocoop_backend/
app/ — server, websocket handler, contracts, DI context
adapters/ — robot adapter implementations + rosbridge client
modules/
robot/ — RobotState, RobotStateStore, TelemetryService
audit/ — AuditEvent, AuditService, sinks (console, file)
utils/ — Config loader (.env + YAML)
robocoop_bringup/
config/ — YAML config files per environment
launch/ — ROS2 launch files (future use)
.env — local environment variables (not committed)
.env.example — template for .env
Requirements: Python 3.11+
git clone <repo>
cd robot-back
python -m venv .venv # or python3
source .venv/bin/activate # macOS/Linux
# .venv\Scripts\activate # Windows
pip install -e src/robocoop_backendCopy the environment file and configure it:
cp .env.example .env.env defaults to ROBOCOOP_ENV=mock — no robot needed to start.
# Mock mode (no robot required)
ROBOCOOP_ENV=mock python -m robocoop_backend.app.server
# Real robot (rosbridge must be running on the robot)
ROBOCOOP_ENV=real python -m robocoop_backend.app.serverOr use the launch script:
bash run_backend.sh mock
bash run_backend.sh realServer starts on ws://0.0.0.0:8765.
Connect to ws://localhost:8765 with any WebSocket client (Postman, WebSocket King, wscat) and send:
{"type": "ping"}Expected response:
{"type": "pong"}On connection, the server automatically pushes the current robot state and the last 50 audit events. See
app/contracts.pyfor the full message reference.
ssh jetson@**.**.***.** # follow instructions and write [ Yes ] or press enter
jetson@**.**.***.**'s password : < password_value > docker ps ## get into this container name : < m3pro >
docker exec -it m3pro /bon/bash ## for write command ( display topic list and whatever )| Variable | Default | Description |
|---|---|---|
ROBOCOOP_ENV |
mock |
Which config to load: mock or real |
ROBOCOOP_CONFIG_DIR |
auto-detected | Path to the YAML config directory |
YAML config lives in src/robocoop_bringup/config/. Two files are loaded on startup:
common.params.yaml— shared across all environments{ROBOCOOP_ENV}.params.yaml— environment-specific overrides
See src/robocoop_bringup/config/README.md for details.
# Install test dependencies
pip install -e "src/robocoop_backend[test]"
# Run all tests (unit + integration)
pytest -m "not real" -v
# Unit tests only
pytest -m unit -v
# Integration tests only
pytest -m integration -v
# Real rosbridge tests (requires a live rosbridge server)
ROSBRIDGE_URL=ws://localhost:9090 pytest -m real -vTests live in src/robocoop_backend/robocoop_backend/tests/. CI runs automatically on push and pull requests via GitHub Actions (.github/workflows/ci.yml).