Skip to content

feat(sim): dimsim as connection#1735

Open
paul-nechifor wants to merge 4 commits into
mainfrom
paul/feat/dimsim
Open

feat(sim): dimsim as connection#1735
paul-nechifor wants to merge 4 commits into
mainfrom
paul/feat/dimsim

Conversation

@paul-nechifor
Copy link
Copy Markdown
Contributor

@paul-nechifor paul-nechifor commented Apr 3, 2026

Problem

We need a light-er weight simulator.

Closes DIM-xxx

Solution

  • Add the DimSim simulator.
  • Add tests which use it.

Breaking Changes

The --simulation flag now takes a parameter: either mujoco or dimsim.

How to Test

Run the apt scene:

uv run dimos --simulation=dimsim run unitree-go2-agentic

Run the empty scene:

uv run dimos --dimsim-scene=empty --simulation=dimsim run unitree-go2-agentic

Run the dimsim tests:

uv run pytest -m dimsim

Contributor License Agreement

  • I have read and approved the CLA.

@paul-nechifor paul-nechifor marked this pull request as draft April 3, 2026 04:02
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 3, 2026

Greptile Summary

This PR introduces DimSim as a new lightweight simulator backend for the Unitree Go2 robot, alongside the MuJoCo simulator, by adding a DimSimConnection adapter, a DimSimProcess launcher (which auto-installs Deno and clones an external repo), a 900-line SceneClient WebSocket SDK for scene manipulation, and a suite of e2e tests. The --simulation CLI flag is changed from a boolean to a string (mujoco or dimsim), which is a breaking change for env-var users.

  • New DimSimConnection: Robot connection adapter wiring DimSim to the existing Go2ConnectionProtocol; currently several core streams (odom_stream, lidar_stream, video_stream) are unimplemented stubs, and move() never sends a cmd_vel command to the simulator.
  • New DimSimProcess / scene_client.py: Manages the DimSim subprocess and exposes a Python SDK for remote Three.js scene manipulation over WebSocket; thread-safety and lifecycle issues exist in both components.
  • Breaking simulation type change: GlobalConfig.simulation was changed from bool to str, silently breaking existing SIMULATION=true environment variable usage.

Confidence Score: 2/5

Not safe to merge: the DimSim backend is non-functional in several core areas that the e2e tests depend on.

The DimSimConnection adapter ships with move() returning True without publishing any cmd_vel command, and all three data streams (odom_stream, lidar_stream, video_stream) are silent Subjects that never receive data. The e2e walk-forward test will always time out because wait_until_odom_position listens to /odom LCM messages that _handle_odom never forwards to the Subject. The SceneClient recv loop can crash permanently on a late exec result after a timeout. Together these issues mean the primary tested feature cannot work end-to-end as written.

dimos/robot/unitree/dimsim_connection.py (move() stub, silent streams), dimos/simulation/dimsim/scene_client.py (_recv_loop crash, WS send race), dimos/simulation/dimsim/dimsim_process.py (personal fork URL, partial clone recovery, stop/log-reader race)

Important Files Changed

