| Crates.io | mecha10-nodes-simulation-bridge |
| lib.rs | mecha10-nodes-simulation-bridge |
| version | 0.1.25 |
| created_at | 2025-11-25 02:29:17.704477+00 |
| updated_at | 2026-01-01 02:53:32.72898+00 |
| description | Simulation bridge node that translates between Redis pub/sub and Godot RL Agents protocol |
| homepage | |
| repository | https://github.com/mecha-industries/mecha10 |
| max_upload_size | |
| id | 1949098 |
| size | 207,770 |
Package: mecha10-nodes-simulation-bridge
Binary: simulation-bridge
Purpose: Translate between Redis pub/sub (framework) and Godot RL Agents protocol (simulation)
The simulation bridge is the only component that talks to Godot directly. All other framework components communicate via Redis pub/sub, making the framework hardware-agnostic.
Architecture:
Framework Nodes → Redis ← Simulation Bridge → Godot
Not:
Framework Nodes → Godot ❌
RL Training → Godot ❌
| Topic | Message Type | Description |
|---|---|---|
robot/actuators/motor |
MotorCommand |
Motor commands (left, right velocity) |
sim/control/reset |
SimResetCommand |
Reset simulation environment |
sim/control/pause |
SimPauseCommand |
Pause/resume simulation |
sim/rl/request |
RLRequest |
Synchronous RL step request |
| Topic | Message Type | Description |
|---|---|---|
robot/sensors/imu |
ImuData |
IMU readings (accel, gyro, orientation) |
robot/sensors/encoders |
EncoderData |
Motor encoder positions |
robot/sensors/camera/rgb |
CameraImage |
RGB camera images (base64) |
sim/rl/response |
RLResponse |
Synchronous RL step response |
# Start simulation bridge
cargo run -p mecha10-nodes-simulation-bridge
# Or use binary name
cargo run --bin simulation-bridge
# Redis connection (default: redis://localhost:6379)
export REDIS_URL="redis://localhost:6379"
# Godot RL Agents URL (default: ws://localhost:11008)
export GODOT_URL="ws://localhost:11008"
mecha10 dev)The simulation bridge can be integrated into the framework development workflow:
# In the future, mecha10 dev will support:
# Press 's' to start simulation bridge + Godot
For RL training, start the bridge first, then Godot, then the training script:
# Terminal 1: Start simulation bridge
cargo run -p mecha10-nodes-simulation-bridge
# Terminal 2: Start Godot simulation
mecha10 sim run --env basic_arena
# Terminal 3: Start RL training (uses Redis)
cd packages/taskrunner
./scripts/run.sh --type=TRAIN --environment_map=basic_arena
pub struct MotorCommand {
pub left: f32, // Left motor velocity (-1.0 to 1.0)
pub right: f32, // Right motor velocity (-1.0 to 1.0)
pub timestamp: u64,
}
pub struct ImuData {
pub linear_acceleration: [f32; 3], // m/s^2
pub angular_velocity: [f32; 3], // rad/s
pub orientation: [f32; 4], // quaternion (w, x, y, z)
pub timestamp: u64,
}
pub struct EncoderData {
pub left: f32, // Left motor encoder position (radians)
pub right: f32, // Right motor encoder position (radians)
pub timestamp: u64,
}
pub struct RLRequest {
pub correlation_id: String, // UUID for matching request/response
pub action: Vec<f32>, // Action vector
}
pub struct RLResponse {
pub correlation_id: String,
pub observation: Vec<f32>,
pub reward: f32,
pub done: bool,
pub info: HashMap<String, String>,
}
The bridge runs three concurrent tasks:
The bridge implements the godot-rl-agents WebSocket protocol:
1. Client → Server: Handshake { major_version, minor_version }
2. Server → Client: EnvInfo { n_agents, action_space, obs_space }
3. Client → Server: ResetEnv
4. Server → Client: Reset { obs }
5. Loop:
- Client → Server: Action { action }
- Server → Client: Step { reward, done, obs }
6. Client → Server: Close
All messages are JSON sent as WebSocket text frames:
{
"type": "handshake",
"major_version": "1",
"minor_version": "0"
}
cargo build -p mecha10-nodes-simulation-bridge
# Run tests
cargo test -p mecha10-nodes-simulation-bridge
# Run with logging
RUST_LOG=debug cargo run -p mecha10-nodes-simulation-bridge
error - Errors onlywarn - Warnings and errorsinfo - General info (default)debug - Detailed debuggingtrace - Very verboseError: Failed to connect to Godot
Solution:
GODOT_URL environment variableError: Failed to connect to Redis
Solution:
redis-server)REDIS_URL environment variableIssue: Bridge runs but no data appears on Redis topics
Solution:
robot/actuators/motorRUST_LOG=debugError: Unexpected message during handshake
Solution:
When using mecha10 init, the simulation bridge is automatically included:
{
"robot": "my-robot",
"nodes": [
{
"name": "simulation-bridge",
"package": "mecha10-nodes-simulation-bridge",
"enabled": true,
"placement": "local"
}
]
}
my-robot/
├── nodes/
│ └── simulation-bridge/ # Copied from monorepo
│ ├── Cargo.toml
│ └── src/
│ ├── main.rs
│ ├── bridge.rs
│ ├── godot_client.rs
│ └── topics.rs
└── Cargo.toml
Add bridge nodes for other simulators:
gazebo-bridge - ROS/Gazebo Classicisaac-sim-bridge - NVIDIA Isaac Simmujoco-bridge - MuJoCo physics engineAll would use the same Redis interface.
robot/sensors/camera/rgb and robot/sensors/camera/depthrobot/sensors/lidarRun some nodes on real hardware, some in simulation:
cargo run -p my-robot-motor --features target-robot # Real hardware
cargo run -p simulation-bridge # Simulated sensors
MIT