Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 2.43 KB

File metadata and controls

59 lines (45 loc) · 2.43 KB

Python MuJoCo sim ↔ WARP

A MuJoCo simulation (Franka Panda + a conveyor belt) wired to WARP shared-memory topics through the zero_schema Python bindings.

Topics

Direction Topic Type Meaning
publish robot/joint_states JointStateArray 7 arm joints: position / velocity / accel
subscribe robot/joint_commands JointStateArray position targets → actuators
publish camera/image Image downward belt camera, RGB
subscribe belt/cmd_vel Twist linear.x = belt speed (m/s)

The belt carries a few red boxes (kinematic mocap bodies) under the camera; the speed is settable live on belt/cmd_vel.

Setup

Needs the sibling ../warp and ../zero-schema checkouts. pixi install builds the editable zero-schema extension against this env's Python (3.12, so PyO3 0.23 builds).

pixi install

Run

pixi run warpd          # terminal 1 — the WARP daemon (start first)
pixi run sim            # terminal 2 — sim + interactive viewer
# or, no GUI:
pixi run sim-headless

# drive it (terminal 3):
pixi run python sim/set_belt.py 0.3
pixi run python sim/send_command.py 0.0 -0.6 0.0 -2.0 0.0 1.6 0.8
pixi run python sim/view_camera.py          # confirms frames + counts red pixels

Notes / gotchas

  • macOS viewer: the interactive viewer must run under mjpython (the sim task already does). Headless (--headless) runs under plain python.
  • Linux headless rendering: set MUJOCO_GL=egl (or osmesa) so the offscreen camera renderer can get a GL context.
  • Image SHM size: Image.data has the FHD capacity (~6.2 MB) regardless of the rendered resolution, so each shared-memory slot is ~6.2 MB. That's fine on macOS, but if creating the camera/image topic ever fails for memory reasons, shrink the FHD tier in ../zero-schema/schemas/sizes.warp (then pixi run gen over there) or add a smaller image type.
  • The sim must be started after warpd; Node.connect blocks with back-off and errors out if the daemon isn't reachable.

Legacy

src/main.rs is the original Rust (mujoco-rs) sim and is unchanged (pixi run run / pixi run build). The Python sim above is the current path.