Skip to content

Commit 3e98063

Browse files
committed
updates for compatibility with mujoco 3.0.0
1 parent edfc2d3 commit 3e98063

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

mujoco_viewer/callbacks.py

+28-11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import yaml
66
from threading import Lock
77

8+
MUJOCO_VERSION=tuple(map(int, mujoco.__version__.split('.')))
89

910
class Callbacks:
1011
def __init__(self, hide_menus):
@@ -254,18 +255,34 @@ def _mouse_button_callback(self, window, button, act, mods):
254255
rely = (self.viewport.height - y) / height
255256
selpnt = np.zeros((3, 1), dtype=np.float64)
256257
selgeom = np.zeros((1, 1), dtype=np.int32)
258+
selflex = np.zeros((1, 1), dtype=np.int32)
257259
selskin = np.zeros((1, 1), dtype=np.int32)
258-
selbody = mujoco.mjv_select(
259-
self.model,
260-
self.data,
261-
self.vopt,
262-
aspectratio,
263-
relx,
264-
rely,
265-
self.scn,
266-
selpnt,
267-
selgeom,
268-
selskin)
260+
261+
if MUJOCO_VERSION>=(3,0,0):
262+
selbody = mujoco.mjv_select(
263+
self.model,
264+
self.data,
265+
self.vopt,
266+
aspectratio,
267+
relx,
268+
rely,
269+
self.scn,
270+
selpnt,
271+
selgeom,
272+
selflex,
273+
selskin)
274+
else:
275+
selbody = mujoco.mjv_select(
276+
self.model,
277+
self.data,
278+
self.vopt,
279+
aspectratio,
280+
relx,
281+
rely,
282+
self.scn,
283+
selpnt,
284+
selgeom,
285+
selskin)
269286

270287
# set lookat point, start tracking is requested
271288
if selmode == 2 or selmode == 3:

mujoco_viewer/mujoco_viewer.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import yaml
77
from .callbacks import Callbacks
88

9+
MUJOCO_VERSION=tuple(map(int, mujoco.__version__.split('.')))
910

1011
class MujocoViewer(Callbacks):
1112
def __init__(
@@ -317,9 +318,16 @@ def add_overlay(gridpos, text1, text2):
317318
add_overlay(
318319
bottomleft, "FPS", "%d%s" %
319320
(1 / self._time_per_render, ""))
320-
add_overlay(
321-
bottomleft, "Solver iterations", str(
322-
self.data.solver_iter + 1))
321+
322+
if MUJOCO_VERSION>=(3,0,0):
323+
add_overlay(
324+
bottomleft, "Max solver iters", str(
325+
max(self.data.solver_niter) + 1))
326+
else:
327+
add_overlay(
328+
bottomleft, "Solver iterations", str(
329+
self.data.solver_iter + 1))
330+
323331
add_overlay(
324332
bottomleft, "Step", str(
325333
round(

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
from setuptools import find_packages, setup
44

5-
VERSION = '0.1.3'
5+
VERSION = '0.1.4'
66

77
INSTALL_REQUIRES = (
88
['mujoco >= 2.1.5',

0 commit comments

Comments
 (0)