Spaces:
Sleeping
Sleeping
File size: 10,492 Bytes
8aedc84 51f51c3 8aedc84 1e7b565 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 8aedc84 51f51c3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
---
title: RobotHub TransportServer
emoji: ๐ค
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 8000
suggested_hardware: cpu-upgrade
suggested_storage: small
short_description: Real-time robotics control and video streaming platform
tags:
- robotics
- control
- websocket
- fastapi
- svelte
- real-time
- video-streaming
- transport-server
- robothub
pinned: true
fullWidth: true
---
# ๐ค RobotHub TransportServer
A high-performance, real-time communication platform for robotics control and video streaming. Built for multi-tenant environments with WebSocket and WebRTC technologies.
## ๐ Overview
RobotHub TransportServer enables real-time, bidirectional communication between robotics systems, cameras, and control interfaces. It provides a unified platform for:
- **Real-time robot joint control** via WebSocket connections
- **Live video streaming** via WebRTC technology
- **Multi-workspace isolation** for secure multi-tenant deployments
- **Producer/Consumer architecture** for scalable robotics applications
- **Cross-platform client libraries** (JavaScript/TypeScript and Python)
## ๐๏ธ Architecture
### Core Components
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ RobotHub TransportServer โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ REST API โ ๐ WebSocket โ ๐น WebRTC โ
โ - Room management โ - Real-time control โ - Video โ
โ - Workspace control โ - Joint updates โ - Streamingโ
โ - Status & health โ - State sync โ - P2P conn โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Multi-Workspace & Room Management โ
โ workspace_1/ workspace_2/ workspace_n/ โ
โ โโโ robotics_room_1 โโโ robotics_room_1 โโโ ... โ
โ โโโ robotics_room_2 โโโ video_room_1 โ โ
โ โโโ video_room_1 โโโ video_room_2 โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
### Producer/Consumer Pattern
**Robotics Control:**
- **Producer**: Sends joint commands and control signals
- **Consumer**: Receives commands and executes robot movements
**Video Streaming:**
- **Producer**: Streams camera feeds or screen content
- **Consumer**: Receives and displays video streams
## ๐ ๏ธ Key Features
### โ
Real-time Robotics Control
- Joint-level robot control with normalized values
- Emergency stop mechanisms
- State synchronization between multiple clients
- Support for 6-DOF robotic arms (extensible)
### โ
WebRTC Video Streaming
- Low-latency video streaming
- Multiple camera support
- Screen sharing capabilities
- Automatic quality adaptation
### โ
Multi-Workspace Architecture
- Complete isolation between workspaces
- UUID-based workspace identification
- Scalable room management within workspaces
### โ
Cross-Platform Clients
- **JavaScript/TypeScript**: Browser and Node.js support
- **Python**: AsyncIO-based client for robotics applications
- Consistent API across all platforms
### โ
Production Ready
- Docker containerization
- Health monitoring endpoints
- Comprehensive logging
- Error handling and recovery
## ๐ Quick Start
### Using Docker (Recommended)
```bash
# Clone the repository
git clone https://github.com/julien-blanchon/RobotHub-TransportServer
cd RobotHub-TransportServer
# Build and run with Docker
docker build -t robothub-transport-server .
docker run -p 8000:8000 robothub-transport-server
```
### Development Setup
```bash
# Install Python dependencies
cd server
uv venv
source .venv/bin/activate
uv sync
uv pip install -e .
# Start the server
uv run launch_with_ui.py
# The server will be available at:
# - API: http://localhost:8000/api
# - Demo UI: http://localhost:8000
```
## ๐ Client Libraries
### JavaScript/TypeScript
```bash
cd client/js
bun install
bun run build
```
```typescript
import { robotics, video } from '@robothub/transport-server-client';
// Robotics control
const producer = new robotics.RoboticsProducer('http://localhost:8000');
await producer.connect(workspaceId, roomId);
await producer.sendJointUpdate([
{ name: 'joint_1', value: 45.0 },
{ name: 'joint_2', value: -30.0 }
]);
// Video streaming
const videoProducer = new video.VideoProducer('http://localhost:8000');
await videoProducer.connect(workspaceId, roomId);
await videoProducer.startCamera();
```
### Python
```bash
cd client/python
uv venv
source .venv/bin/activate
uv sync
uv pip install -e .
```
```python
import asyncio
from transport_server_client import RoboticsProducer
from transport_server_client.video import VideoProducer
async def main():
# Robotics control
producer = RoboticsProducer('http://localhost:8000')
await producer.connect(workspace_id, room_id)
await producer.send_joint_update([
{'name': 'joint_1', 'value': 45.0},
{'name': 'joint_2', 'value': -30.0}
])
# Video streaming
video_producer = VideoProducer('http://localhost:8000')
await video_producer.connect(workspace_id, room_id)
await video_producer.start_camera()
asyncio.run(main())
```
## ๐ฎ Interactive Demo
The included demo application showcases all features:
```bash
cd demo
bun install
bun run dev
```
Visit `http://localhost:5173` to access:
- **Workspace Management**: Create and manage isolated environments
- **Robotics Control**: Real-time robot arm control interface
- **Video Streaming**: Camera and screen sharing demos
- **Multi-room Support**: Manage multiple concurrent sessions
## ๐ง API Reference
### REST Endpoints
#### Workspaces & Rooms
```
GET /robotics/workspaces/{workspace_id}/rooms
POST /robotics/workspaces/{workspace_id}/rooms
DELETE /robotics/workspaces/{workspace_id}/rooms/{room_id}
GET /robotics/workspaces/{workspace_id}/rooms/{room_id}/state
GET /video/workspaces/{workspace_id}/rooms
POST /video/workspaces/{workspace_id}/rooms
DELETE /video/workspaces/{workspace_id}/rooms/{room_id}
```
#### WebSocket Connections
```
WS /robotics/workspaces/{workspace_id}/rooms/{room_id}/ws
WS /video/workspaces/{workspace_id}/rooms/{room_id}/ws
```
### Message Types
#### Robotics Messages
- `joint_update`: Send/receive joint position commands
- `state_sync`: Synchronize complete robot state
- `emergency_stop`: Emergency stop signal
- `heartbeat`: Connection health monitoring
#### Video Messages
- `stream_started`: Video stream initiated
- `stream_stopped`: Video stream ended
- `webrtc_offer/answer/ice`: WebRTC signaling
- `video_config_update`: Stream configuration changes
## ๐ Integration Examples
### ML/AI Robotics Pipeline
```python
# Example: AI model controlling robot via TransportServer
import asyncio
from transport_server_client import RoboticsProducer
from transport_server_client.video import VideoConsumer
class AIRobotController:
def __init__(self, server_url, workspace_id):
self.robot_producer = RoboticsProducer(server_url)
self.camera_consumer = VideoConsumer(server_url)
self.workspace_id = workspace_id
async def start_control_loop(self):
# Connect to robot control room
await self.robot_producer.connect(self.workspace_id, 'robot_control')
# Connect to camera feed
await self.camera_consumer.connect(self.workspace_id, 'camera_feed')
# Set up frame processing
self.camera_consumer.on_frame_update(self.process_frame)
async def process_frame(self, frame_data):
# AI inference on camera frame
joint_commands = await self.ai_model.predict(frame_data)
# Send robot commands
await self.robot_producer.send_joint_update(joint_commands)
```
### Multi-Robot Coordination
```typescript
// Example: Coordinating multiple robots
import { robotics } from '@robothub/transport-server-client';
class MultiRobotCoordinator {
private robots: Map<string, robotics.RoboticsProducer> = new Map();
async addRobot(robotId: string, workspaceId: string, roomId: string) {
const producer = new robotics.RoboticsProducer();
await producer.connect(workspaceId, roomId);
this.robots.set(robotId, producer);
}
async coordinatedMovement(positions: Map<string, JointUpdate[]>) {
// Send synchronized commands to all robots
const promises = Array.from(positions.entries()).map(([robotId, joints]) => {
const producer = this.robots.get(robotId);
return producer?.sendJointUpdate(joints);
});
await Promise.all(promises);
}
}
```
## ๐ Project Structure
```
RobotHub-TransportServer/
โโโ server/ # FastAPI backend server
โ โโโ src/
โ โ โโโ robotics/ # Robotics control logic
โ โ โโโ video/ # Video streaming logic
โ โ โโโ api.py # Main API routes
โ โโโ launch_with_ui.py # Server launcher
โโโ client/
โ โโโ js/ # JavaScript/TypeScript client
โ โโโ python/ # Python client library
โโโ demo/ # SvelteKit demo application
โโโ Dockerfile # Container configuration
โโโ README.md
```
## ๐ข Deployment
### Production Docker Deployment
```bash
# Build production image
docker build -t robothub-transport-server .
# Run with custom configuration
docker run -d \
--name robothub-transport-server \
-p 8000:8000 \
-e LOG_LEVEL=info \
robothub-transport-server
```
### Development Setup
```bash
# Clone repository
git clone https://github.com/julien-blanchon/RobotHub-TransportServer
cd RobotHub-TransportServer
# Server development
cd server
uv venv && source .venv/bin/activate
uv sync
# Client development
cd client/js
bun install
# Demo development
cd demo
bun install
```
|