Skip to content

Commit ab86d33

Browse files
Update mujoco-py to MuJoCo 2.1 (#640)
* Update to MuJoCo 2.1.0 - Remove license-related parts of the build process. - Correctly parse the comments for array sizes based on nmocap. - Explicitly exclude a few structs from generated wrappers, where the structs don't have a corresponding typedef. Still TODO: Update README.md once a new package is pushed to PyPi. * Remove MuJoCo key docs from README.md. As of version 2.1.0, MuJoCo doesn't require an activation key.
1 parent 4830435 commit ab86d33

File tree

15 files changed

+198
-181
lines changed

15 files changed

+198
-181
lines changed

Dockerfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ RUN apt-get update -q \
1414
libosmesa6-dev \
1515
software-properties-common \
1616
net-tools \
17-
unzip \
1817
vim \
1918
virtualenv \
2019
wget \
@@ -38,12 +37,11 @@ RUN curl -o /usr/local/bin/patchelf https://s3-us-west-2.amazonaws.com/openai-sc
3837
ENV LANG C.UTF-8
3938

4039
RUN mkdir -p /root/.mujoco \
41-
&& wget https://www.roboti.us/download/mujoco200_linux.zip -O mujoco.zip \
42-
&& unzip mujoco.zip -d /root/.mujoco \
43-
&& mv /root/.mujoco/mujoco200_linux /root/.mujoco/mujoco200 \
44-
&& rm mujoco.zip
45-
COPY ./mjkey.txt /root/.mujoco/
46-
ENV LD_LIBRARY_PATH /root/.mujoco/mujoco200/bin:${LD_LIBRARY_PATH}
40+
&& wget https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz -O mujoco.tar.gz \
41+
&& tar -xf mujoco.tar.gz -C /root/.mujoco \
42+
&& rm mujoco.tar.gz
43+
44+
ENV LD_LIBRARY_PATH /root/.mujoco/mujoco210/bin:${LD_LIBRARY_PATH}
4745
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib64:${LD_LIBRARY_PATH}
4846

4947
COPY vendor/Xdummy /usr/local/bin/Xdummy

Makefile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
SHELL := /bin/bash
22
.PHONY: all clean build test mount_shell shell upload check-env
33

4-
MUJOCO_LICENSE_PATH ?= ~/.mujoco/mjkey.txt
54
VERSION := `cd mujoco_py; python -c "from version import get_version;print(get_version())"; cd ..`
65
PYTHON_VERSION := "36"
76
DOCKER_NAME := quay.io/openai/mujoco_py:$(USER)_$(VERSION)
@@ -24,9 +23,8 @@ clean:
2423
rm -rf dist
2524
rm -rf build
2625

27-
build: check-license
28-
cp $(MUJOCO_LICENSE_PATH) mjkey.txt
29-
docker build -t $(DOCKER_NAME) . || rm mjkey.txt && rm mjkey.txt
26+
build:
27+
docker build -t $(DOCKER_NAME) .
3028

3129
push:
3230
docker push $(DOCKER_NAME)
@@ -82,8 +80,3 @@ generate_cpu_so:
8280
docker run -it --name $(UUID) $(DOCKER_NAME) bash -c "make clean;python -c 'import mujoco_py'"
8381
docker cp $(UUID):/mujoco_py/mujoco_py/generated/cymj_$(VERSION)_$(PYTHON_VERSION)_linuxcpuextensionbuilder.so mujoco_py/generated/
8482

85-
86-
check-license:
87-
ifeq ("","$(wildcard $(MUJOCO_LICENSE_PATH))")
88-
$(error "License key not found at location $(MUJOCO_LICENSE_PATH). Use MUJOCO_LICENSE_PATH to specify its path")
89-
endif

README.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[MuJoCo](http://mujoco.org/) is a physics engine for detailed, efficient rigid body simulations with contacts.
66
`mujoco-py` allows using MuJoCo from Python 3.
77

8-
This library has been updated to be compatible with MuJoCo version 2.0 released on 10/1/2018.
8+
This library has been updated to be compatible with MuJoCo version 2.1 released on 2021-10-18.
99

1010

1111
## Synopsis
@@ -24,31 +24,26 @@ The following platforms are DEPRECATED and unsupported:
2424

2525
### Install MuJoCo
2626

27-
1. Obtain a 30-day free trial on the [MuJoCo website](https://www.roboti.us/license.html)
28-
or free license if you are a student.
29-
The license key will arrive in an email with your username and password.
30-
2. Download the MuJoCo version 2.0 binaries for
31-
[Linux](https://www.roboti.us/download/mujoco200_linux.zip) or
32-
[OSX](https://www.roboti.us/download/mujoco200_macos.zip).
33-
3. Unzip the downloaded `mujoco200` directory into `~/.mujoco/mujoco200`,
34-
and place your license key (the `mjkey.txt` file from your email)
35-
at `~/.mujoco/mjkey.txt`.
27+
1. Download the MuJoCo version 2.1 binaries for
28+
[Linux](https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz) or
29+
[OSX](https://mujoco.org/download/mujoco210-macos-x86_64.tar.gz).
30+
1. Extract the downloaded `mujoco210` directory into `~/.mujoco/mujoco210`.
3631

37-
If you want to specify a nonstandard location for the key and package,
38-
use the env variables `MUJOCO_PY_MJKEY_PATH` and `MUJOCO_PY_MUJOCO_PATH`.
32+
If you want to specify a nonstandard location for the package,
33+
use the env variable `MUJOCO_PY_MUJOCO_PATH`.
3934

4035
### Install and use `mujoco-py`
4136
To include `mujoco-py` in your own package, add it to your requirements like so:
4237
```
43-
mujoco-py<2.1,>=2.0
38+
mujoco-py<2.2,>=2.1
4439
```
4540
To play with `mujoco-py` interactively, follow these steps:
4641
```
47-
$ pip3 install -U 'mujoco-py<2.1,>=2.0'
42+
$ pip3 install -U 'mujoco-py<2.2,>=2.1'
4843
$ python3
4944
import mujoco_py
5045
import os
51-
mj_path, _ = mujoco_py.utils.discover_mujoco()
46+
mj_path = mujoco_py.utils.discover_mujoco()
5247
xml_path = os.path.join(mj_path, 'model', 'humanoid.xml')
5348
model = mujoco_py.load_model_from_path(xml_path)
5449
sim = mujoco_py.MjSim(model)
@@ -97,7 +92,7 @@ export CPPFLAGS="-I/usr/local/opt/llvm/include"
9792

9893
```bash
9994
# Make sure your python environment is activated
100-
pip install -U 'mujoco-py<2.1,>=2.0'
95+
pip install -U 'mujoco-py<2.2,>=2.1'
10196
```
10297

10398
### Missing GLFW
@@ -112,7 +107,7 @@ MuJoCo ships with its own copy of this library, which can be used during install
112107

113108
Add the path to the mujoco bin directory to your dynamic loader:
114109

115-
LD_LIBRARY_PATH=$HOME/.mujoco/mujoco200/bin pip install mujoco-py
110+
LD_LIBRARY_PATH=$HOME/.mujoco/mujoco210/bin pip install mujoco-py
116111

117112
This is particularly useful on Ubuntu 14.04, which does not have a GLFW package.
118113

mujoco_py/__init__.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/usr/bin/env python
2-
import os
32
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
43
from mujoco_py.generated import const
54
from mujoco_py.mjrenderpool import MjRenderPool
65
from mujoco_py.mjviewer import MjViewer, MjViewerBasic
76
from mujoco_py.version import __version__, get_version
8-
import mujoco_py
97

108
load_model_from_path = cymj.load_model_from_path
119
load_model_from_xml = cymj.load_model_from_xml
@@ -29,10 +27,3 @@
2927
'ignore_mujoco_warnings', 'const', "functions",
3028
"__version__", "get_version"]
3129

32-
33-
# Print out a warning if we can't find the key.
34-
# this is nicer than failing activation, which we can not do in python.
35-
# The mujoco library exits the process forcibly, in a way we can't try/catch.
36-
mujoco_py.builder.find_key()
37-
if not os.environ.get('MUJOCO_PY_SKIP_ACTIVATE'):
38-
mujoco_py.builder.activate()

mujoco_py/builder.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from Cython.Distutils.old_build_ext import old_build_ext as build_ext
2020
from cffi import FFI
2121

22-
from mujoco_py.utils import discover_mujoco, MISSING_KEY_MESSAGE
22+
from mujoco_py.utils import discover_mujoco
2323
from mujoco_py.version import get_version
2424

2525

@@ -172,8 +172,8 @@ def manually_link_libraries(mujoco_path, raw_cext_dll_path):
172172

173173
# Fix the rpath of the generated library -- i lost the Stackoverflow
174174
# reference here
175-
from_mujoco_path = '@executable_path/libmujoco200.dylib'
176-
to_mujoco_path = '%s/libmujoco200.dylib' % mj_bin_path
175+
from_mujoco_path = '@executable_path/libmujoco210.dylib'
176+
to_mujoco_path = '%s/libmujoco210.dylib' % mj_bin_path
177177
subprocess.check_call(['install_name_tool',
178178
'-change',
179179
from_mujoco_path,
@@ -208,7 +208,7 @@ def __init__(self, mujoco_path):
208208
join(mujoco_path, 'include'),
209209
np.get_include(),
210210
],
211-
libraries=['mujoco200'],
211+
libraries=['mujoco210'],
212212
library_dirs=[join(mujoco_path, 'bin')],
213213
extra_compile_args=[
214214
'-fopenmp', # needed for OpenMP
@@ -272,7 +272,7 @@ def __init__(self, mujoco_path):
272272
def _build_impl(self):
273273
so_file_path = super()._build_impl()
274274
# Removes absolute paths to libraries. Allows for dynamic loading.
275-
fix_shared_library(so_file_path, 'libmujoco200.so', 'libmujoco200.so')
275+
fix_shared_library(so_file_path, 'libmujoco210.so', 'libmujoco210.so')
276276
fix_shared_library(so_file_path, 'libglewosmesa.so', 'libglewosmesa.so')
277277
return so_file_path
278278

@@ -291,7 +291,7 @@ def _build_impl(self):
291291
so_file_path = super()._build_impl()
292292
fix_shared_library(so_file_path, 'libOpenGL.so', 'libOpenGL.so.0')
293293
fix_shared_library(so_file_path, 'libEGL.so', 'libEGL.so.1')
294-
fix_shared_library(so_file_path, 'libmujoco200.so', 'libmujoco200.so')
294+
fix_shared_library(so_file_path, 'libmujoco210.so', 'libmujoco210.so')
295295
fix_shared_library(so_file_path, 'libglewegl.so', 'libglewegl.so')
296296
return so_file_path
297297

@@ -478,7 +478,7 @@ def build_callback_fn(function_string, userdata_names=[]):
478478
ffibuilder.set_source(name, source_string,
479479
include_dirs=[join(mujoco_path, 'include')],
480480
library_dirs=[join(mujoco_path, 'bin')],
481-
libraries=['mujoco200'])
481+
libraries=['mujoco210'])
482482
# Catch compilation exceptions so we can cleanup partial files in that case
483483
try:
484484
library_path = ffibuilder.compile(verbose=True)
@@ -495,18 +495,7 @@ def build_callback_fn(function_string, userdata_names=[]):
495495
return module.lib.__fun
496496

497497

498-
def find_key():
499-
''' Try to find the key file, if missing, print out a big message '''
500-
if exists(key_path):
501-
return
502-
print(MISSING_KEY_MESSAGE.format(key_path), file=sys.stderr)
503-
504-
505-
def activate():
506-
functions.mj_activate(key_path)
507-
508-
509-
mujoco_path, key_path = discover_mujoco()
498+
mujoco_path = discover_mujoco()
510499
cymj = load_cython_ext(mujoco_path)
511500

512501

mujoco_py/generated/const.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
MINIMP = 0.0001 # minimum constraint impedance
99
MAXIMP = 0.9999 # maximum constraint impedance
1010
MAXCONPAIR = 50.0 # maximum number of contacts per geom pair
11-
MAXVFS = 200.0 # maximum number of files in virtual file system
12-
MAXVFSNAME = 100.0 # maximum filename size in virtual file system
11+
MAXVFS = 2000.0 # maximum number of files in virtual file system
12+
MAXVFSNAME = 1000.0 # maximum filename size in virtual file system
1313
NEQDATA = 7.0 # number of eq_data fields
1414
NDYN = 10.0 # number of actuator dynamics parameters
1515
NGAIN = 10.0 # number of actuator gain parameters
@@ -26,11 +26,12 @@
2626
MAXTEXTURE = 1000.0 # maximum number of textures
2727
MAXUISECT = 10.0 # maximum number of sections
2828
MAXUIITEM = 80.0 # maximum number of items per section
29-
MAXUITEXT = 500.0 # maximum number of chars in edittext and other
29+
MAXUITEXT = 300.0 # maximum number of chars in edittext and other
3030
MAXUINAME = 40.0 # maximum number of chars in name
31-
MAXUIMULTI = 20.0 # maximum number of radio/select items in group
32-
MAXUIEDIT = 5.0 # maximum number of elements in edit list
33-
MAXUIRECT = 15.0 # maximum number of rectangles
31+
MAXUIMULTI = 35.0 # maximum number of radio/select items in group
32+
MAXUIEDIT = 7.0 # maximum number of elements in edit list
33+
MAXUIRECT = 25.0 # maximum number of rectangles
34+
SEPCLOSED = 1000.0 # closed state of adjustable separator
3435
KEY_ESCAPE = 256.0 #
3536
KEY_ENTER = 257.0 #
3637
KEY_TAB = 258.0 #
@@ -449,10 +450,11 @@
449450
ITEM_CHECKINT = 3
450451
ITEM_CHECKBYTE = 4
451452
ITEM_RADIO = 5
452-
ITEM_SELECT = 6
453-
ITEM_SLIDERINT = 7
454-
ITEM_SLIDERNUM = 8
455-
ITEM_EDITINT = 9
456-
ITEM_EDITNUM = 10
457-
ITEM_EDITTXT = 11
458-
NITEM = 12
453+
ITEM_RADIOLINE = 6
454+
ITEM_SELECT = 7
455+
ITEM_SLIDERINT = 8
456+
ITEM_SLIDERNUM = 9
457+
ITEM_EDITINT = 10
458+
ITEM_EDITNUM = 11
459+
ITEM_EDITTXT = 12
460+
NITEM = 13

0 commit comments

Comments
 (0)