commaai / openpilot

openpilot is an operating system for robotics. Currently, it upgrades the driver assistance system in 275+ supported cars.
https://comma.ai/openpilot
MIT License
49.82k stars 9.08k forks source link

Failed to run metadrive simulation bridge #33917

Closed dvorak0 closed 2 hours ago

dvorak0 commented 5 hours ago

Describe the bug

For the master version, I do a fresh set up in devcontainer, and run the ubuntu_setup.sh first.

All I do is to run run_bridge.py. The error is as follows:

(openpilot) batman ➜ /workspaces/openpilot (master) $ ./tools/sim/run_bridge.py 
Keyboard Commands:

  | key  |   functionality       |
  |------|-----------------------|
  |  1   | Cruise Resume / Accel |
  |  2   | Cruise Set    / Decel |
  |  3   | Cruise Cancel         |
  |  r   | Reset Simulation      |
  |  i   | Toggle Ignition       |
  |  q   | Exit all              |
  | wasd | Control manually      |

----------------------------------------------------------
---- Spawning Metadrive world, this might take awhile ----
----------------------------------------------------------
[INFO] Environment: MetaDriveEnv
[INFO] MetaDrive version: 0.4.2.3
[INFO] Sensors: [lidar: Lidar(), side_detector: SideDetector(), lane_line_detector: LaneLineDetector(), rgb_road: RGBCameraRoad(1928, 1208)]
[INFO] Render Mode: offscreen
[INFO] Horizon (Max steps per agent): None
[INFO] Assets version: 0.4.2.3
[INFO] Known Pipes: glxGraphicsPipe
[INFO] Assets version: 0.4.2.3
failed to create drawable
libEGL warning: DRI3: Screen seems not DRI3 capable
libEGL warning: DRI2: failed to authenticate
libEGL warning: DRI3: Screen seems not DRI3 capable
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
libEGL warning: egl: failed to create dri2 screen
[INFO] Known Pipes: glxGraphicsPipe
manager:  <direct.filter.FilterManager.FilterManager object at 0x7f802dd06c00>
tonemap_quad None
Process metadrive process:
Traceback (most recent call last):
  File "/home/batman/.local/share/uv/python/cpython-3.12.0-linux-x86_64-gnu/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/home/batman/.local/share/uv/python/cpython-3.12.0-linux-x86_64-gnu/lib/python3.12/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/workspaces/openpilot/openpilot/tools/sim/bridge/metadrive/metadrive_process.py", line 83, in metadrive_process
    lane_idx_prev = reset()
                    ^^^^^^^
  File "/workspaces/openpilot/openpilot/tools/sim/bridge/metadrive/metadrive_process.py", line 70, in reset
    env.reset()
  File "/workspaces/openpilot/.venv/lib/python3.12/site-packages/metadrive/envs/base_env.py", line 522, in reset
    self.lazy_init()  # it only works the first time when reset() is called to avoid the error when render
    ^^^^^^^^^^^^^^^^
  File "/workspaces/openpilot/.venv/lib/python3.12/site-packages/metadrive/envs/base_env.py", line 414, in lazy_init
    initialize_engine(self.config)
  File "/workspaces/openpilot/.venv/lib/python3.12/site-packages/metadrive/engine/engine_utils.py", line 38, in initialize_engine
    cls.singleton = cls(env_global_config)
                    ^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/openpilot/.venv/lib/python3.12/site-packages/metadrive/engine/base_engine.py", line 55, in __init__
    EngineCore.__init__(self, global_config)
  File "/workspaces/openpilot/.venv/lib/python3.12/site-packages/metadrive/engine/core/engine_core.py", line 297, in __init__
    self.pbrpipe = init(
                   ^^^^^
  File "/workspaces/openpilot/.venv/lib/python3.12/site-packages/metadrive/third_party/simplepbr/__init__.py", line 352, in init
    return Pipeline(**kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/workspaces/openpilot/.venv/lib/python3.12/site-packages/metadrive/third_party/simplepbr/__init__.py", line 142, in __init__
    self._setup_tonemapping()
  File "/workspaces/openpilot/.venv/lib/python3.12/site-packages/metadrive/third_party/simplepbr/__init__.py", line 289, in _setup_tonemapping
    self.tonemap_quad.set_shader(tonemap_shader)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'set_shader'

Could I get hints about how to deal with it?

OS Version

NixOS

openpilot version or commit

No response

Additional info

No response

maxime-desroches commented 2 hours ago

This is not a bug with openpilot, but with metadrive. I suggest you take this up to them.

Here 2 suggestions though:

  1. Don't use the devcontainer, try to run metadrive natively.
  2. I had to deactivate some of their PBR renderers when working on metadrive for macOS https://github.com/commaai/metadrive/commit/0dd67b8a924d65c5c263c63863c3e766850e0b66#diff-047fc9d618228e10801429884bbcc687fe4ebf69630e0c9d37e6b2fd5baab69cR297-R303 , maybe that's also your issue.