blanchon's picture
Update
1e7b565
metadata
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)

# 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

# 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

cd client/js
bun install
bun run build
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

cd client/python
uv venv
source .venv/bin/activate
uv sync
uv pip install -e .
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:

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

# 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

// 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

# 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

# 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