Test higher version of mujoco but failed, add hard version check in code

This commit is contained in:
wty-yy
2026-07-22 21:37:17 +08:00
parent 30643dfed8
commit c1b347c89f
3 changed files with 622 additions and 7 deletions

View File

@@ -8,14 +8,17 @@
@Desc : Run Robogauge Pipeline
'''
import os
import sys
# Headless solution for mujoco
# For GPU
# os.environ['MUJOCO_GL'] = 'egl'
# For CPU (Slow)
# os.environ['MUJOCO_GL'] = 'osmesa'
# With a graphical user interface (GUI)
os.environ['MUJOCO_GL'] = 'glfw'
# Select the rendering backend before importing MuJoCo. EGL provides an
# offscreen context on headless Linux, while GLFW is used by the GUI viewer.
# Keep an explicit MUJOCO_GL value so callers can override either default.
default_mujoco_gl = (
'egl'
if sys.platform.startswith('linux') and '--headless' in sys.argv
else 'glfw'
)
os.environ.setdefault('MUJOCO_GL', default_mujoco_gl)
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["MKL_NUM_THREADS"] = "1"

View File

@@ -30,7 +30,28 @@ from robogauge.tasks.simulator.sim_data import (
from robogauge.tasks.gauge.goal_data import VelocityGoal
class MujocoSimulator:
_MAX_MUJOCO_VERSION = (3, 3, 0)
@classmethod
def _require_supported_mujoco_version(cls):
version_string = getattr(mujoco, '__version__', '')
version_match = re.match(r'^(\d+)\.(\d+)\.(\d+)', version_string)
if version_match is None:
raise RuntimeError(
f"Unable to parse the installed MuJoCo version: "
f"{version_string!r}. RoboGauge requires mujoco<3.3.0."
)
installed_version = tuple(map(int, version_match.groups()))
if installed_version >= cls._MAX_MUJOCO_VERSION:
raise RuntimeError(
f"Unsupported MuJoCo version {version_string}. "
"RoboGauge evaluation requires mujoco<3.3.0 because "
"MuJoCo 3.3.0 and newer use different contact dynamics."
)
def __init__(self, sim_cfg: MujocoConfig):
self._require_supported_mujoco_version()
self.cfg = sim_cfg
self.terrain_xmls = None
self.robot_xml = None