tools/sim: get MetaDrive simulator working on macOS#38261
Open
hamiikalhor wants to merge 2 commits into
Open
Conversation
Contributor
Process replay diff reportReplays driving segments through this PR and compares the behavior to master. ✅ 0 changed, 66 passed, 0 errors |
Re-enables the MetaDrive bridge on macOS (issue commaai#33207): - pyproject: re-enable the metadrive-simulator dependency (still excluded on the comma device, aarch64 Linux, via the existing marker) - manager: only pre-import process modules under the "fork" start method. With "spawn" (the default on macOS) every child re-imports anyway, and pre-importing the UI (which initializes Cocoa) in the manager process breaks startup on macOS. - tools/sim/camerad: stamp the camera EOF with time.monotonic_ns() so it shares the simulated sensors' logMonoTime clock domain. Otherwise locationd rejects all camera odometry and openpilot never engages. Road rendering also requires the macOS terrain shader fix in commaai/metadrive (texture2D -> texture). Verified on macOS (Apple Silicon): tools/sim/tests/test_metadrive_bridge.py passes (offscreen rendering via CocoaGraphicsPipe, openpilot engages and drives the loop with no failure states).
b3a6d85 to
3cf1936
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #33207. Re-enables the MetaDrive simulator on macOS with feature parity to Linux;
tools/sim/tests/test_metadrive_bridge.pynow passes on macOS (Apple Silicon).Changes
metadrive-simulatordependency. Still excluded on the comma device (aarch64 Linux) via the existing marker.forkstart method. macOS defaults tospawn, where every child re-imports anyway and pre-importing the UI (which initializes Cocoa) in the manager process breaks startup.time.monotonic_ns()so it shares the simulated sensors'logMonoTimeclock domain. Otherwise locationd rejects all camera odometry on its timing check and openpilot never engages.simulator_drivingjob (disabled while the sim wasn't ready).Dependency
Road rendering on macOS also needs the terrain shader fix in commaai/metadrive (
texture2D→texture, rejected by Apple's GLSL at#version 330): commaai/metadrive#15. This PR points at@minimal, so that needs to land first.Verification
On macOS (Apple Silicon):
openpilot engages and drives the loop with no failure states; offscreen rendering via
CocoaGraphicsPipe(no xvfb needed on macOS). The skipped item is the abstractTestSimBridgeBase, same as on Linux.Notes
modeld stays on the default
CPUbackend on macOS (unchanged). Metal currently fails the model build's determinism check andCPU:LLVMneeds libLLVM that isn't part of the macOS setup, so the GPU/LLVM path is left as a follow-up.