feat: add MujocoCamera module for sim-based perception#1694
feat: add MujocoCamera module for sim-based perception#1694ruthwikdasyam wants to merge 23 commits intodevfrom
Conversation
Greptile SummaryThis PR adds Key findings:
Confidence Score: 4/5Safe to merge once the set_engine() / camera-registration bug is fixed; all other findings are P2 style or robustness improvements. One confirmed P1 bug: using set_engine() leaves the camera never registered with the engine, so the advertised alternative initialization path produces no frames. The primary registry-based path (via address) works correctly. Fixing the P1 before merge is recommended. dimos/simulation/manipulators/camera.py — set_engine() + start() interaction needs the camera-config registration fix. Important Files Changed
Sequence DiagramsequenceDiagram
participant BP as Blueprint
participant Adapter as SimMujocoAdapter
participant Camera as MujocoCamera
participant Registry as engine registry
participant Engine as MujocoEngine (sim thread)
BP->>Adapter: connect()
Adapter->>Registry: get_or_create_engine(path, headless)
Registry-->>Adapter: engine (new)
Adapter->>Engine: engine.connect() → starts sim thread
BP->>Camera: start()
Camera->>Registry: get_or_create_engine(path, cameras=[CameraConfig])
Registry->>Engine: merge CameraConfig into _camera_configs (via _camera_lock)
Registry-->>Camera: engine (existing, shared)
loop sim tick (sim thread)
Engine->>Engine: _init_new_cameras() → create Renderer
Engine->>Engine: _render_cameras() → write CameraFrame
end
Camera->>Engine: read_camera(name) → CameraFrame
Camera->>Camera: publish color_image, depth_image, TF
Reviews (2): Last reviewed commit: "xarm7 updated mujoco env" | Re-trigger Greptile |
Problem
Sim-based manipulation requires a camera for perception
This blocks testing and developing the full perception, planning, execution pipeline in simulation
Closes DIM-733
Solution
MujocoCameraa drop-in replacement forRealSenseCamerathat renders RGB + depth from a named camera in the MuJoCo sim loop.get_or_create_engine()keyed by resolved MJCF path lets the sim adapter and camera independently resolve the same engine without explicit wiringsim_manip_interface.pybounding_box_dimensionscached property before pickling (was missing, could cause stale cache after unpickling)Sequence[str]→list[str]inRobotModelConfig.tf_extra_linksfor Pydantic v2 compatibilityBreaking Changes
None
Important to Note: -
SimMujocoAdapternow uses the engine registry - two adapters pointing to the same MJCF share state (previously each got an independent engine). This is intentional for the camera sharing use case.How to Test
Contributor License Agreement
Note:
Added rerun in sim blueprint for a reason to view rgb and depth camera views
Can remove later, if not a need
Object detection is not great, should be improved later (if any optimzes needed for sim-cam)