Filename Overview
dimos/robot/unitree/dimsim_connection.py New DimSim connection adapter: core streams (odom, lidar, video) are silent stubs, move() never sends cmd_vel, and functools.cache on instance methods causes memory leaks and incorrect cache_clear() scope.
dimos/simulation/dimsim/dimsim_process.py DimSim subprocess launcher: repo URL points to a personal fork, stop() closes stderr while log-reader thread iterates it, partial clone leaves repo in a broken state, ensure_playwright_chromium runs unconditionally on every start().
dimos/simulation/dimsim/scene_client.py SceneClient WebSocket SDK: _recv_loop crashes permanently on KeyError after exec() timeout, self._ws.send() races with stop(), {name} interpolated directly into JS error strings allowing injection, set_embodiment/set_agent_position lack null-check on self._ws.
dimos/simulation/dimsim/deno_utils.py Deno auto-installer: handles platform detection and safe atomic write; ensure_playwright_chromium runs unconditionally with no timeout.
dimos/e2e_tests/dim_sim_client.py Test helper: stop() unconditionally invokes the lazy self.client property which creates and connects a new SceneClient when _client is None, hanging teardown if DimSim isn't running.
dimos/core/global_config.py simulation field changed from bool to str; silently breaks SIMULATION=true/false env var users who will now get connection_type="true" and hit an assertion failure.
dimos/e2e_tests/test_dimsim_walk_forward.py E2e test that relies on odom_stream() (currently a silent stub) and move() (currently a no-op); the odom position assertion will never be satisfied.
dimos/msgs/sensor_msgs/CameraInfo.py New from_fov() and from_intrinsics() factory methods are clean and correct; simplifies camera info construction across all simulators.
dimos/robot/unitree/go2/connection.py Adds dimsim branch to make_connection() factory and refactors camera info construction to use new from_intrinsics(); straightforward change.

Reviews (19): Last reviewed commit: "remove 3.15" | Re-trigger Greptile

Comment thread dimos/robot/unitree/dimsim_connection.py Outdated
Comment thread dimos/robot/unitree/dimsim_connection.py Outdated
Comment thread dimos/robot/unitree/dimsim_connection.py Outdated
Comment thread dimos/robot/unitree/dimsim_connection.py Outdated
@paul-nechifor paul-nechifor force-pushed the paul/feat/dimsim branch 2 times, most recently from 9d01ca0 to d26e60d Compare April 20, 2026 21:50
@paul-nechifor paul-nechifor changed the title WIP: Just for reference feat(sim): dimsim as connection Apr 20, 2026
@paul-nechifor paul-nechifor force-pushed the paul/feat/dimsim branch 2 times, most recently from 6e02118 to 1aec40d Compare April 21, 2026 00:53
@paul-nechifor paul-nechifor marked this pull request as ready for review April 21, 2026 00:56
Comment thread dimos/robot/unitree/dimsim_connection.py
@paul-nechifor paul-nechifor force-pushed the paul/feat/dimsim branch 3 times, most recently from 7851b03 to 139e176 Compare April 23, 2026 21:47
Comment thread dimos/robot/unitree/dimsim_connection.py
Comment thread dimos/robot/unitree/dimsim_connection.py
Comment thread dimos/core/global_config.py
Comment thread dimos/simulation/dimsim/dimsim_process.py
Comment thread dimos/simulation/dimsim/dimsim_process.py
Comment thread dimos/simulation/dimsim/dimsim_process.py
@paul-nechifor paul-nechifor force-pushed the paul/feat/dimsim branch 3 times, most recently from 2f00cad to 96d8638 Compare May 2, 2026 00:35
Comment thread dimos/experimental/security_demo/security_module.py
Comment thread dimos/simulation/dimsim/dimsim_process.py
Comment thread dimos/e2e_tests/dim_sim_client.py
Comment thread dimos/e2e_tests/dim_sim_client.py
@paul-nechifor paul-nechifor changed the base branch from dev to main May 9, 2026 01:07
Comment thread dimos/simulation/dimsim/scene_client.py
@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

Comment thread dimos/e2e_tests/test_dimsim_spatial_memory.py
leshy
leshy previously approved these changes May 12, 2026
Copy link
Copy Markdown
Contributor

@leshy leshy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no notes on this apart from LCM, can fix in the followup, amazing!

mustafab0
mustafab0 previously approved these changes May 12, 2026
paul-nechifor and others added 2 commits May 13, 2026 00:42
Co-authored-by: Viswajit Nair <viswajitnair@gmail.com>
leshy
leshy previously approved these changes May 13, 2026
Comment thread dimos/simulation/dimsim/scene_client.py
leshy
leshy previously approved these changes May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants