diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index bdf48913..00000000 --- a/.appveyor.yml +++ /dev/null @@ -1,38 +0,0 @@ -version: 1.0.{build} - -environment: - - global: - # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the - # /E:ON and /V:ON options are not enabled in the batch script intepreter - # See: http://stackoverflow.com/a/13751649/163740 - CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\continuous-integration\\appveyor\\run_with_env.cmd" - -platform: - - x64 - - -install: - - mkdir %userprofile%\.mujoco - - curl %MUJOCO_FOR_WINDOWS% -o %userprofile%\.mujoco\mjpro.tar.gz - - curl https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.bin.WIN64.zip -o %userprofile%\glfw.zip - - cd %userprofile%\.mujoco\ - - tar -zxvf mjpro.tar.gz - - echo "%PYTHON_VERSION% C:\Miniconda35-x64 %userprofile%" - - set PATH=C:\Miniconda35-x64;C:\Miniconda35-x64\Scripts;%PATH% - - conda config --set always_yes yes --set changeps1 no - - conda update -q conda - - conda info -a - - conda create -q -n test-environment python=3.6 numpy scipy - - activate test-environment - - SET PATH=%userprofile%\.mujoco\mjpro150\bin;%PATH%; - - cd C:\projects\mujoco-py - - pip install -r requirements.txt - - pip install -r requirements.dev.txt - -build: off - -test_script: - - pytest -s --verbose --durations=10 --instafail -m "not requires_rendering" - - diff --git a/.gitignore b/.gitignore index 1225da4b..0367db87 100755 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ cymj.c *.c *.so .python-version +/build diff --git a/Dockerfile b/Dockerfile index b06a046d..a600b46f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,11 +38,12 @@ RUN curl -o /usr/local/bin/patchelf https://s3-us-west-2.amazonaws.com/openai-sc ENV LANG C.UTF-8 RUN mkdir -p /root/.mujoco \ - && wget https://www.roboti.us/download/mjpro150_linux.zip -O mujoco.zip \ + && wget https://www.roboti.us/download/mujoco200_linux.zip -O mujoco.zip \ && unzip mujoco.zip -d /root/.mujoco \ + && mv /root/.mujoco/mujoco200_linux /root/.mujoco/mujoco200 \ && rm mujoco.zip COPY ./mjkey.txt /root/.mujoco/ -ENV LD_LIBRARY_PATH /root/.mujoco/mjpro150/bin:${LD_LIBRARY_PATH} +ENV LD_LIBRARY_PATH /root/.mujoco/mujoco200/bin:${LD_LIBRARY_PATH} ENV LD_LIBRARY_PATH /usr/local/nvidia/lib64:${LD_LIBRARY_PATH} COPY vendor/Xdummy /usr/local/bin/Xdummy diff --git a/Makefile b/Makefile index bb9405fb..7db7679a 100644 --- a/Makefile +++ b/Makefile @@ -65,8 +65,9 @@ cirra: # # Gather all *.so files. upload: - test -f ./mujoco_py/generated/cymj_$(VERSION)_$(PYTHON_VERSION)_linuxcpuextensionbuilder.so || exit -1 - test -f ./mujoco_py/generated/cymj_$(VERSION)_$(PYTHON_VERSION)_linuxgpuextensionbuilder.so || exit -1 + # Commented out for now, binary distributions seem not to work very well + # test -f ./mujoco_py/generated/cymj_$(VERSION)_$(PYTHON_VERSION)_linuxcpuextensionbuilder.so || exit -1 + # test -f ./mujoco_py/generated/cymj_$(VERSION)_$(PYTHON_VERSION)_linuxgpuextensionbuilder.so || exit -1 rm -rf dist python setup.py sdist twine upload dist/* diff --git a/README.md b/README.md index 61e91267..b70f599a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,11 @@ # mujoco-py [![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](https://openai.github.io/mujoco-py/build/html/index.html) [![Build Status](https://travis-ci.org/openai/mujoco-py.svg?branch=master)](https://travis-ci.org/openai/mujoco-py) -[MuJoCo](http://mujoco.org/) is a physics engine for detailed, efficient rigid body simulations with contacts. `mujoco-py` allows using MuJoCo from Python 3. +[MuJoCo](http://mujoco.org/) is a physics engine for detailed, efficient rigid body simulations with contacts. +`mujoco-py` allows using MuJoCo from Python 3. + +This library has been updated to be compatible with MuJoCo version 2.0 released on 10/1/2018. + ## Synopsis @@ -15,7 +19,7 @@ The following platforms are currently supported: The following platforms are DEPRECATED and unsupported: -- Windows support is DEPRECATED and will be removed soon. One known good past version is [1.50.1.68](https://github.com/openai/mujoco-py/blob/9ea9bb000d6b8551b99f9aa440862e0c7f7b4191/README.md#requirements). +- Windows support has been DEPRECATED and removed in [2.0.2.0]. One known good past version is [1.50.1.68](https://github.com/openai/mujoco-py/blob/9ea9bb000d6b8551b99f9aa440862e0c7f7b4191/README.md#requirements). - Python 2 has been DEPRECATED and removed in [1.50.1.0](https://github.com/openai/mujoco-py/releases/tag/1.50.1.0). Python 2 users can stay on the [`0.5` branch](https://github.com/openai/mujoco-py/tree/0.5). The latest release there is [`0.5.7`](https://github.com/openai/mujoco-py/releases/tag/0.5.7) which can be installed with `pip install mujoco-py==0.5.7`. ### Install MuJoCo @@ -23,25 +27,24 @@ The following platforms are DEPRECATED and unsupported: 1. Obtain a 30-day free trial on the [MuJoCo website](https://www.roboti.us/license.html) or free license if you are a student. The license key will arrive in an email with your username and password. -2. Download the MuJoCo version 1.50 binaries for - [Linux](https://www.roboti.us/download/mjpro150_linux.zip), - [OSX](https://www.roboti.us/download/mjpro150_osx.zip), or - [Windows](https://www.roboti.us/download/mjpro150_win64.zip). -3. Unzip the downloaded `mjpro150` directory into `~/.mujoco/mjpro150`, +2. Download the MuJoCo version 2.0 binaries for + [Linux](https://www.roboti.us/download/mujoco200_linux.zip) or + [OSX](https://www.roboti.us/download/mujoco200_macos.zip). +3. Unzip the downloaded `mujoco200` directory into `~/.mujoco/mujoco200`, and place your license key (the `mjkey.txt` file from your email) at `~/.mujoco/mjkey.txt`. If you want to specify a nonstandard location for the key and package, -use the env variables `MUJOCO_PY_MJKEY_PATH` and `MUJOCO_PY_MJPRO_PATH`. +use the env variables `MUJOCO_PY_MJKEY_PATH` and `MUJOCO_PY_MUJOCO_PATH`. ### Install and use `mujoco-py` To include `mujoco-py` in your own package, add it to your requirements like so: ``` -mujoco-py<1.50.2,>=1.50.1 +mujoco-py<2.1,>=2.0 ``` To play with `mujoco-py` interactively, follow these steps: ``` -$ pip3 install -U 'mujoco-py<1.50.2,>=1.50.1' +$ pip3 install -U 'mujoco-py<2.1,>=2.0' $ python3 import mujoco_py import os @@ -77,7 +80,7 @@ MuJoCo ships with its own copy of this library, which can be used during install Add the path to the mujoco bin directory to your dynamic loader: - LD_LIBRARY_PATH=$HOME/.mujoco/mjpro150/bin pip install mujoco-py + LD_LIBRARY_PATH=$HOME/.mujoco/mujoco200/bin pip install mujoco-py This is particularly useful on Ubuntu 14.04, which does not have a GLFW package. @@ -124,3 +127,4 @@ This is somewhat dependent on internal OpenAI infrastructure at the moment, but - Jonathan Ho - Peter Welinder - Wojciech Zaremba +- Jerry Tworek diff --git a/examples/mjvive.py b/examples/mjvive.py index 7dc63ddc..3db13c73 100644 --- a/examples/mjvive.py +++ b/examples/mjvive.py @@ -25,7 +25,7 @@ import numpy as np import OpenGL.GL as gl from mujoco_py import functions -from mujoco_py.builder import mjpro_path +from mujoco_py.builder import mujoco_path from mujoco_py.cymj import (MjRenderContext, MjSim, load_model_from_xml, PyMjrRect, PyMjvCamera) from mujoco_py.generated.const import (CAT_ALL, FB_OFFSCREEN, FONT_BIG, @@ -37,6 +37,7 @@ class HMD(): # anonymous object we can set fields on pass + window = None sim = None ctx = None @@ -156,7 +157,7 @@ def v_render(): if __name__ == '__main__': - filename = os.path.join(mjpro_path, 'model', 'humanoid.xml') + filename = os.path.join(mujoco_path, 'model', 'humanoid.xml') v_initPre() initMuJoCo(filename, hmd.width * 2, hmd.height) v_initPost() diff --git a/mujoco_py/builder.py b/mujoco_py/builder.py index d5b847b8..64f544c1 100644 --- a/mujoco_py/builder.py +++ b/mujoco_py/builder.py @@ -41,7 +41,7 @@ def get_nvidia_lib_dir(): return paths[-1] -def load_cython_ext(mjpro_path): +def load_cython_ext(mujoco_path): """ Loads the cymj Cython extension. This is safe to be called from multiple processes running on the same machine. @@ -62,7 +62,7 @@ def load_cython_ext(mjpro_path): The easy solution is to `import mujoco_py` _before_ `import glfw`. ''') - lib_path = os.path.join(mjpro_path, "bin") + lib_path = os.path.join(mujoco_path, "bin") if sys.platform == 'darwin': Builder = MacExtensionBuilder elif sys.platform == 'linux': @@ -81,7 +81,7 @@ def load_cython_ext(mjpro_path): else: raise RuntimeError("Unsupported platform %s" % sys.platform) - builder = Builder(mjpro_path) + builder = Builder(mujoco_path) cext_so_path = builder.get_so_file_path() lockpath = os.path.join(os.path.dirname(cext_so_path), 'mujocopy-buildlock') @@ -153,7 +153,7 @@ def fix_shared_library(so_file, name, library_path): subprocess.check_call(['patchelf', '--add-needed', library_path, so_file]) -def manually_link_libraries(mjpro_path, raw_cext_dll_path): +def manually_link_libraries(mujoco_path, raw_cext_dll_path): ''' Used to fix mujoco library linking on Mac ''' root, ext = os.path.splitext(raw_cext_dll_path) final_cext_dll_path = root + '_final' + ext @@ -167,12 +167,12 @@ def manually_link_libraries(mjpro_path, raw_cext_dll_path): tmp_final_cext_dll_path = final_cext_dll_path + '~' shutil.copyfile(raw_cext_dll_path, tmp_final_cext_dll_path) - mj_bin_path = join(mjpro_path, 'bin') + mj_bin_path = join(mujoco_path, 'bin') # Fix the rpath of the generated library -- i lost the Stackoverflow # reference here - from_mujoco_path = '@executable_path/libmujoco150.dylib' - to_mujoco_path = '%s/libmujoco150.dylib' % mj_bin_path + from_mujoco_path = '@executable_path/libmujoco200.dylib' + to_mujoco_path = '%s/libmujoco200.dylib' % mj_bin_path subprocess.check_call(['install_name_tool', '-change', from_mujoco_path, @@ -195,8 +195,8 @@ class MujocoExtensionBuilder(): CYMJ_DIR_PATH = abspath(dirname(__file__)) - def __init__(self, mjpro_path): - self.mjpro_path = mjpro_path + def __init__(self, mujoco_path): + self.mujoco_path = mujoco_path python_version = str(sys.version_info.major) + str(sys.version_info.minor) self.version = '%s_%s_%s' % (get_version(), python_version, self.build_base()) self.extension = Extension( @@ -204,11 +204,11 @@ def __init__(self, mjpro_path): sources=[join(self.CYMJ_DIR_PATH, "cymj.pyx")], include_dirs=[ self.CYMJ_DIR_PATH, - join(mjpro_path, 'include'), + join(mujoco_path, 'include'), np.get_include(), ], - libraries=['mujoco150'], - library_dirs=[join(mjpro_path, 'bin')], + libraries=['mujoco200'], + library_dirs=[join(mujoco_path, 'bin')], extra_compile_args=[ '-fopenmp', # needed for OpenMP '-w', # suppress numpy compilation warnings @@ -252,58 +252,58 @@ def get_so_file_path(self): class WindowsExtensionBuilder(MujocoExtensionBuilder): - def __init__(self, mjpro_path): - super().__init__(mjpro_path) - os.environ["PATH"] += ";" + join(mjpro_path, "bin") + def __init__(self, mujoco_path): + super().__init__(mujoco_path) + os.environ["PATH"] += ";" + join(mujoco_path, "bin") self.extension.sources.append(self.CYMJ_DIR_PATH + "/gl/dummyshim.c") class LinuxCPUExtensionBuilder(MujocoExtensionBuilder): - def __init__(self, mjpro_path): - super().__init__(mjpro_path) + def __init__(self, mujoco_path): + super().__init__(mujoco_path) self.extension.sources.append( join(self.CYMJ_DIR_PATH, "gl", "osmesashim.c")) self.extension.libraries.extend(['glewosmesa', 'OSMesa', 'GL']) - self.extension.runtime_library_dirs = [join(mjpro_path, 'bin')] + self.extension.runtime_library_dirs = [join(mujoco_path, 'bin')] def _build_impl(self): so_file_path = super()._build_impl() # Removes absolute paths to libraries. Allows for dynamic loading. - fix_shared_library(so_file_path, 'libmujoco150.so', 'libmujoco150.so') + fix_shared_library(so_file_path, 'libmujoco200.so', 'libmujoco200.so') fix_shared_library(so_file_path, 'libglewosmesa.so', 'libglewosmesa.so') return so_file_path class LinuxGPUExtensionBuilder(MujocoExtensionBuilder): - def __init__(self, mjpro_path): - super().__init__(mjpro_path) + def __init__(self, mujoco_path): + super().__init__(mujoco_path) self.extension.sources.append(self.CYMJ_DIR_PATH + "/gl/eglshim.c") self.extension.include_dirs.append(self.CYMJ_DIR_PATH + '/vendor/egl') self.extension.libraries.extend(['glewegl']) - self.extension.runtime_library_dirs = [join(mjpro_path, 'bin')] + self.extension.runtime_library_dirs = [join(mujoco_path, 'bin')] def _build_impl(self): so_file_path = super()._build_impl() fix_shared_library(so_file_path, 'libOpenGL.so', 'libOpenGL.so.0') fix_shared_library(so_file_path, 'libEGL.so', 'libEGL.so.1') - fix_shared_library(so_file_path, 'libmujoco150.so', 'libmujoco150.so') + fix_shared_library(so_file_path, 'libmujoco200.so', 'libmujoco200.so') fix_shared_library(so_file_path, 'libglewegl.so', 'libglewegl.so') return so_file_path class MacExtensionBuilder(MujocoExtensionBuilder): - def __init__(self, mjpro_path): - super().__init__(mjpro_path) + def __init__(self, mujoco_path): + super().__init__(mujoco_path) self.extension.sources.append(self.CYMJ_DIR_PATH + "/gl/dummyshim.c") self.extension.libraries.extend(['glfw.3']) self.extension.define_macros = [('ONMAC', None)] - self.extension.runtime_library_dirs = [join(mjpro_path, 'bin')] + self.extension.runtime_library_dirs = [join(mujoco_path, 'bin')] def _build_impl(self): if not os.environ.get('CC'): @@ -327,7 +327,7 @@ def _build_impl(self): del os.environ['CC'] else: # User-directed c compiler so_file_path = super()._build_impl() - return manually_link_libraries(self.mjpro_path, so_file_path) + return manually_link_libraries(self.mujoco_path, so_file_path) class MujocoException(Exception): @@ -467,9 +467,9 @@ def build_callback_fn(function_string, userdata_names=[]): source_string += '\nuintptr_t __fun = (uintptr_t) fun;' # Link against mujoco so we can call mujoco functions from within callback ffibuilder.set_source(name, source_string, - include_dirs=[join(mjpro_path, 'include')], - library_dirs=[join(mjpro_path, 'bin')], - libraries=['mujoco150']) + include_dirs=[join(mujoco_path, 'include')], + library_dirs=[join(mujoco_path, 'bin')], + libraries=['mujoco200']) # Catch compilation exceptions so we can cleanup partial files in that case try: library_path = ffibuilder.compile(verbose=True) @@ -478,7 +478,7 @@ def build_callback_fn(function_string, userdata_names=[]): raise e # On Mac the MuJoCo library is linked strangely, so we have to fix it here if sys.platform == 'darwin': - fixed_library_path = manually_link_libraries(mjpro_path, library_path) + fixed_library_path = manually_link_libraries(mujoco_path, library_path) move(fixed_library_path, library_path) # Overwrite with fixed library module = load_dynamic_ext(name, library_path) # Now that the module is loaded into memory, we can actually delete it @@ -499,8 +499,8 @@ def activate(): functions.mj_activate(key_path) -mjpro_path, key_path = discover_mujoco() -cymj = load_cython_ext(mjpro_path) +mujoco_path, key_path = discover_mujoco() +cymj = load_cython_ext(mujoco_path) # Trick to expose all mj* functions from mujoco in mujoco_py.* diff --git a/mujoco_py/generated/const.py b/mujoco_py/generated/const.py index f2e8d6ff..2cc76172 100644 --- a/mujoco_py/generated/const.py +++ b/mujoco_py/generated/const.py @@ -2,7 +2,7 @@ ###### const from defines ###### MINVAL = 1e-15 # minimum value in any denominator -PI = 3.141592653589793 # +PI = 3.141592653589793 # MAXVAL = 10000000000.0 # maximum value in qpos, qvel, qacc MINMU = 1e-05 # minimum friction coefficient MINIMP = 0.0001 # minimum constraint impedance @@ -11,40 +11,75 @@ MAXVFS = 200.0 # maximum number of files in virtual file system MAXVFSNAME = 100.0 # maximum filename size in virtual file system NEQDATA = 7.0 # number of eq_data fields -NDYN = 3.0 # number of actuator dynamics parameters -NGAIN = 3.0 # number of actuator gain parameters -NBIAS = 3.0 # number of actuator bias parameters +NDYN = 10.0 # number of actuator dynamics parameters +NGAIN = 10.0 # number of actuator gain parameters +NBIAS = 10.0 # number of actuator bias parameters NREF = 2.0 # number of solver reference parameters -NIMP = 3.0 # number of solver impedance parameters +NIMP = 5.0 # number of solver impedance parameters NSOLVER = 1000.0 # size of mjData.solver_XXX arrays -NGROUP = 5.0 # number of geom and site groups with visflags +NGROUP = 6.0 # number of geom, site, joint groups with visflags MAXOVERLAY = 500.0 # maximum number of characters in overlay text MAXLINE = 100.0 # maximum number of lines per plot -MAXLINEPNT = 500.0 # maximum number points per line -MAXPLANEGRID = 100.0 # maximum number of grid points for plane rendering +MAXLINEPNT = 1000.0 # maximum number points per line +MAXPLANEGRID = 200.0 # maximum number of grid divisions for plane +NAUX = 10.0 # number of auxiliary buffers +MAXTEXTURE = 1000.0 # maximum number of textures +MAXUISECT = 10.0 # maximum number of sections +MAXUIITEM = 80.0 # maximum number of items per section +MAXUITEXT = 500.0 # maximum number of chars in edittext and other +MAXUINAME = 40.0 # maximum number of chars in name +MAXUIMULTI = 20.0 # maximum number of radio/select items in group +MAXUIEDIT = 5.0 # maximum number of elements in edit list +MAXUIRECT = 15.0 # maximum number of rectangles +KEY_ESCAPE = 256.0 # +KEY_ENTER = 257.0 # +KEY_TAB = 258.0 # +KEY_BACKSPACE = 259.0 # +KEY_INSERT = 260.0 # +KEY_DELETE = 261.0 # +KEY_RIGHT = 262.0 # +KEY_LEFT = 263.0 # +KEY_DOWN = 264.0 # +KEY_UP = 265.0 # +KEY_PAGE_UP = 266.0 # +KEY_PAGE_DOWN = 267.0 # +KEY_HOME = 268.0 # +KEY_END = 269.0 # +KEY_F1 = 290.0 # +KEY_F2 = 291.0 # +KEY_F3 = 292.0 # +KEY_F4 = 293.0 # +KEY_F5 = 294.0 # +KEY_F6 = 295.0 # +KEY_F7 = 296.0 # +KEY_F8 = 297.0 # +KEY_F9 = 298.0 # +KEY_F10 = 299.0 # +KEY_F11 = 300.0 # +KEY_F12 = 301.0 # ###### const from enums ###### # _mjtDisableBit -DSBL_CONSTRAINT = 0 -DSBL_EQUALITY = 1 -DSBL_FRICTIONLOSS = 2 -DSBL_LIMIT = 3 -DSBL_CONTACT = 4 -DSBL_PASSIVE = 5 -DSBL_GRAVITY = 6 -DSBL_CLAMPCTRL = 7 -DSBL_WARMSTART = 8 -DSBL_FILTERPARENT = 9 -DSBL_ACTUATION = 10 -DSBL_REFSAFE = 11 +DSBL_CONSTRAINT = 1 +DSBL_EQUALITY = 2 +DSBL_FRICTIONLOSS = 4 +DSBL_LIMIT = 8 +DSBL_CONTACT = 16 +DSBL_PASSIVE = 32 +DSBL_GRAVITY = 64 +DSBL_CLAMPCTRL = 128 +DSBL_WARMSTART = 256 +DSBL_FILTERPARENT = 512 +DSBL_ACTUATION = 1024 +DSBL_REFSAFE = 2048 NDISABLE = 12 # _mjtEnableBit -ENBL_OVERRIDE = 0 -ENBL_ENERGY = 1 -ENBL_FWDINV = 2 -ENBL_SENSORNOISE = 3 +ENBL_OVERRIDE = 1 +ENBL_ENERGY = 2 +ENBL_FWDINV = 4 +ENBL_SENSORNOISE = 8 NENABLE = 4 # _mjtJoint @@ -66,7 +101,9 @@ GEOM_ARROW = 100 GEOM_ARROW1 = 101 GEOM_ARROW2 = 102 -GEOM_LABEL = 103 +GEOM_LINE = 103 +GEOM_SKIN = 104 +GEOM_LABEL = 105 GEOM_NONE = 1001 # _mjtCamLight @@ -104,16 +141,6 @@ SOL_CG = 1 SOL_NEWTON = 2 - # _mjtImp -IMP_CONSTANT = 0 -IMP_SIGMOID = 1 -IMP_LINEAR = 2 -IMP_USER = 3 - - # _mjtRef -REF_SPRING = 0 -REF_USER = 1 - # _mjtEq EQ_CONNECT = 0 EQ_WELD = 1 @@ -141,16 +168,19 @@ DYN_NONE = 0 DYN_INTEGRATOR = 1 DYN_FILTER = 2 -DYN_USER = 3 +DYN_MUSCLE = 3 +DYN_USER = 4 # _mjtGain GAIN_FIXED = 0 -GAIN_USER = 1 +GAIN_MUSCLE = 1 +GAIN_USER = 2 # _mjtBias BIAS_NONE = 0 BIAS_AFFINE = 1 -BIAS_USER = 2 +BIAS_MUSCLE = 2 +BIAS_USER = 3 # _mjtObj OBJ_UNKNOWN = 0 @@ -163,19 +193,20 @@ OBJ_CAMERA = 7 OBJ_LIGHT = 8 OBJ_MESH = 9 -OBJ_HFIELD = 10 -OBJ_TEXTURE = 11 -OBJ_MATERIAL = 12 -OBJ_PAIR = 13 -OBJ_EXCLUDE = 14 -OBJ_EQUALITY = 15 -OBJ_TENDON = 16 -OBJ_ACTUATOR = 17 -OBJ_SENSOR = 18 -OBJ_NUMERIC = 19 -OBJ_TEXT = 20 -OBJ_TUPLE = 21 -OBJ_KEY = 22 +OBJ_SKIN = 10 +OBJ_HFIELD = 11 +OBJ_TEXTURE = 12 +OBJ_MATERIAL = 13 +OBJ_PAIR = 14 +OBJ_EXCLUDE = 15 +OBJ_EQUALITY = 16 +OBJ_TENDON = 17 +OBJ_ACTUATOR = 18 +OBJ_SENSOR = 19 +OBJ_NUMERIC = 20 +OBJ_TEXT = 21 +OBJ_TUPLE = 22 +OBJ_KEY = 23 # _mjtConstraint CNSTR_EQUALITY = 0 @@ -212,19 +243,25 @@ SENS_ACTUATORFRC = 14 SENS_BALLQUAT = 15 SENS_BALLANGVEL = 16 -SENS_FRAMEPOS = 17 -SENS_FRAMEQUAT = 18 -SENS_FRAMEXAXIS = 19 -SENS_FRAMEYAXIS = 20 -SENS_FRAMEZAXIS = 21 -SENS_FRAMELINVEL = 22 -SENS_FRAMEANGVEL = 23 -SENS_FRAMELINACC = 24 -SENS_FRAMEANGACC = 25 -SENS_SUBTREECOM = 26 -SENS_SUBTREELINVEL = 27 -SENS_SUBTREEANGMOM = 28 -SENS_USER = 29 +SENS_JOINTLIMITPOS = 17 +SENS_JOINTLIMITVEL = 18 +SENS_JOINTLIMITFRC = 19 +SENS_TENDONLIMITPOS = 20 +SENS_TENDONLIMITVEL = 21 +SENS_TENDONLIMITFRC = 22 +SENS_FRAMEPOS = 23 +SENS_FRAMEQUAT = 24 +SENS_FRAMEXAXIS = 25 +SENS_FRAMEYAXIS = 26 +SENS_FRAMEZAXIS = 27 +SENS_FRAMELINVEL = 28 +SENS_FRAMEANGVEL = 29 +SENS_FRAMELINACC = 30 +SENS_FRAMEANGACC = 31 +SENS_SUBTREECOM = 32 +SENS_SUBTREELINVEL = 33 +SENS_SUBTREEANGMOM = 34 +SENS_USER = 35 # _mjtStage STAGE_NONE = 0 @@ -238,6 +275,12 @@ DATATYPE_AXIS = 2 DATATYPE_QUATERNION = 3 + # _mjtLRMode +LRMODE_NONE = 0 +LRMODE_MUSCLE = 1 +LRMODE_MUSCLEUSER = 2 +LRMODE_ALL = 3 + # _mjtWarning WARN_INERTIA = 0 WARN_CONTACTFULL = 1 @@ -301,10 +344,11 @@ LABEL_TENDON = 7 LABEL_ACTUATOR = 8 LABEL_CONSTRAINT = 9 -LABEL_SELECTION = 10 -LABEL_SELPNT = 11 -LABEL_CONTACTFORCE = 12 -NLABEL = 13 +LABEL_SKIN = 10 +LABEL_SELECTION = 11 +LABEL_SELPNT = 12 +LABEL_CONTACTFORCE = 13 +NLABEL = 14 # _mjtFrame FRAME_NONE = 0 @@ -323,27 +367,35 @@ VIS_ACTUATOR = 3 VIS_CAMERA = 4 VIS_LIGHT = 5 -VIS_CONSTRAINT = 6 -VIS_INERTIA = 7 -VIS_PERTFORCE = 8 -VIS_PERTOBJ = 9 -VIS_CONTACTPOINT = 10 -VIS_CONTACTFORCE = 11 -VIS_CONTACTSPLIT = 12 -VIS_TRANSPARENT = 13 -VIS_AUTOCONNECT = 14 -VIS_COM = 15 -VIS_SELECT = 16 -VIS_STATIC = 17 -NVISFLAG = 18 +VIS_TENDON = 6 +VIS_RANGEFINDER = 7 +VIS_CONSTRAINT = 8 +VIS_INERTIA = 9 +VIS_SCLINERTIA = 10 +VIS_PERTFORCE = 11 +VIS_PERTOBJ = 12 +VIS_CONTACTPOINT = 13 +VIS_CONTACTFORCE = 14 +VIS_CONTACTSPLIT = 15 +VIS_TRANSPARENT = 16 +VIS_AUTOCONNECT = 17 +VIS_COM = 18 +VIS_SELECT = 19 +VIS_STATIC = 20 +VIS_SKIN = 21 +NVISFLAG = 22 # _mjtRndFlag RND_SHADOW = 0 RND_WIREFRAME = 1 RND_REFLECTION = 2 -RND_FOG = 3 +RND_ADDITIVE = 3 RND_SKYBOX = 4 -NRNDFLAG = 5 +RND_FOG = 5 +RND_HAZE = 6 +RND_SEGMENT = 7 +RND_IDCOLOR = 8 +NRNDFLAG = 9 # _mjtStereo STEREO_NONE = 0 @@ -361,11 +413,46 @@ FB_OFFSCREEN = 1 # _mjtFontScale +FONTSCALE_50 = 50 FONTSCALE_100 = 100 FONTSCALE_150 = 150 FONTSCALE_200 = 200 +FONTSCALE_250 = 250 +FONTSCALE_300 = 300 # _mjtFont FONT_NORMAL = 0 FONT_SHADOW = 1 FONT_BIG = 2 + + # _mjtButton +BUTTON_NONE = 0 +BUTTON_LEFT = 1 +BUTTON_RIGHT = 2 +BUTTON_MIDDLE = 3 + + # _mjtEvent +EVENT_NONE = 0 +EVENT_MOVE = 1 +EVENT_PRESS = 2 +EVENT_RELEASE = 3 +EVENT_SCROLL = 4 +EVENT_KEY = 5 +EVENT_RESIZE = 6 + + # _mjtItem +ITEM_END = -2 +ITEM_SECTION = -1 +ITEM_SEPARATOR = 0 +ITEM_STATIC = 1 +ITEM_BUTTON = 2 +ITEM_CHECKINT = 3 +ITEM_CHECKBYTE = 4 +ITEM_RADIO = 5 +ITEM_SELECT = 6 +ITEM_SLIDERINT = 7 +ITEM_SLIDERNUM = 8 +ITEM_EDITINT = 9 +ITEM_EDITNUM = 10 +ITEM_EDITTXT = 11 +NITEM = 12 diff --git a/mujoco_py/generated/wrappers.pxi b/mujoco_py/generated/wrappers.pxi index 541d8ce2..23894bb2 100644 --- a/mujoco_py/generated/wrappers.pxi +++ b/mujoco_py/generated/wrappers.pxi @@ -8,6 +8,70 @@ cimport numpy as np import numpy as np from tempfile import TemporaryDirectory +cdef class PyMjLROpt(object): + cdef mjLROpt* ptr + + + + def __cinit__(self): + self.ptr = NULL + + + @property + def uintptr(self): return self.ptr + + cdef void _set(self, mjLROpt* p): + + self.ptr = p + + + + @property + def mode(self): return self.ptr.mode + @mode.setter + def mode(self, int x): self.ptr.mode = x + @property + def useexisting(self): return self.ptr.useexisting + @useexisting.setter + def useexisting(self, int x): self.ptr.useexisting = x + @property + def uselimit(self): return self.ptr.uselimit + @uselimit.setter + def uselimit(self, int x): self.ptr.uselimit = x + @property + def accel(self): return self.ptr.accel + @accel.setter + def accel(self, mjtNum x): self.ptr.accel = x + @property + def maxforce(self): return self.ptr.maxforce + @maxforce.setter + def maxforce(self, mjtNum x): self.ptr.maxforce = x + @property + def timeconst(self): return self.ptr.timeconst + @timeconst.setter + def timeconst(self, mjtNum x): self.ptr.timeconst = x + @property + def timestep(self): return self.ptr.timestep + @timestep.setter + def timestep(self, mjtNum x): self.ptr.timestep = x + @property + def inttotal(self): return self.ptr.inttotal + @inttotal.setter + def inttotal(self, mjtNum x): self.ptr.inttotal = x + @property + def inteval(self): return self.ptr.inteval + @inteval.setter + def inteval(self, mjtNum x): self.ptr.inteval = x + @property + def tolrange(self): return self.ptr.tolrange + @tolrange.setter + def tolrange(self, mjtNum x): self.ptr.tolrange = x + +cdef PyMjLROpt WrapMjLROpt(mjLROpt* p): + cdef PyMjLROpt o = PyMjLROpt() + o._set(p) + return o + cdef class PyMjVFS(object): cdef mjVFS* ptr @@ -71,7 +135,7 @@ cdef class PyMjOption(object): self._wind = _wrap_mjtNum_1d(&p.wind[0], 3) self._magnetic = _wrap_mjtNum_1d(&p.magnetic[0], 3) self._o_solref = _wrap_mjtNum_1d(&p.o_solref[0], 2) - self._o_solimp = _wrap_mjtNum_1d(&p.o_solimp[0], 3) + self._o_solimp = _wrap_mjtNum_1d(&p.o_solimp[0], 5) @property def timestep(self): return self.ptr.timestep @@ -118,14 +182,6 @@ cdef class PyMjOption(object): @collision.setter def collision(self, int x): self.ptr.collision = x @property - def impedance(self): return self.ptr.impedance - @impedance.setter - def impedance(self, int x): self.ptr.impedance = x - @property - def reference(self): return self.ptr.reference - @reference.setter - def reference(self, int x): self.ptr.reference = x - @property def cone(self): return self.ptr.cone @cone.setter def cone(self, int x): self.ptr.cone = x @@ -304,10 +360,6 @@ cdef class PyMjVisual_quality(object): @numstacks.setter def numstacks(self, int x): self.ptr.numstacks = x @property - def numarrows(self): return self.ptr.numarrows - @numarrows.setter - def numarrows(self, int x): self.ptr.numarrows = x - @property def numquads(self): return self.ptr.numquads @numquads.setter def numquads(self, int x): self.ptr.numquads = x @@ -412,6 +464,10 @@ cdef class PyMjVisual_map(object): @zfar.setter def zfar(self, float x): self.ptr.zfar = x @property + def haze(self): return self.ptr.haze + @haze.setter + def haze(self, float x): self.ptr.haze = x + @property def shadowclip(self): return self.ptr.shadowclip @shadowclip.setter def shadowclip(self, float x): self.ptr.shadowclip = x @@ -419,6 +475,10 @@ cdef class PyMjVisual_map(object): def shadowscale(self): return self.ptr.shadowscale @shadowscale.setter def shadowscale(self, float x): self.ptr.shadowscale = x + @property + def actuatortendon(self): return self.ptr.actuatortendon + @actuatortendon.setter + def actuatortendon(self, float x): self.ptr.actuatortendon = x cdef PyMjVisual_map WrapMjVisual_map(mjVisual_map* p): cdef PyMjVisual_map o = PyMjVisual_map() @@ -518,10 +578,13 @@ cdef class PyMjVisual_rgba(object): cdef np.ndarray _fog + cdef np.ndarray _haze cdef np.ndarray _force cdef np.ndarray _inertia cdef np.ndarray _joint cdef np.ndarray _actuator + cdef np.ndarray _actuatornegative + cdef np.ndarray _actuatorpositive cdef np.ndarray _com cdef np.ndarray _camera cdef np.ndarray _light @@ -531,6 +594,8 @@ cdef class PyMjVisual_rgba(object): cdef np.ndarray _contactforce cdef np.ndarray _contactfriction cdef np.ndarray _contacttorque + cdef np.ndarray _contactgap + cdef np.ndarray _rangefinder cdef np.ndarray _constraint cdef np.ndarray _slidercrank cdef np.ndarray _crankbroken @@ -548,10 +613,13 @@ cdef class PyMjVisual_rgba(object): self._fog = _wrap_float_1d(&p.fog[0], 4) + self._haze = _wrap_float_1d(&p.haze[0], 4) self._force = _wrap_float_1d(&p.force[0], 4) self._inertia = _wrap_float_1d(&p.inertia[0], 4) self._joint = _wrap_float_1d(&p.joint[0], 4) self._actuator = _wrap_float_1d(&p.actuator[0], 4) + self._actuatornegative = _wrap_float_1d(&p.actuatornegative[0], 4) + self._actuatorpositive = _wrap_float_1d(&p.actuatorpositive[0], 4) self._com = _wrap_float_1d(&p.com[0], 4) self._camera = _wrap_float_1d(&p.camera[0], 4) self._light = _wrap_float_1d(&p.light[0], 4) @@ -561,6 +629,8 @@ cdef class PyMjVisual_rgba(object): self._contactforce = _wrap_float_1d(&p.contactforce[0], 4) self._contactfriction = _wrap_float_1d(&p.contactfriction[0], 4) self._contacttorque = _wrap_float_1d(&p.contacttorque[0], 4) + self._contactgap = _wrap_float_1d(&p.contactgap[0], 4) + self._rangefinder = _wrap_float_1d(&p.rangefinder[0], 4) self._constraint = _wrap_float_1d(&p.constraint[0], 4) self._slidercrank = _wrap_float_1d(&p.slidercrank[0], 4) self._crankbroken = _wrap_float_1d(&p.crankbroken[0], 4) @@ -568,6 +638,8 @@ cdef class PyMjVisual_rgba(object): @property def fog(self): return self._fog @property + def haze(self): return self._haze + @property def force(self): return self._force @property def inertia(self): return self._inertia @@ -576,6 +648,10 @@ cdef class PyMjVisual_rgba(object): @property def actuator(self): return self._actuator @property + def actuatornegative(self): return self._actuatornegative + @property + def actuatorpositive(self): return self._actuatorpositive + @property def com(self): return self._com @property def camera(self): return self._camera @@ -594,6 +670,10 @@ cdef class PyMjVisual_rgba(object): @property def contacttorque(self): return self._contacttorque @property + def contactgap(self): return self._contactgap + @property + def rangefinder(self): return self._rangefinder + @property def constraint(self): return self._constraint @property def slidercrank(self): return self._slidercrank @@ -668,6 +748,8 @@ cdef class PyMjModel(object): cdef np.ndarray _body_dofadr cdef np.ndarray _body_geomnum cdef np.ndarray _body_geomadr + cdef np.ndarray _body_simple + cdef np.ndarray _body_sameframe cdef np.ndarray _body_pos cdef np.ndarray _body_quat cdef np.ndarray _body_ipos @@ -681,6 +763,7 @@ cdef class PyMjModel(object): cdef np.ndarray _jnt_qposadr cdef np.ndarray _jnt_dofadr cdef np.ndarray _jnt_bodyid + cdef np.ndarray _jnt_group cdef np.ndarray _jnt_limited cdef np.ndarray _jnt_solref cdef np.ndarray _jnt_solimp @@ -694,12 +777,14 @@ cdef class PyMjModel(object): cdef np.ndarray _dof_jntid cdef np.ndarray _dof_parentid cdef np.ndarray _dof_Madr + cdef np.ndarray _dof_simplenum cdef np.ndarray _dof_solref cdef np.ndarray _dof_solimp cdef np.ndarray _dof_frictionloss cdef np.ndarray _dof_armature cdef np.ndarray _dof_damping cdef np.ndarray _dof_invweight0 + cdef np.ndarray _dof_M0 cdef np.ndarray _geom_type cdef np.ndarray _geom_contype cdef np.ndarray _geom_conaffinity @@ -708,6 +793,8 @@ cdef class PyMjModel(object): cdef np.ndarray _geom_dataid cdef np.ndarray _geom_matid cdef np.ndarray _geom_group + cdef np.ndarray _geom_priority + cdef np.ndarray _geom_sameframe cdef np.ndarray _geom_solmix cdef np.ndarray _geom_solref cdef np.ndarray _geom_solimp @@ -724,6 +811,7 @@ cdef class PyMjModel(object): cdef np.ndarray _site_bodyid cdef np.ndarray _site_matid cdef np.ndarray _site_group + cdef np.ndarray _site_sameframe cdef np.ndarray _site_size cdef np.ndarray _site_pos cdef np.ndarray _site_quat @@ -757,15 +845,37 @@ cdef class PyMjModel(object): cdef np.ndarray _light_ambient cdef np.ndarray _light_diffuse cdef np.ndarray _light_specular - cdef np.ndarray _mesh_faceadr - cdef np.ndarray _mesh_facenum cdef np.ndarray _mesh_vertadr cdef np.ndarray _mesh_vertnum + cdef np.ndarray _mesh_texcoordadr + cdef np.ndarray _mesh_faceadr + cdef np.ndarray _mesh_facenum cdef np.ndarray _mesh_graphadr cdef np.ndarray _mesh_vert cdef np.ndarray _mesh_normal + cdef np.ndarray _mesh_texcoord cdef np.ndarray _mesh_face cdef np.ndarray _mesh_graph + cdef np.ndarray _skin_matid + cdef np.ndarray _skin_rgba + cdef np.ndarray _skin_inflate + cdef np.ndarray _skin_vertadr + cdef np.ndarray _skin_vertnum + cdef np.ndarray _skin_texcoordadr + cdef np.ndarray _skin_faceadr + cdef np.ndarray _skin_facenum + cdef np.ndarray _skin_boneadr + cdef np.ndarray _skin_bonenum + cdef np.ndarray _skin_vert + cdef np.ndarray _skin_texcoord + cdef np.ndarray _skin_face + cdef np.ndarray _skin_bonevertadr + cdef np.ndarray _skin_bonevertnum + cdef np.ndarray _skin_bonebindpos + cdef np.ndarray _skin_bonebindquat + cdef np.ndarray _skin_bonebodyid + cdef np.ndarray _skin_bonevertid + cdef np.ndarray _skin_bonevertweight cdef np.ndarray _hfield_size cdef np.ndarray _hfield_nrow cdef np.ndarray _hfield_ncol @@ -804,6 +914,7 @@ cdef class PyMjModel(object): cdef np.ndarray _tendon_adr cdef np.ndarray _tendon_num cdef np.ndarray _tendon_matid + cdef np.ndarray _tendon_group cdef np.ndarray _tendon_limited cdef np.ndarray _tendon_width cdef np.ndarray _tendon_solref_lim @@ -828,6 +939,7 @@ cdef class PyMjModel(object): cdef np.ndarray _actuator_gaintype cdef np.ndarray _actuator_biastype cdef np.ndarray _actuator_trnid + cdef np.ndarray _actuator_group cdef np.ndarray _actuator_ctrllimited cdef np.ndarray _actuator_forcelimited cdef np.ndarray _actuator_dynprm @@ -837,7 +949,7 @@ cdef class PyMjModel(object): cdef np.ndarray _actuator_forcerange cdef np.ndarray _actuator_gear cdef np.ndarray _actuator_cranklength - cdef np.ndarray _actuator_invweight0 + cdef np.ndarray _actuator_acc0 cdef np.ndarray _actuator_length0 cdef np.ndarray _actuator_lengthrange cdef np.ndarray _actuator_user @@ -873,9 +985,12 @@ cdef class PyMjModel(object): cdef np.ndarray _name_camadr cdef np.ndarray _name_lightadr cdef np.ndarray _name_meshadr + cdef np.ndarray _name_skinadr cdef np.ndarray _name_hfieldadr cdef np.ndarray _name_texadr cdef np.ndarray _name_matadr + cdef np.ndarray _name_pairadr + cdef np.ndarray _name_excludeadr cdef np.ndarray _name_eqadr cdef np.ndarray _name_tendonadr cdef np.ndarray _name_actuatoradr @@ -883,6 +998,7 @@ cdef class PyMjModel(object): cdef np.ndarray _name_numericadr cdef np.ndarray _name_textadr cdef np.ndarray _name_tupleadr + cdef np.ndarray _name_keyadr cdef np.ndarray _names cdef readonly tuple body_names, joint_names, geom_names, site_names, light_names, camera_names, actuator_names, sensor_names, tendon_names @@ -1128,6 +1244,8 @@ cdef class PyMjModel(object): self._body_dofadr = _wrap_int_1d(p.body_dofadr, p.nbody) self._body_geomnum = _wrap_int_1d(p.body_geomnum, p.nbody) self._body_geomadr = _wrap_int_1d(p.body_geomadr, p.nbody) + self._body_simple = _wrap_mjtByte_1d(p.body_simple, p.nbody) + self._body_sameframe = _wrap_mjtByte_1d(p.body_sameframe, p.nbody) self._body_pos = _wrap_mjtNum_2d(p.body_pos, p.nbody, 3) self._body_quat = _wrap_mjtNum_2d(p.body_quat, p.nbody, 4) self._body_ipos = _wrap_mjtNum_2d(p.body_ipos, p.nbody, 3) @@ -1141,6 +1259,7 @@ cdef class PyMjModel(object): self._jnt_qposadr = _wrap_int_1d(p.jnt_qposadr, p.njnt) self._jnt_dofadr = _wrap_int_1d(p.jnt_dofadr, p.njnt) self._jnt_bodyid = _wrap_int_1d(p.jnt_bodyid, p.njnt) + self._jnt_group = _wrap_int_1d(p.jnt_group, p.njnt) self._jnt_limited = _wrap_mjtByte_1d(p.jnt_limited, p.njnt) self._jnt_solref = _wrap_mjtNum_2d(p.jnt_solref, p.njnt, mjNREF) self._jnt_solimp = _wrap_mjtNum_2d(p.jnt_solimp, p.njnt, mjNIMP) @@ -1154,12 +1273,14 @@ cdef class PyMjModel(object): self._dof_jntid = _wrap_int_1d(p.dof_jntid, p.nv) self._dof_parentid = _wrap_int_1d(p.dof_parentid, p.nv) self._dof_Madr = _wrap_int_1d(p.dof_Madr, p.nv) + self._dof_simplenum = _wrap_int_1d(p.dof_simplenum, p.nv) self._dof_solref = _wrap_mjtNum_2d(p.dof_solref, p.nv, mjNREF) self._dof_solimp = _wrap_mjtNum_2d(p.dof_solimp, p.nv, mjNIMP) self._dof_frictionloss = _wrap_mjtNum_1d(p.dof_frictionloss, p.nv) self._dof_armature = _wrap_mjtNum_1d(p.dof_armature, p.nv) self._dof_damping = _wrap_mjtNum_1d(p.dof_damping, p.nv) self._dof_invweight0 = _wrap_mjtNum_1d(p.dof_invweight0, p.nv) + self._dof_M0 = _wrap_mjtNum_1d(p.dof_M0, p.nv) self._geom_type = _wrap_int_1d(p.geom_type, p.ngeom) self._geom_contype = _wrap_int_1d(p.geom_contype, p.ngeom) self._geom_conaffinity = _wrap_int_1d(p.geom_conaffinity, p.ngeom) @@ -1168,6 +1289,8 @@ cdef class PyMjModel(object): self._geom_dataid = _wrap_int_1d(p.geom_dataid, p.ngeom) self._geom_matid = _wrap_int_1d(p.geom_matid, p.ngeom) self._geom_group = _wrap_int_1d(p.geom_group, p.ngeom) + self._geom_priority = _wrap_int_1d(p.geom_priority, p.ngeom) + self._geom_sameframe = _wrap_mjtByte_1d(p.geom_sameframe, p.ngeom) self._geom_solmix = _wrap_mjtNum_1d(p.geom_solmix, p.ngeom) self._geom_solref = _wrap_mjtNum_2d(p.geom_solref, p.ngeom, mjNREF) self._geom_solimp = _wrap_mjtNum_2d(p.geom_solimp, p.ngeom, mjNIMP) @@ -1184,6 +1307,7 @@ cdef class PyMjModel(object): self._site_bodyid = _wrap_int_1d(p.site_bodyid, p.nsite) self._site_matid = _wrap_int_1d(p.site_matid, p.nsite) self._site_group = _wrap_int_1d(p.site_group, p.nsite) + self._site_sameframe = _wrap_mjtByte_1d(p.site_sameframe, p.nsite) self._site_size = _wrap_mjtNum_2d(p.site_size, p.nsite, 3) self._site_pos = _wrap_mjtNum_2d(p.site_pos, p.nsite, 3) self._site_quat = _wrap_mjtNum_2d(p.site_quat, p.nsite, 4) @@ -1217,15 +1341,37 @@ cdef class PyMjModel(object): self._light_ambient = _wrap_float_2d(p.light_ambient, p.nlight, 3) self._light_diffuse = _wrap_float_2d(p.light_diffuse, p.nlight, 3) self._light_specular = _wrap_float_2d(p.light_specular, p.nlight, 3) - self._mesh_faceadr = _wrap_int_1d(p.mesh_faceadr, p.nmesh) - self._mesh_facenum = _wrap_int_1d(p.mesh_facenum, p.nmesh) self._mesh_vertadr = _wrap_int_1d(p.mesh_vertadr, p.nmesh) self._mesh_vertnum = _wrap_int_1d(p.mesh_vertnum, p.nmesh) + self._mesh_texcoordadr = _wrap_int_1d(p.mesh_texcoordadr, p.nmesh) + self._mesh_faceadr = _wrap_int_1d(p.mesh_faceadr, p.nmesh) + self._mesh_facenum = _wrap_int_1d(p.mesh_facenum, p.nmesh) self._mesh_graphadr = _wrap_int_1d(p.mesh_graphadr, p.nmesh) self._mesh_vert = _wrap_float_2d(p.mesh_vert, p.nmeshvert, 3) self._mesh_normal = _wrap_float_2d(p.mesh_normal, p.nmeshvert, 3) + self._mesh_texcoord = _wrap_float_2d(p.mesh_texcoord, p.nmeshtexvert, 2) self._mesh_face = _wrap_int_2d(p.mesh_face, p.nmeshface, 3) self._mesh_graph = _wrap_int_1d(p.mesh_graph, p.nmeshgraph) + self._skin_matid = _wrap_int_1d(p.skin_matid, p.nskin) + self._skin_rgba = _wrap_float_2d(p.skin_rgba, p.nskin, 4) + self._skin_inflate = _wrap_float_1d(p.skin_inflate, p.nskin) + self._skin_vertadr = _wrap_int_1d(p.skin_vertadr, p.nskin) + self._skin_vertnum = _wrap_int_1d(p.skin_vertnum, p.nskin) + self._skin_texcoordadr = _wrap_int_1d(p.skin_texcoordadr, p.nskin) + self._skin_faceadr = _wrap_int_1d(p.skin_faceadr, p.nskin) + self._skin_facenum = _wrap_int_1d(p.skin_facenum, p.nskin) + self._skin_boneadr = _wrap_int_1d(p.skin_boneadr, p.nskin) + self._skin_bonenum = _wrap_int_1d(p.skin_bonenum, p.nskin) + self._skin_vert = _wrap_float_2d(p.skin_vert, p.nskinvert, 3) + self._skin_texcoord = _wrap_float_2d(p.skin_texcoord, p.nskintexvert, 2) + self._skin_face = _wrap_int_2d(p.skin_face, p.nskinface, 3) + self._skin_bonevertadr = _wrap_int_1d(p.skin_bonevertadr, p.nskinbone) + self._skin_bonevertnum = _wrap_int_1d(p.skin_bonevertnum, p.nskinbone) + self._skin_bonebindpos = _wrap_float_2d(p.skin_bonebindpos, p.nskinbone, 3) + self._skin_bonebindquat = _wrap_float_2d(p.skin_bonebindquat, p.nskinbone, 4) + self._skin_bonebodyid = _wrap_int_1d(p.skin_bonebodyid, p.nskinbone) + self._skin_bonevertid = _wrap_int_1d(p.skin_bonevertid, p.nskinbonevert) + self._skin_bonevertweight = _wrap_float_1d(p.skin_bonevertweight, p.nskinbonevert) self._hfield_size = _wrap_mjtNum_2d(p.hfield_size, p.nhfield, 4) self._hfield_nrow = _wrap_int_1d(p.hfield_nrow, p.nhfield) self._hfield_ncol = _wrap_int_1d(p.hfield_ncol, p.nhfield) @@ -1264,6 +1410,7 @@ cdef class PyMjModel(object): self._tendon_adr = _wrap_int_1d(p.tendon_adr, p.ntendon) self._tendon_num = _wrap_int_1d(p.tendon_num, p.ntendon) self._tendon_matid = _wrap_int_1d(p.tendon_matid, p.ntendon) + self._tendon_group = _wrap_int_1d(p.tendon_group, p.ntendon) self._tendon_limited = _wrap_mjtByte_1d(p.tendon_limited, p.ntendon) self._tendon_width = _wrap_mjtNum_1d(p.tendon_width, p.ntendon) self._tendon_solref_lim = _wrap_mjtNum_2d(p.tendon_solref_lim, p.ntendon, mjNREF) @@ -1288,6 +1435,7 @@ cdef class PyMjModel(object): self._actuator_gaintype = _wrap_int_1d(p.actuator_gaintype, p.nu) self._actuator_biastype = _wrap_int_1d(p.actuator_biastype, p.nu) self._actuator_trnid = _wrap_int_2d(p.actuator_trnid, p.nu, 2) + self._actuator_group = _wrap_int_1d(p.actuator_group, p.nu) self._actuator_ctrllimited = _wrap_mjtByte_1d(p.actuator_ctrllimited, p.nu) self._actuator_forcelimited = _wrap_mjtByte_1d(p.actuator_forcelimited, p.nu) self._actuator_dynprm = _wrap_mjtNum_2d(p.actuator_dynprm, p.nu, mjNDYN) @@ -1297,7 +1445,7 @@ cdef class PyMjModel(object): self._actuator_forcerange = _wrap_mjtNum_2d(p.actuator_forcerange, p.nu, 2) self._actuator_gear = _wrap_mjtNum_2d(p.actuator_gear, p.nu, 6) self._actuator_cranklength = _wrap_mjtNum_1d(p.actuator_cranklength, p.nu) - self._actuator_invweight0 = _wrap_mjtNum_1d(p.actuator_invweight0, p.nu) + self._actuator_acc0 = _wrap_mjtNum_1d(p.actuator_acc0, p.nu) self._actuator_length0 = _wrap_mjtNum_1d(p.actuator_length0, p.nu) self._actuator_lengthrange = _wrap_mjtNum_2d(p.actuator_lengthrange, p.nu, 2) self._actuator_user = _wrap_mjtNum_2d(p.actuator_user, p.nu, p.nuser_actuator) @@ -1333,9 +1481,12 @@ cdef class PyMjModel(object): self._name_camadr = _wrap_int_1d(p.name_camadr, p.ncam) self._name_lightadr = _wrap_int_1d(p.name_lightadr, p.nlight) self._name_meshadr = _wrap_int_1d(p.name_meshadr, p.nmesh) + self._name_skinadr = _wrap_int_1d(p.name_skinadr, p.nskin) self._name_hfieldadr = _wrap_int_1d(p.name_hfieldadr, p.nhfield) self._name_texadr = _wrap_int_1d(p.name_texadr, p.ntex) self._name_matadr = _wrap_int_1d(p.name_matadr, p.nmat) + self._name_pairadr = _wrap_int_1d(p.name_pairadr, p.npair) + self._name_excludeadr = _wrap_int_1d(p.name_excludeadr, p.nexclude) self._name_eqadr = _wrap_int_1d(p.name_eqadr, p.neq) self._name_tendonadr = _wrap_int_1d(p.name_tendonadr, p.ntendon) self._name_actuatoradr = _wrap_int_1d(p.name_actuatoradr, p.nu) @@ -1343,6 +1494,7 @@ cdef class PyMjModel(object): self._name_numericadr = _wrap_int_1d(p.name_numericadr, p.nnumeric) self._name_textadr = _wrap_int_1d(p.name_textadr, p.ntext) self._name_tupleadr = _wrap_int_1d(p.name_tupleadr, p.ntuple) + self._name_keyadr = _wrap_int_1d(p.name_keyadr, p.nkey) self._names = _wrap_char_1d(p.names, p.nnames) @property @@ -1394,6 +1546,10 @@ cdef class PyMjModel(object): @nmeshvert.setter def nmeshvert(self, int x): self.ptr.nmeshvert = x @property + def nmeshtexvert(self): return self.ptr.nmeshtexvert + @nmeshtexvert.setter + def nmeshtexvert(self, int x): self.ptr.nmeshtexvert = x + @property def nmeshface(self): return self.ptr.nmeshface @nmeshface.setter def nmeshface(self, int x): self.ptr.nmeshface = x @@ -1402,6 +1558,30 @@ cdef class PyMjModel(object): @nmeshgraph.setter def nmeshgraph(self, int x): self.ptr.nmeshgraph = x @property + def nskin(self): return self.ptr.nskin + @nskin.setter + def nskin(self, int x): self.ptr.nskin = x + @property + def nskinvert(self): return self.ptr.nskinvert + @nskinvert.setter + def nskinvert(self, int x): self.ptr.nskinvert = x + @property + def nskintexvert(self): return self.ptr.nskintexvert + @nskintexvert.setter + def nskintexvert(self, int x): self.ptr.nskintexvert = x + @property + def nskinface(self): return self.ptr.nskinface + @nskinface.setter + def nskinface(self, int x): self.ptr.nskinface = x + @property + def nskinbone(self): return self.ptr.nskinbone + @nskinbone.setter + def nskinbone(self, int x): self.ptr.nskinbone = x + @property + def nskinbonevert(self): return self.ptr.nskinbonevert + @nskinbonevert.setter + def nskinbonevert(self, int x): self.ptr.nskinbonevert = x + @property def nhfield(self): return self.ptr.nhfield @nhfield.setter def nhfield(self, int x): self.ptr.nhfield = x @@ -1576,6 +1756,10 @@ cdef class PyMjModel(object): @property def body_geomadr(self): return self._body_geomadr @property + def body_simple(self): return self._body_simple + @property + def body_sameframe(self): return self._body_sameframe + @property def body_pos(self): return self._body_pos @property def body_quat(self): return self._body_quat @@ -1602,6 +1786,8 @@ cdef class PyMjModel(object): @property def jnt_bodyid(self): return self._jnt_bodyid @property + def jnt_group(self): return self._jnt_group + @property def jnt_limited(self): return self._jnt_limited @property def jnt_solref(self): return self._jnt_solref @@ -1628,6 +1814,8 @@ cdef class PyMjModel(object): @property def dof_Madr(self): return self._dof_Madr @property + def dof_simplenum(self): return self._dof_simplenum + @property def dof_solref(self): return self._dof_solref @property def dof_solimp(self): return self._dof_solimp @@ -1640,6 +1828,8 @@ cdef class PyMjModel(object): @property def dof_invweight0(self): return self._dof_invweight0 @property + def dof_M0(self): return self._dof_M0 + @property def geom_type(self): return self._geom_type @property def geom_contype(self): return self._geom_contype @@ -1656,6 +1846,10 @@ cdef class PyMjModel(object): @property def geom_group(self): return self._geom_group @property + def geom_priority(self): return self._geom_priority + @property + def geom_sameframe(self): return self._geom_sameframe + @property def geom_solmix(self): return self._geom_solmix @property def geom_solref(self): return self._geom_solref @@ -1688,6 +1882,8 @@ cdef class PyMjModel(object): @property def site_group(self): return self._site_group @property + def site_sameframe(self): return self._site_sameframe + @property def site_size(self): return self._site_size @property def site_pos(self): return self._site_pos @@ -1754,24 +1950,68 @@ cdef class PyMjModel(object): @property def light_specular(self): return self._light_specular @property - def mesh_faceadr(self): return self._mesh_faceadr - @property - def mesh_facenum(self): return self._mesh_facenum - @property def mesh_vertadr(self): return self._mesh_vertadr @property def mesh_vertnum(self): return self._mesh_vertnum @property + def mesh_texcoordadr(self): return self._mesh_texcoordadr + @property + def mesh_faceadr(self): return self._mesh_faceadr + @property + def mesh_facenum(self): return self._mesh_facenum + @property def mesh_graphadr(self): return self._mesh_graphadr @property def mesh_vert(self): return self._mesh_vert @property def mesh_normal(self): return self._mesh_normal @property + def mesh_texcoord(self): return self._mesh_texcoord + @property def mesh_face(self): return self._mesh_face @property def mesh_graph(self): return self._mesh_graph @property + def skin_matid(self): return self._skin_matid + @property + def skin_rgba(self): return self._skin_rgba + @property + def skin_inflate(self): return self._skin_inflate + @property + def skin_vertadr(self): return self._skin_vertadr + @property + def skin_vertnum(self): return self._skin_vertnum + @property + def skin_texcoordadr(self): return self._skin_texcoordadr + @property + def skin_faceadr(self): return self._skin_faceadr + @property + def skin_facenum(self): return self._skin_facenum + @property + def skin_boneadr(self): return self._skin_boneadr + @property + def skin_bonenum(self): return self._skin_bonenum + @property + def skin_vert(self): return self._skin_vert + @property + def skin_texcoord(self): return self._skin_texcoord + @property + def skin_face(self): return self._skin_face + @property + def skin_bonevertadr(self): return self._skin_bonevertadr + @property + def skin_bonevertnum(self): return self._skin_bonevertnum + @property + def skin_bonebindpos(self): return self._skin_bonebindpos + @property + def skin_bonebindquat(self): return self._skin_bonebindquat + @property + def skin_bonebodyid(self): return self._skin_bonebodyid + @property + def skin_bonevertid(self): return self._skin_bonevertid + @property + def skin_bonevertweight(self): return self._skin_bonevertweight + @property def hfield_size(self): return self._hfield_size @property def hfield_nrow(self): return self._hfield_nrow @@ -1848,6 +2088,8 @@ cdef class PyMjModel(object): @property def tendon_matid(self): return self._tendon_matid @property + def tendon_group(self): return self._tendon_group + @property def tendon_limited(self): return self._tendon_limited @property def tendon_width(self): return self._tendon_width @@ -1896,6 +2138,8 @@ cdef class PyMjModel(object): @property def actuator_trnid(self): return self._actuator_trnid @property + def actuator_group(self): return self._actuator_group + @property def actuator_ctrllimited(self): return self._actuator_ctrllimited @property def actuator_forcelimited(self): return self._actuator_forcelimited @@ -1914,7 +2158,7 @@ cdef class PyMjModel(object): @property def actuator_cranklength(self): return self._actuator_cranklength @property - def actuator_invweight0(self): return self._actuator_invweight0 + def actuator_acc0(self): return self._actuator_acc0 @property def actuator_length0(self): return self._actuator_length0 @property @@ -1986,12 +2230,18 @@ cdef class PyMjModel(object): @property def name_meshadr(self): return self._name_meshadr @property + def name_skinadr(self): return self._name_skinadr + @property def name_hfieldadr(self): return self._name_hfieldadr @property def name_texadr(self): return self._name_texadr @property def name_matadr(self): return self._name_matadr @property + def name_pairadr(self): return self._name_pairadr + @property + def name_excludeadr(self): return self._name_excludeadr + @property def name_eqadr(self): return self._name_eqadr @property def name_tendonadr(self): return self._name_tendonadr @@ -2006,6 +2256,8 @@ cdef class PyMjModel(object): @property def name_tupleadr(self): return self._name_tupleadr @property + def name_keyadr(self): return self._name_keyadr + @property def names(self): return self._names cdef PyMjModel WrapMjModel(mjModel* p): @@ -2040,7 +2292,7 @@ cdef class PyMjContact(object): self._frame = _wrap_mjtNum_1d(&p.frame[0], 9) self._friction = _wrap_mjtNum_1d(&p.friction[0], 5) self._solref = _wrap_mjtNum_1d(&p.solref[0], 2) - self._solimp = _wrap_mjtNum_1d(&p.solimp[0], 3) + self._solimp = _wrap_mjtNum_1d(&p.solimp[0], 5) self._H = _wrap_mjtNum_1d(&p.H[0], 36) @property @@ -2217,6 +2469,7 @@ cdef class PyMjData(object): cdef np.ndarray _qpos cdef np.ndarray _qvel cdef np.ndarray _act + cdef np.ndarray _qacc_warmstart cdef np.ndarray _ctrl cdef np.ndarray _qfrc_applied cdef np.ndarray _xfrc_applied @@ -2246,8 +2499,11 @@ cdef class PyMjData(object): cdef np.ndarray _cinert cdef np.ndarray _ten_wrapadr cdef np.ndarray _ten_wrapnum + cdef np.ndarray _ten_J_rownnz + cdef np.ndarray _ten_J_rowadr + cdef np.ndarray _ten_J_colind cdef np.ndarray _ten_length - cdef np.ndarray _ten_moment + cdef np.ndarray _ten_J cdef np.ndarray _wrap_obj cdef np.ndarray _wrap_xpos cdef np.ndarray _actuator_length @@ -2262,18 +2518,19 @@ cdef class PyMjData(object): cdef np.ndarray _efc_id cdef np.ndarray _efc_J_rownnz cdef np.ndarray _efc_J_rowadr + cdef np.ndarray _efc_J_rowsuper cdef np.ndarray _efc_J_colind cdef np.ndarray _efc_JT_rownnz cdef np.ndarray _efc_JT_rowadr + cdef np.ndarray _efc_JT_rowsuper cdef np.ndarray _efc_JT_colind - cdef np.ndarray _efc_solref - cdef np.ndarray _efc_solimp - cdef np.ndarray _efc_margin - cdef np.ndarray _efc_frictionloss - cdef np.ndarray _efc_pos cdef np.ndarray _efc_J cdef np.ndarray _efc_JT + cdef np.ndarray _efc_pos + cdef np.ndarray _efc_margin + cdef np.ndarray _efc_frictionloss cdef np.ndarray _efc_diagApprox + cdef np.ndarray _efc_KBIP cdef np.ndarray _efc_D cdef np.ndarray _efc_R cdef np.ndarray _efc_AR_rownnz @@ -2298,7 +2555,6 @@ cdef class PyMjData(object): cdef np.ndarray _efc_force cdef np.ndarray _efc_state cdef np.ndarray _qfrc_constraint - cdef np.ndarray _qacc_warmstart cdef np.ndarray _qfrc_inverse cdef np.ndarray _cacc cdef np.ndarray _cfrc_int @@ -2581,6 +2837,7 @@ cdef class PyMjData(object): self._qpos = _wrap_mjtNum_1d(p.qpos, model.nq) self._qvel = _wrap_mjtNum_1d(p.qvel, model.nv) self._act = _wrap_mjtNum_1d(p.act, model.na) + self._qacc_warmstart = _wrap_mjtNum_1d(p.qacc_warmstart, model.nv) self._ctrl = _wrap_mjtNum_1d(p.ctrl, model.nu) self._qfrc_applied = _wrap_mjtNum_1d(p.qfrc_applied, model.nv) self._xfrc_applied = _wrap_mjtNum_2d(p.xfrc_applied, model.nbody, 6) @@ -2610,8 +2867,11 @@ cdef class PyMjData(object): self._cinert = _wrap_mjtNum_2d(p.cinert, model.nbody, 10) self._ten_wrapadr = _wrap_int_1d(p.ten_wrapadr, model.ntendon) self._ten_wrapnum = _wrap_int_1d(p.ten_wrapnum, model.ntendon) + self._ten_J_rownnz = _wrap_int_1d(p.ten_J_rownnz, model.ntendon) + self._ten_J_rowadr = _wrap_int_1d(p.ten_J_rowadr, model.ntendon) + self._ten_J_colind = _wrap_int_2d(p.ten_J_colind, model.ntendon, model.nv) self._ten_length = _wrap_mjtNum_1d(p.ten_length, model.ntendon) - self._ten_moment = _wrap_mjtNum_2d(p.ten_moment, model.ntendon, model.nv) + self._ten_J = _wrap_mjtNum_2d(p.ten_J, model.ntendon, model.nv) self._wrap_obj = _wrap_int_1d(p.wrap_obj, model.nwrap*2) self._wrap_xpos = _wrap_mjtNum_2d(p.wrap_xpos, model.nwrap*2, 3) self._actuator_length = _wrap_mjtNum_1d(p.actuator_length, model.nu) @@ -2626,18 +2886,19 @@ cdef class PyMjData(object): self._efc_id = _wrap_int_1d(p.efc_id, model.njmax) self._efc_J_rownnz = _wrap_int_1d(p.efc_J_rownnz, model.njmax) self._efc_J_rowadr = _wrap_int_1d(p.efc_J_rowadr, model.njmax) + self._efc_J_rowsuper = _wrap_int_1d(p.efc_J_rowsuper, model.njmax) self._efc_J_colind = _wrap_int_2d(p.efc_J_colind, model.njmax, model.nv) self._efc_JT_rownnz = _wrap_int_1d(p.efc_JT_rownnz, model.nv) self._efc_JT_rowadr = _wrap_int_1d(p.efc_JT_rowadr, model.nv) + self._efc_JT_rowsuper = _wrap_int_1d(p.efc_JT_rowsuper, model.nv) self._efc_JT_colind = _wrap_int_2d(p.efc_JT_colind, model.nv, model.njmax) - self._efc_solref = _wrap_mjtNum_2d(p.efc_solref, model.njmax, mjNREF) - self._efc_solimp = _wrap_mjtNum_2d(p.efc_solimp, model.njmax, mjNIMP) - self._efc_margin = _wrap_mjtNum_1d(p.efc_margin, model.njmax) - self._efc_frictionloss = _wrap_mjtNum_1d(p.efc_frictionloss, model.njmax) - self._efc_pos = _wrap_mjtNum_1d(p.efc_pos, model.njmax) self._efc_J = _wrap_mjtNum_2d(p.efc_J, model.njmax, model.nv) self._efc_JT = _wrap_mjtNum_2d(p.efc_JT, model.nv, model.njmax) + self._efc_pos = _wrap_mjtNum_1d(p.efc_pos, model.njmax) + self._efc_margin = _wrap_mjtNum_1d(p.efc_margin, model.njmax) + self._efc_frictionloss = _wrap_mjtNum_1d(p.efc_frictionloss, model.njmax) self._efc_diagApprox = _wrap_mjtNum_1d(p.efc_diagApprox, model.njmax) + self._efc_KBIP = _wrap_mjtNum_2d(p.efc_KBIP, model.njmax, 4) self._efc_D = _wrap_mjtNum_1d(p.efc_D, model.njmax) self._efc_R = _wrap_mjtNum_1d(p.efc_R, model.njmax) self._efc_AR_rownnz = _wrap_int_1d(p.efc_AR_rownnz, model.njmax) @@ -2662,7 +2923,6 @@ cdef class PyMjData(object): self._efc_force = _wrap_mjtNum_1d(p.efc_force, model.njmax) self._efc_state = _wrap_int_1d(p.efc_state, model.njmax) self._qfrc_constraint = _wrap_mjtNum_1d(p.qfrc_constraint, model.nv) - self._qacc_warmstart = _wrap_mjtNum_1d(p.qacc_warmstart, model.nv) self._qfrc_inverse = _wrap_mjtNum_1d(p.qfrc_inverse, model.nv) self._cacc = _wrap_mjtNum_2d(p.cacc, model.nbody, 6) self._cfrc_int = _wrap_mjtNum_2d(p.cfrc_int, model.nbody, 6) @@ -2732,6 +2992,8 @@ cdef class PyMjData(object): @property def act(self): return self._act @property + def qacc_warmstart(self): return self._qacc_warmstart + @property def ctrl(self): return self._ctrl @property def qfrc_applied(self): return self._qfrc_applied @@ -2799,9 +3061,15 @@ cdef class PyMjData(object): @property def ten_wrapnum(self): return self._ten_wrapnum @property + def ten_J_rownnz(self): return self._ten_J_rownnz + @property + def ten_J_rowadr(self): return self._ten_J_rowadr + @property + def ten_J_colind(self): return self._ten_J_colind + @property def ten_length(self): return self._ten_length @property - def ten_moment(self): return self._ten_moment + def ten_J(self): return self._ten_J @property def wrap_obj(self): return self._wrap_obj @property @@ -2831,33 +3099,35 @@ cdef class PyMjData(object): @property def efc_J_rowadr(self): return self._efc_J_rowadr @property + def efc_J_rowsuper(self): return self._efc_J_rowsuper + @property def efc_J_colind(self): return self._efc_J_colind @property def efc_JT_rownnz(self): return self._efc_JT_rownnz @property def efc_JT_rowadr(self): return self._efc_JT_rowadr @property - def efc_JT_colind(self): return self._efc_JT_colind - @property - def efc_solref(self): return self._efc_solref + def efc_JT_rowsuper(self): return self._efc_JT_rowsuper @property - def efc_solimp(self): return self._efc_solimp + def efc_JT_colind(self): return self._efc_JT_colind @property - def efc_margin(self): return self._efc_margin + def efc_J(self): return self._efc_J @property - def efc_frictionloss(self): return self._efc_frictionloss + def efc_JT(self): return self._efc_JT @property def efc_pos(self): raise RuntimeError("active_contacts_efc_pos should be used instead of efc_pos") @property - def efc_J(self): return self._efc_J + def efc_margin(self): return self._efc_margin @property - def efc_JT(self): return self._efc_JT + def efc_frictionloss(self): return self._efc_frictionloss @property def efc_diagApprox(self): return self._efc_diagApprox @property + def efc_KBIP(self): return self._efc_KBIP + @property def efc_D(self): return self._efc_D @property def efc_R(self): return self._efc_R @@ -2906,8 +3176,6 @@ cdef class PyMjData(object): @property def qfrc_constraint(self): return self._qfrc_constraint @property - def qacc_warmstart(self): return self._qacc_warmstart - @property def qfrc_inverse(self): return self._qfrc_inverse @property def cacc(self): return self._cacc @@ -3050,6 +3318,10 @@ cdef class PyMjvPerturb(object): @select.setter def select(self, int x): self.ptr.select = x @property + def skinselect(self): return self.ptr.skinselect + @skinselect.setter + def skinselect(self, int x): self.ptr.skinselect = x + @property def active(self): return self.ptr.active @active.setter def active(self, int x): self.ptr.active = x @@ -3236,6 +3508,14 @@ cdef class PyMjvGeom(object): @texuniform.setter def texuniform(self, int x): self.ptr.texuniform = x @property + def texcoord(self): return self.ptr.texcoord + @texcoord.setter + def texcoord(self, int x): self.ptr.texcoord = x + @property + def segid(self): return self.ptr.segid + @segid.setter + def segid(self, int x): self.ptr.segid = x + @property def emission(self): return self.ptr.emission @emission.setter def emission(self, float x): self.ptr.emission = x @@ -3355,6 +3635,9 @@ cdef class PyMjvOption(object): cdef np.ndarray _geomgroup cdef np.ndarray _sitegroup + cdef np.ndarray _jointgroup + cdef np.ndarray _tendongroup + cdef np.ndarray _actuatorgroup cdef np.ndarray _flags def __cinit__(self): @@ -3369,8 +3652,11 @@ cdef class PyMjvOption(object): self.ptr = p - self._geomgroup = _wrap_mjtByte_1d(&p.geomgroup[0], 5) - self._sitegroup = _wrap_mjtByte_1d(&p.sitegroup[0], 5) + self._geomgroup = _wrap_mjtByte_1d(&p.geomgroup[0], 6) + self._sitegroup = _wrap_mjtByte_1d(&p.sitegroup[0], 6) + self._jointgroup = _wrap_mjtByte_1d(&p.jointgroup[0], 6) + self._tendongroup = _wrap_mjtByte_1d(&p.tendongroup[0], 6) + self._actuatorgroup = _wrap_mjtByte_1d(&p.actuatorgroup[0], 6) self._flags = _wrap_mjtByte_1d(&p.flags[0], mjNVISFLAG) @property @@ -3386,6 +3672,12 @@ cdef class PyMjvOption(object): @property def sitegroup(self): return self._sitegroup @property + def jointgroup(self): return self._jointgroup + @property + def tendongroup(self): return self._tendongroup + @property + def actuatorgroup(self): return self._actuatorgroup + @property def flags(self): return self._flags cdef PyMjvOption WrapMjvOption(mjvOption* p): @@ -3430,6 +3722,10 @@ cdef class PyMjvScene(object): @ngeom.setter def ngeom(self, int x): self.ptr.ngeom = x @property + def nskin(self): return self.ptr.nskin + @nskin.setter + def nskin(self, int x): self.ptr.nskin = x + @property def nlight(self): return self.ptr.nlight @nlight.setter def nlight(self, int x): self.ptr.nlight = x @@ -3467,8 +3763,10 @@ cdef class PyMjvFigure(object): cdef np.ndarray _flg_ticklabel cdef np.ndarray _gridsize + cdef np.ndarray _highlight cdef np.ndarray _gridrgb cdef np.ndarray _figurergba + cdef np.ndarray _panergba cdef np.ndarray _legendrgba cdef np.ndarray _textrgb cdef np.ndarray _xlabel @@ -3478,6 +3776,10 @@ cdef class PyMjvFigure(object): cdef np.ndarray _minwidth cdef np.ndarray _linepnt cdef np.ndarray _linewidth + cdef np.ndarray _xaxispixel + cdef np.ndarray _yaxispixel + cdef np.ndarray _xaxisdata + cdef np.ndarray _yaxisdata def __cinit__(self): self.ptr = NULL @@ -3493,8 +3795,10 @@ cdef class PyMjvFigure(object): self._flg_ticklabel = _wrap_int_1d(&p.flg_ticklabel[0], 2) self._gridsize = _wrap_int_1d(&p.gridsize[0], 2) + self._highlight = _wrap_int_1d(&p.highlight[0], 2) self._gridrgb = _wrap_float_1d(&p.gridrgb[0], 3) self._figurergba = _wrap_float_1d(&p.figurergba[0], 4) + self._panergba = _wrap_float_1d(&p.panergba[0], 4) self._legendrgba = _wrap_float_1d(&p.legendrgba[0], 4) self._textrgb = _wrap_float_1d(&p.textrgb[0], 3) self._xlabel = _wrap_char_1d(&p.xlabel[0], 100) @@ -3504,6 +3808,10 @@ cdef class PyMjvFigure(object): self._minwidth = _wrap_char_1d(&p.minwidth[0], 20) self._linepnt = _wrap_int_1d(&p.linepnt[0], 100) self._linewidth = _wrap_float_1d(&p.linewidth[0], 100) + self._xaxispixel = _wrap_int_1d(&p.xaxispixel[0], 2) + self._yaxispixel = _wrap_int_1d(&p.yaxispixel[0], 2) + self._xaxisdata = _wrap_float_1d(&p.xaxisdata[0], 2) + self._yaxisdata = _wrap_float_1d(&p.yaxisdata[0], 2) @property def flg_legend(self): return self.ptr.flg_legend @@ -3518,6 +3826,22 @@ cdef class PyMjvFigure(object): @flg_barplot.setter def flg_barplot(self, int x): self.ptr.flg_barplot = x @property + def flg_selection(self): return self.ptr.flg_selection + @flg_selection.setter + def flg_selection(self, int x): self.ptr.flg_selection = x + @property + def flg_symmetric(self): return self.ptr.flg_symmetric + @flg_symmetric.setter + def flg_symmetric(self, int x): self.ptr.flg_symmetric = x + @property + def legendoff(self): return self.ptr.legendoff + @legendoff.setter + def legendoff(self, int x): self.ptr.legendoff = x + @property + def selection(self): return self.ptr.selection + @selection.setter + def selection(self, int x): self.ptr.selection = x + @property def gridwidth(self): return self.ptr.gridwidth @gridwidth.setter def gridwidth(self, float x): self.ptr.gridwidth = x @@ -3526,10 +3850,14 @@ cdef class PyMjvFigure(object): @property def gridsize(self): return self._gridsize @property + def highlight(self): return self._highlight + @property def gridrgb(self): return self._gridrgb @property def figurergba(self): return self._figurergba @property + def panergba(self): return self._panergba + @property def legendrgba(self): return self._legendrgba @property def textrgb(self): return self._textrgb @@ -3547,6 +3875,14 @@ cdef class PyMjvFigure(object): def linepnt(self): return self._linepnt @property def linewidth(self): return self._linewidth + @property + def xaxispixel(self): return self._xaxispixel + @property + def yaxispixel(self): return self._yaxispixel + @property + def xaxisdata(self): return self._xaxisdata + @property + def yaxisdata(self): return self._yaxisdata cdef PyMjvFigure WrapMjvFigure(mjvFigure* p): cdef PyMjvFigure o = PyMjvFigure() @@ -3602,6 +3938,14 @@ cdef class PyMjrContext(object): cdef mjrContext* ptr + cdef np.ndarray _fogRGBA + cdef np.ndarray _auxWidth + cdef np.ndarray _auxHeight + cdef np.ndarray _auxSamples + cdef np.ndarray _auxFBO + cdef np.ndarray _auxFBO_r + cdef np.ndarray _auxColor + cdef np.ndarray _auxColor_r cdef np.ndarray _textureType cdef np.ndarray _texture cdef np.ndarray _charWidth @@ -3619,6 +3963,14 @@ cdef class PyMjrContext(object): self.ptr = p + self._fogRGBA = _wrap_float_1d(&p.fogRGBA[0], 4) + self._auxWidth = _wrap_int_1d(&p.auxWidth[0], 10) + self._auxHeight = _wrap_int_1d(&p.auxHeight[0], 10) + self._auxSamples = _wrap_int_1d(&p.auxSamples[0], 10) + self._auxFBO = _wrap_unsigned_int_1d(&p.auxFBO[0], 10) + self._auxFBO_r = _wrap_unsigned_int_1d(&p.auxFBO_r[0], 10) + self._auxColor = _wrap_unsigned_int_1d(&p.auxColor[0], 10) + self._auxColor_r = _wrap_unsigned_int_1d(&p.auxColor_r[0], 10) self._textureType = _wrap_int_1d(&p.textureType[0], 100) self._texture = _wrap_unsigned_int_1d(&p.texture[0], 100) self._charWidth = _wrap_int_1d(&p.charWidth[0], 127) @@ -3637,6 +3989,14 @@ cdef class PyMjrContext(object): @shadowScale.setter def shadowScale(self, float x): self.ptr.shadowScale = x @property + def fogStart(self): return self.ptr.fogStart + @fogStart.setter + def fogStart(self, float x): self.ptr.fogStart = x + @property + def fogEnd(self): return self.ptr.fogEnd + @fogEnd.setter + def fogEnd(self, float x): self.ptr.fogEnd = x + @property def shadowSize(self): return self.ptr.shadowSize @shadowSize.setter def shadowSize(self, int x): self.ptr.shadowSize = x @@ -3653,6 +4013,10 @@ cdef class PyMjrContext(object): @offSamples.setter def offSamples(self, int x): self.ptr.offSamples = x @property + def fontScale(self): return self.ptr.fontScale + @fontScale.setter + def fontScale(self, int x): self.ptr.fontScale = x + @property def offFBO(self): return self.ptr.offFBO @offFBO.setter def offFBO(self, unsigned int x): self.ptr.offFBO = x @@ -3737,6 +4101,10 @@ cdef class PyMjrContext(object): @rangeFont.setter def rangeFont(self, int x): self.ptr.rangeFont = x @property + def nskin(self): return self.ptr.nskin + @nskin.setter + def nskin(self, int x): self.ptr.nskin = x + @property def charHeight(self): return self.ptr.charHeight @charHeight.setter def charHeight(self, int x): self.ptr.charHeight = x @@ -3769,6 +4137,22 @@ cdef class PyMjrContext(object): @currentBuffer.setter def currentBuffer(self, int x): self.ptr.currentBuffer = x @property + def fogRGBA(self): return self._fogRGBA + @property + def auxWidth(self): return self._auxWidth + @property + def auxHeight(self): return self._auxHeight + @property + def auxSamples(self): return self._auxSamples + @property + def auxFBO(self): return self._auxFBO + @property + def auxFBO_r(self): return self._auxFBO_r + @property + def auxColor(self): return self._auxColor + @property + def auxColor_r(self): return self._auxColor_r + @property def textureType(self): return self._textureType @property def texture(self): return self._texture @@ -3782,6 +4166,510 @@ cdef PyMjrContext WrapMjrContext(mjrContext* p): o._set(p) return o +cdef class PyMjuiState(object): + cdef mjuiState* ptr + + + cdef list _rect + + def __cinit__(self): + self.ptr = NULL + + + @property + def uintptr(self): return self.ptr + + cdef void _set(self, mjuiState* p): + + self.ptr = p + + + self._rect = [WrapMjrRect(&p.rect[i]) for i in range(15)] + + @property + def nrect(self): return self.ptr.nrect + @nrect.setter + def nrect(self, int x): self.ptr.nrect = x + @property + def type(self): return self.ptr.type + @type.setter + def type(self, int x): self.ptr.type = x + @property + def left(self): return self.ptr.left + @left.setter + def left(self, int x): self.ptr.left = x + @property + def right(self): return self.ptr.right + @right.setter + def right(self, int x): self.ptr.right = x + @property + def middle(self): return self.ptr.middle + @middle.setter + def middle(self, int x): self.ptr.middle = x + @property + def doubleclick(self): return self.ptr.doubleclick + @doubleclick.setter + def doubleclick(self, int x): self.ptr.doubleclick = x + @property + def button(self): return self.ptr.button + @button.setter + def button(self, int x): self.ptr.button = x + @property + def control(self): return self.ptr.control + @control.setter + def control(self, int x): self.ptr.control = x + @property + def shift(self): return self.ptr.shift + @shift.setter + def shift(self, int x): self.ptr.shift = x + @property + def alt(self): return self.ptr.alt + @alt.setter + def alt(self, int x): self.ptr.alt = x + @property + def key(self): return self.ptr.key + @key.setter + def key(self, int x): self.ptr.key = x + @property + def mouserect(self): return self.ptr.mouserect + @mouserect.setter + def mouserect(self, int x): self.ptr.mouserect = x + @property + def dragrect(self): return self.ptr.dragrect + @dragrect.setter + def dragrect(self, int x): self.ptr.dragrect = x + @property + def dragbutton(self): return self.ptr.dragbutton + @dragbutton.setter + def dragbutton(self, int x): self.ptr.dragbutton = x + @property + def rect(self): return self._rect + +cdef PyMjuiState WrapMjuiState(mjuiState* p): + cdef PyMjuiState o = PyMjuiState() + o._set(p) + return o + +cdef class PyMjuiThemeSpacing(object): + cdef mjuiThemeSpacing* ptr + + + + def __cinit__(self): + self.ptr = NULL + + + @property + def uintptr(self): return self.ptr + + cdef void _set(self, mjuiThemeSpacing* p): + + self.ptr = p + + + + @property + def total(self): return self.ptr.total + @total.setter + def total(self, int x): self.ptr.total = x + @property + def scroll(self): return self.ptr.scroll + @scroll.setter + def scroll(self, int x): self.ptr.scroll = x + @property + def label(self): return self.ptr.label + @label.setter + def label(self, int x): self.ptr.label = x + @property + def section(self): return self.ptr.section + @section.setter + def section(self, int x): self.ptr.section = x + @property + def itemside(self): return self.ptr.itemside + @itemside.setter + def itemside(self, int x): self.ptr.itemside = x + @property + def itemmid(self): return self.ptr.itemmid + @itemmid.setter + def itemmid(self, int x): self.ptr.itemmid = x + @property + def itemver(self): return self.ptr.itemver + @itemver.setter + def itemver(self, int x): self.ptr.itemver = x + @property + def texthor(self): return self.ptr.texthor + @texthor.setter + def texthor(self, int x): self.ptr.texthor = x + @property + def textver(self): return self.ptr.textver + @textver.setter + def textver(self, int x): self.ptr.textver = x + @property + def linescroll(self): return self.ptr.linescroll + @linescroll.setter + def linescroll(self, int x): self.ptr.linescroll = x + @property + def samples(self): return self.ptr.samples + @samples.setter + def samples(self, int x): self.ptr.samples = x + +cdef PyMjuiThemeSpacing WrapMjuiThemeSpacing(mjuiThemeSpacing* p): + cdef PyMjuiThemeSpacing o = PyMjuiThemeSpacing() + o._set(p) + return o + +cdef class PyMjuiThemeColor(object): + cdef mjuiThemeColor* ptr + + + cdef np.ndarray _master + cdef np.ndarray _thumb + cdef np.ndarray _secttitle + cdef np.ndarray _sectfont + cdef np.ndarray _sectsymbol + cdef np.ndarray _sectpane + cdef np.ndarray _shortcut + cdef np.ndarray _fontactive + cdef np.ndarray _fontinactive + cdef np.ndarray _decorinactive + cdef np.ndarray _decorinactive2 + cdef np.ndarray _button + cdef np.ndarray _check + cdef np.ndarray _radio + cdef np.ndarray _select + cdef np.ndarray _select2 + cdef np.ndarray _slider + cdef np.ndarray _slider2 + cdef np.ndarray _edit + cdef np.ndarray _edit2 + cdef np.ndarray _cursor + + def __cinit__(self): + self.ptr = NULL + + + @property + def uintptr(self): return self.ptr + + cdef void _set(self, mjuiThemeColor* p): + + self.ptr = p + + + self._master = _wrap_float_1d(&p.master[0], 3) + self._thumb = _wrap_float_1d(&p.thumb[0], 3) + self._secttitle = _wrap_float_1d(&p.secttitle[0], 3) + self._sectfont = _wrap_float_1d(&p.sectfont[0], 3) + self._sectsymbol = _wrap_float_1d(&p.sectsymbol[0], 3) + self._sectpane = _wrap_float_1d(&p.sectpane[0], 3) + self._shortcut = _wrap_float_1d(&p.shortcut[0], 3) + self._fontactive = _wrap_float_1d(&p.fontactive[0], 3) + self._fontinactive = _wrap_float_1d(&p.fontinactive[0], 3) + self._decorinactive = _wrap_float_1d(&p.decorinactive[0], 3) + self._decorinactive2 = _wrap_float_1d(&p.decorinactive2[0], 3) + self._button = _wrap_float_1d(&p.button[0], 3) + self._check = _wrap_float_1d(&p.check[0], 3) + self._radio = _wrap_float_1d(&p.radio[0], 3) + self._select = _wrap_float_1d(&p.select[0], 3) + self._select2 = _wrap_float_1d(&p.select2[0], 3) + self._slider = _wrap_float_1d(&p.slider[0], 3) + self._slider2 = _wrap_float_1d(&p.slider2[0], 3) + self._edit = _wrap_float_1d(&p.edit[0], 3) + self._edit2 = _wrap_float_1d(&p.edit2[0], 3) + self._cursor = _wrap_float_1d(&p.cursor[0], 3) + + @property + def master(self): return self._master + @property + def thumb(self): return self._thumb + @property + def secttitle(self): return self._secttitle + @property + def sectfont(self): return self._sectfont + @property + def sectsymbol(self): return self._sectsymbol + @property + def sectpane(self): return self._sectpane + @property + def shortcut(self): return self._shortcut + @property + def fontactive(self): return self._fontactive + @property + def fontinactive(self): return self._fontinactive + @property + def decorinactive(self): return self._decorinactive + @property + def decorinactive2(self): return self._decorinactive2 + @property + def button(self): return self._button + @property + def check(self): return self._check + @property + def radio(self): return self._radio + @property + def select(self): return self._select + @property + def select2(self): return self._select2 + @property + def slider(self): return self._slider + @property + def slider2(self): return self._slider2 + @property + def edit(self): return self._edit + @property + def edit2(self): return self._edit2 + @property + def cursor(self): return self._cursor + +cdef PyMjuiThemeColor WrapMjuiThemeColor(mjuiThemeColor* p): + cdef PyMjuiThemeColor o = PyMjuiThemeColor() + o._set(p) + return o + +cdef class PyMjuiItem(object): + cdef mjuiItem* ptr + + + cdef PyMjrRect _rect + cdef np.ndarray _name + + def __cinit__(self): + self.ptr = NULL + + + @property + def uintptr(self): return self.ptr + + cdef void _set(self, mjuiItem* p): + + self.ptr = p + + + self._rect = WrapMjrRect(&p.rect) + self._name = _wrap_char_1d(&p.name[0], 40) + + @property + def type(self): return self.ptr.type + @type.setter + def type(self, int x): self.ptr.type = x + @property + def state(self): return self.ptr.state + @state.setter + def state(self, int x): self.ptr.state = x + @property + def sectionid(self): return self.ptr.sectionid + @sectionid.setter + def sectionid(self, int x): self.ptr.sectionid = x + @property + def itemid(self): return self.ptr.itemid + @itemid.setter + def itemid(self, int x): self.ptr.itemid = x + @property + def rect(self): return self._rect + @property + def name(self): return self._name + +cdef PyMjuiItem WrapMjuiItem(mjuiItem* p): + cdef PyMjuiItem o = PyMjuiItem() + o._set(p) + return o + +cdef class PyMjuiSection(object): + cdef mjuiSection* ptr + + + cdef PyMjrRect _rtitle + cdef PyMjrRect _rcontent + cdef np.ndarray _name + cdef list _item + + def __cinit__(self): + self.ptr = NULL + + + @property + def uintptr(self): return self.ptr + + cdef void _set(self, mjuiSection* p): + + self.ptr = p + + + self._rtitle = WrapMjrRect(&p.rtitle) + self._rcontent = WrapMjrRect(&p.rcontent) + self._name = _wrap_char_1d(&p.name[0], 40) + self._item = [WrapMjuiItem(&p.item[i]) for i in range(80)] + + @property + def state(self): return self.ptr.state + @state.setter + def state(self, int x): self.ptr.state = x + @property + def modifier(self): return self.ptr.modifier + @modifier.setter + def modifier(self, int x): self.ptr.modifier = x + @property + def shortcut(self): return self.ptr.shortcut + @shortcut.setter + def shortcut(self, int x): self.ptr.shortcut = x + @property + def nitem(self): return self.ptr.nitem + @nitem.setter + def nitem(self, int x): self.ptr.nitem = x + @property + def rtitle(self): return self._rtitle + @property + def rcontent(self): return self._rcontent + @property + def name(self): return self._name + @property + def item(self): return self._item + +cdef PyMjuiSection WrapMjuiSection(mjuiSection* p): + cdef PyMjuiSection o = PyMjuiSection() + o._set(p) + return o + +cdef class PyMjUI(object): + cdef mjUI* ptr + + + cdef PyMjuiThemeSpacing _spacing + cdef PyMjuiThemeColor _color + cdef np.ndarray _edittext + cdef list _sect + + def __cinit__(self): + self.ptr = NULL + + + @property + def uintptr(self): return self.ptr + + cdef void _set(self, mjUI* p): + + self.ptr = p + + + self._spacing = WrapMjuiThemeSpacing(&p.spacing) + self._color = WrapMjuiThemeColor(&p.color) + self._edittext = _wrap_char_1d(&p.edittext[0], 500) + self._sect = [WrapMjuiSection(&p.sect[i]) for i in range(10)] + + @property + def spacing(self): return self._spacing + @property + def color(self): return self._color + @property + def rectid(self): return self.ptr.rectid + @rectid.setter + def rectid(self, int x): self.ptr.rectid = x + @property + def auxid(self): return self.ptr.auxid + @auxid.setter + def auxid(self, int x): self.ptr.auxid = x + @property + def radiocol(self): return self.ptr.radiocol + @radiocol.setter + def radiocol(self, int x): self.ptr.radiocol = x + @property + def width(self): return self.ptr.width + @width.setter + def width(self, int x): self.ptr.width = x + @property + def height(self): return self.ptr.height + @height.setter + def height(self, int x): self.ptr.height = x + @property + def maxheight(self): return self.ptr.maxheight + @maxheight.setter + def maxheight(self, int x): self.ptr.maxheight = x + @property + def scroll(self): return self.ptr.scroll + @scroll.setter + def scroll(self, int x): self.ptr.scroll = x + @property + def mousesect(self): return self.ptr.mousesect + @mousesect.setter + def mousesect(self, int x): self.ptr.mousesect = x + @property + def mouseitem(self): return self.ptr.mouseitem + @mouseitem.setter + def mouseitem(self, int x): self.ptr.mouseitem = x + @property + def mousehelp(self): return self.ptr.mousehelp + @mousehelp.setter + def mousehelp(self, int x): self.ptr.mousehelp = x + @property + def editsect(self): return self.ptr.editsect + @editsect.setter + def editsect(self, int x): self.ptr.editsect = x + @property + def edititem(self): return self.ptr.edititem + @edititem.setter + def edititem(self, int x): self.ptr.edititem = x + @property + def editcursor(self): return self.ptr.editcursor + @editcursor.setter + def editcursor(self, int x): self.ptr.editcursor = x + @property + def editscroll(self): return self.ptr.editscroll + @editscroll.setter + def editscroll(self, int x): self.ptr.editscroll = x + @property + def nsect(self): return self.ptr.nsect + @nsect.setter + def nsect(self, int x): self.ptr.nsect = x + @property + def edittext(self): return self._edittext + @property + def sect(self): return self._sect + +cdef PyMjUI WrapMjUI(mjUI* p): + cdef PyMjUI o = PyMjUI() + o._set(p) + return o + +cdef class PyMjuiDef(object): + cdef mjuiDef* ptr + + + cdef np.ndarray _name + cdef np.ndarray _other + + def __cinit__(self): + self.ptr = NULL + + + @property + def uintptr(self): return self.ptr + + cdef void _set(self, mjuiDef* p): + + self.ptr = p + + + self._name = _wrap_char_1d(&p.name[0], 40) + self._other = _wrap_char_1d(&p.other[0], 500) + + @property + def type(self): return self.ptr.type + @type.setter + def type(self, int x): self.ptr.type = x + @property + def state(self): return self.ptr.state + @state.setter + def state(self, int x): self.ptr.state = x + @property + def name(self): return self._name + @property + def other(self): return self._other + +cdef PyMjuiDef WrapMjuiDef(mjuiDef* p): + cdef PyMjuiDef o = PyMjuiDef() + o._set(p) + return o + cdef inline np.ndarray _wrap_char_1d(char* a, int shape0): if shape0 == 0: return None cdef char[:] b = a @@ -3897,11 +4785,14 @@ def _mj_forward(PyMjModel m, PyMjData d): def _mj_inverse(PyMjModel m, PyMjData d): mj_inverse(m.ptr, d.ptr) -def _mj_forwardSkip(PyMjModel m, PyMjData d, int skipstage, int skipsensorenergy): - mj_forwardSkip(m.ptr, d.ptr, skipstage, skipsensorenergy) +def _mj_forwardSkip(PyMjModel m, PyMjData d, int skipstage, int skipsensor): + mj_forwardSkip(m.ptr, d.ptr, skipstage, skipsensor) -def _mj_inverseSkip(PyMjModel m, PyMjData d, int skipstage, int skipsensorenergy): - mj_inverseSkip(m.ptr, d.ptr, skipstage, skipsensorenergy) +def _mj_inverseSkip(PyMjModel m, PyMjData d, int skipstage, int skipsensor): + mj_inverseSkip(m.ptr, d.ptr, skipstage, skipsensor) + +def _mj_defaultLROpt(PyMjLROpt opt): + mj_defaultLROpt(opt.ptr) def _mj_defaultSolRefImp(np.ndarray[np.float64_t, mode="c", ndim=1] solref, np.ndarray[np.float64_t, mode="c", ndim=1] solimp): mj_defaultSolRefImp(&solref[0], &solimp[0]) @@ -3936,8 +4827,11 @@ def _mj_deleteData(PyMjData d): def _mj_resetCallbacks(): mj_resetCallbacks() -def _mj_setConst(PyMjModel m, PyMjData d, int flg_actrange): - mj_setConst(m.ptr, d.ptr, flg_actrange) +def _mj_setConst(PyMjModel m, PyMjData d): + mj_setConst(m.ptr, d.ptr) + +def _mj_setLengthRange(PyMjModel m, PyMjData d, int index, PyMjLROpt opt, str error, int error_sz): + return mj_setLengthRange(m.ptr, d.ptr, index, opt.ptr, error.encode(), error_sz) def _mj_printModel(PyMjModel m, str filename): mj_printModel(m.ptr, filename.encode()) @@ -4041,6 +4935,9 @@ def _mj_comVel(PyMjModel m, PyMjData d): def _mj_passive(PyMjModel m, PyMjData d): mj_passive(m.ptr, d.ptr) +def _mj_subtreeVel(PyMjModel m, PyMjData d): + mj_subtreeVel(m.ptr, d.ptr) + def _mj_rne(PyMjModel m, PyMjData d, int flg_acc, np.ndarray[np.float64_t, mode="c", ndim=1] result): mj_rne(m.ptr, d.ptr, flg_acc, &result[0]) @@ -4107,6 +5004,9 @@ def _mj_fullM(PyMjModel m, np.ndarray[np.float64_t, mode="c", ndim=1] dst, np.nd def _mj_mulM(PyMjModel m, PyMjData d, np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] vec): mj_mulM(m.ptr, d.ptr, &res[0], &vec[0]) +def _mj_mulM2(PyMjModel m, PyMjData d, np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] vec): + mj_mulM2(m.ptr, d.ptr, &res[0], &vec[0]) + def _mj_addM(PyMjModel m, PyMjData d, np.ndarray[np.float64_t, mode="c", ndim=1] dst, uintptr_t rownnz, uintptr_t rowadr, uintptr_t colind): mj_addM(m.ptr, d.ptr, &dst[0], rownnz, rowadr, colind) @@ -4119,20 +5019,20 @@ def _mj_objectVelocity(PyMjModel m, PyMjData d, int objtype, int objid, np.ndarr def _mj_objectAcceleration(PyMjModel m, PyMjData d, int objtype, int objid, np.ndarray[np.float64_t, mode="c", ndim=1] res, int flg_local): mj_objectAcceleration(m.ptr, d.ptr, objtype, objid, &res[0], flg_local) -def _mj_differentiatePos(PyMjModel m, np.ndarray[np.float64_t, mode="c", ndim=1] qvel, float dt, np.ndarray[np.float64_t, mode="c", ndim=1] qpos1, np.ndarray[np.float64_t, mode="c", ndim=1] qpos2): - mj_differentiatePos(m.ptr, &qvel[0], dt, &qpos1[0], &qpos2[0]) - def _mj_contactForce(PyMjModel m, PyMjData d, int id, np.ndarray[np.float64_t, mode="c", ndim=1] result): mj_contactForce(m.ptr, d.ptr, id, &result[0]) +def _mj_differentiatePos(PyMjModel m, np.ndarray[np.float64_t, mode="c", ndim=1] qvel, float dt, np.ndarray[np.float64_t, mode="c", ndim=1] qpos1, np.ndarray[np.float64_t, mode="c", ndim=1] qpos2): + mj_differentiatePos(m.ptr, &qvel[0], dt, &qpos1[0], &qpos2[0]) + def _mj_integratePos(PyMjModel m, np.ndarray[np.float64_t, mode="c", ndim=1] qpos, np.ndarray[np.float64_t, mode="c", ndim=1] qvel, float dt): mj_integratePos(m.ptr, &qpos[0], &qvel[0], dt) def _mj_normalizeQuat(PyMjModel m, np.ndarray[np.float64_t, mode="c", ndim=1] qpos): mj_normalizeQuat(m.ptr, &qpos[0]) -def _mj_local2Global(PyMjData d, np.ndarray[np.float64_t, mode="c", ndim=1] xpos, np.ndarray[np.float64_t, mode="c", ndim=1] xmat, np.ndarray[np.float64_t, mode="c", ndim=1] pos, np.ndarray[np.float64_t, mode="c", ndim=1] quat, int body): - mj_local2Global(d.ptr, &xpos[0], &xmat[0], &pos[0], &quat[0], body) +def _mj_local2Global(PyMjData d, np.ndarray[np.float64_t, mode="c", ndim=1] xpos, np.ndarray[np.float64_t, mode="c", ndim=1] xmat, np.ndarray[np.float64_t, mode="c", ndim=1] pos, np.ndarray[np.float64_t, mode="c", ndim=1] quat, int body, int sameframe): + mj_local2Global(d.ptr, &xpos[0], &xmat[0], &pos[0], &quat[0], body, sameframe) def _mj_getTotalmass(PyMjModel m): return mj_getTotalmass(m.ptr) @@ -4197,8 +5097,8 @@ def _mjv_applyPerturbPose(PyMjModel m, PyMjData d, PyMjvPerturb pert, int flg_pa def _mjv_applyPerturbForce(PyMjModel m, PyMjData d, PyMjvPerturb pert): mjv_applyPerturbForce(m.ptr, d.ptr, pert.ptr) -def _mjv_select(PyMjModel m, PyMjData d, PyMjvOption vopt, float aspectratio, float relx, float rely, PyMjvScene scn, np.ndarray[np.float64_t, mode="c", ndim=1] selpnt): - return mjv_select(m.ptr, d.ptr, vopt.ptr, aspectratio, relx, rely, scn.ptr, &selpnt[0]) +def _mjv_select(PyMjModel m, PyMjData d, PyMjvOption vopt, float aspectratio, float relx, float rely, PyMjvScene scn, np.ndarray[np.float64_t, mode="c", ndim=1] selpnt, uintptr_t geomid, uintptr_t skinid): + return mjv_select(m.ptr, d.ptr, vopt.ptr, aspectratio, relx, rely, scn.ptr, &selpnt[0], geomid, skinid) def _mjv_defaultOption(PyMjvOption opt): mjv_defaultOption(opt.ptr) @@ -4209,8 +5109,11 @@ def _mjv_defaultFigure(PyMjvFigure fig): def _mjv_makeConnector(PyMjvGeom geom, int type, float width, float a0, float a1, float a2, float b0, float b1, float b2): mjv_makeConnector(geom.ptr, type, width, a0, a1, a2, b0, b1, b2) -def _mjv_makeScene(PyMjvScene scn, int maxgeom): - mjv_makeScene(scn.ptr, maxgeom) +def _mjv_defaultScene(PyMjvScene scn): + mjv_defaultScene(scn.ptr) + +def _mjv_makeScene(PyMjModel m, PyMjvScene scn, int maxgeom): + mjv_makeScene(m.ptr, scn.ptr, maxgeom) def _mjv_freeScene(PyMjvScene scn): mjv_freeScene(scn.ptr) @@ -4221,15 +5124,27 @@ def _mjv_updateScene(PyMjModel m, PyMjData d, PyMjvOption opt, PyMjvPerturb pert def _mjv_addGeoms(PyMjModel m, PyMjData d, PyMjvOption opt, PyMjvPerturb pert, int catmask, PyMjvScene scn): mjv_addGeoms(m.ptr, d.ptr, opt.ptr, pert.ptr, catmask, scn.ptr) +def _mjv_makeLights(PyMjModel m, PyMjData d, PyMjvScene scn): + mjv_makeLights(m.ptr, d.ptr, scn.ptr) + def _mjv_updateCamera(PyMjModel m, PyMjData d, PyMjvCamera cam, PyMjvScene scn): mjv_updateCamera(m.ptr, d.ptr, cam.ptr, scn.ptr) +def _mjv_updateSkin(PyMjModel m, PyMjData d, PyMjvScene scn): + mjv_updateSkin(m.ptr, d.ptr, scn.ptr) + def _mjr_defaultContext(PyMjrContext con): mjr_defaultContext(con.ptr) def _mjr_makeContext(PyMjModel m, PyMjrContext con, int fontscale): mjr_makeContext(m.ptr, con.ptr, fontscale) +def _mjr_changeFont(int fontscale, PyMjrContext con): + mjr_changeFont(fontscale, con.ptr) + +def _mjr_addAux(int index, int width, int height, int samples, PyMjrContext con): + mjr_addAux(index, width, height, samples, con.ptr) + def _mjr_freeContext(PyMjrContext con): mjr_freeContext(con.ptr) @@ -4242,12 +5157,21 @@ def _mjr_uploadMesh(PyMjModel m, PyMjrContext con, int meshid): def _mjr_uploadHField(PyMjModel m, PyMjrContext con, int hfieldid): mjr_uploadHField(m.ptr, con.ptr, hfieldid) +def _mjr_restoreBuffer(PyMjrContext con): + mjr_restoreBuffer(con.ptr) + def _mjr_setBuffer(int framebuffer, PyMjrContext con): mjr_setBuffer(framebuffer, con.ptr) def _mjr_blitBuffer(PyMjrRect src, PyMjrRect dst, int flg_color, int flg_depth, PyMjrContext con): mjr_blitBuffer(src.ptr[0], dst.ptr[0], flg_color, flg_depth, con.ptr) +def _mjr_setAux(int index, PyMjrContext con): + mjr_setAux(index, con.ptr) + +def _mjr_blitAux(int index, PyMjrRect src, int left, int bottom, PyMjrContext con): + mjr_blitAux(index, src.ptr[0], left, bottom, con.ptr) + def _mjr_overlay(int font, int gridpos, PyMjrRect viewport, str overlay, str overlay2, PyMjrContext con): mjr_overlay(font, gridpos, viewport.ptr[0], overlay.encode(), overlay2.encode(), con.ptr) @@ -4263,6 +5187,24 @@ def _mjr_finish(): def _mjr_getError(): return mjr_getError() +def _mjr_findRect(int x, int y, int nrect, PyMjrRect rect): + return mjr_findRect(x, y, nrect, rect.ptr) + +def _mjui_add(PyMjUI ui, PyMjuiDef _def): + mjui_add(ui.ptr, _def.ptr) + +def _mjui_resize(PyMjUI ui, PyMjrContext con): + mjui_resize(ui.ptr, con.ptr) + +def _mjui_update(int section, int item, PyMjUI ui, PyMjuiState state, PyMjrContext con): + mjui_update(section, item, ui.ptr, state.ptr, con.ptr) + +def _mjui_event(PyMjUI ui, PyMjuiState state, PyMjrContext con): + return WrapMjuiItem(mjui_event(ui.ptr, state.ptr, con.ptr)) + +def _mjui_render(PyMjUI ui, PyMjuiState state, PyMjrContext con): + mjui_render(ui.ptr, state.ptr, con.ptr) + def _mju_error(str msg): mju_error(msg.encode()) @@ -4356,6 +5298,12 @@ def _mju_zero(np.ndarray[np.float64_t, mode="c", ndim=1] res, int n): def _mju_copy(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] data, int n): mju_copy(&res[0], &data[0], n) +def _mju_sum(np.ndarray[np.float64_t, mode="c", ndim=1] vec, int n): + return mju_sum(&vec[0], n) + +def _mju_L1(np.ndarray[np.float64_t, mode="c", ndim=1] vec, int n): + return mju_L1(&vec[0], n) + def _mju_scl(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] vec, float scl, int n): mju_scl(&res[0], &vec[0], scl, n) @@ -4410,33 +5358,6 @@ def _mju_sqrMatTD(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np. def _mju_transformSpatial(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] vec, int flg_force, np.ndarray[np.float64_t, mode="c", ndim=1] newpos, np.ndarray[np.float64_t, mode="c", ndim=1] oldpos, np.ndarray[np.float64_t, mode="c", ndim=1] rotnew2old): mju_transformSpatial(&res[0], &vec[0], flg_force, &newpos[0], &oldpos[0], &rotnew2old[0]) -def _mju_dotSparse(np.ndarray[np.float64_t, mode="c", ndim=1] vec1, np.ndarray[np.float64_t, mode="c", ndim=1] vec2, int nnz1, uintptr_t ind1): - return mju_dotSparse(&vec1[0], &vec2[0], nnz1, ind1) - -def _mju_dotSparse2(np.ndarray[np.float64_t, mode="c", ndim=1] vec1, np.ndarray[np.float64_t, mode="c", ndim=1] vec2, int nnz1, uintptr_t ind1, int nnz2, uintptr_t ind2): - return mju_dotSparse2(&vec1[0], &vec2[0], nnz1, ind1, nnz2, ind2) - -def _mju_dense2sparse(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] mat, int nr, int nc, uintptr_t rownnz, uintptr_t rowadr, uintptr_t colind): - mju_dense2sparse(&res[0], &mat[0], nr, nc, rownnz, rowadr, colind) - -def _mju_sparse2dense(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] mat, int nr, int nc, uintptr_t rownnz, uintptr_t rowadr, uintptr_t colind): - mju_sparse2dense(&res[0], &mat[0], nr, nc, rownnz, rowadr, colind) - -def _mju_mulMatVecSparse(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] mat, np.ndarray[np.float64_t, mode="c", ndim=1] vec, int nr, uintptr_t rownnz, uintptr_t rowadr, uintptr_t colind): - mju_mulMatVecSparse(&res[0], &mat[0], &vec[0], nr, rownnz, rowadr, colind) - -def _mju_compressSparse(np.ndarray[np.float64_t, mode="c", ndim=1] mat, int nr, int nc, uintptr_t rownnz, uintptr_t rowadr, uintptr_t colind): - mju_compressSparse(&mat[0], nr, nc, rownnz, rowadr, colind) - -def _mju_combineSparse(np.ndarray[np.float64_t, mode="c", ndim=1] dst, np.ndarray[np.float64_t, mode="c", ndim=1] src, int n, float a, float b, int dst_nnz, int src_nnz, uintptr_t dst_ind, uintptr_t src_ind, np.ndarray[np.float64_t, mode="c", ndim=1] scratch, int nscratch): - return mju_combineSparse(&dst[0], &src[0], n, a, b, dst_nnz, src_nnz, dst_ind, src_ind, &scratch[0], nscratch) - -def _mju_sqrMatTDSparse(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] mat, np.ndarray[np.float64_t, mode="c", ndim=1] matT, np.ndarray[np.float64_t, mode="c", ndim=1] diag, int nr, int nc, uintptr_t res_rownnz, uintptr_t res_rowadr, uintptr_t res_colind, uintptr_t rownnz, uintptr_t rowadr, uintptr_t colind, uintptr_t rownnzT, uintptr_t rowadrT, uintptr_t colindT, np.ndarray[np.float64_t, mode="c", ndim=1] scratch, int nscratch): - mju_sqrMatTDSparse(&res[0], &mat[0], &matT[0], &diag[0], nr, nc, res_rownnz, res_rowadr, res_colind, rownnz, rowadr, colind, rownnzT, rowadrT, colindT, &scratch[0], nscratch) - -def _mju_transposeSparse(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] mat, int nr, int nc, uintptr_t res_rownnz, uintptr_t res_rowadr, uintptr_t res_colind, uintptr_t rownnz, uintptr_t rowadr, uintptr_t colind): - mju_transposeSparse(&res[0], &mat[0], nr, nc, res_rownnz, res_rowadr, res_colind, rownnz, rowadr, colind) - def _mju_rotVecQuat(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] vec, np.ndarray[np.float64_t, mode="c", ndim=1] quat): mju_rotVecQuat(&res[0], &vec[0], &quat[0]) @@ -4455,6 +5376,9 @@ def _mju_axisAngle2Quat(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarr def _mju_quat2Vel(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] quat, float dt): mju_quat2Vel(&res[0], &quat[0], dt) +def _mju_subQuat(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] qa, np.ndarray[np.float64_t, mode="c", ndim=1] qb): + mju_subQuat(&res[0], &qa[0], &qb[0]) + def _mju_quat2Mat(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] quat): mju_quat2Mat(&res[0], &quat[0]) @@ -4479,8 +5403,8 @@ def _mju_negPose(np.ndarray[np.float64_t, mode="c", ndim=1] posres, np.ndarray[n def _mju_trnVecPose(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] pos, np.ndarray[np.float64_t, mode="c", ndim=1] quat, np.ndarray[np.float64_t, mode="c", ndim=1] vec): mju_trnVecPose(&res[0], &pos[0], &quat[0], &vec[0]) -def _mju_cholFactor(np.ndarray[np.float64_t, mode="c", ndim=1] mat, int n): - return mju_cholFactor(&mat[0], n) +def _mju_cholFactor(np.ndarray[np.float64_t, mode="c", ndim=1] mat, int n, float mindiag): + return mju_cholFactor(&mat[0], n, mindiag) def _mju_cholSolve(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] mat, np.ndarray[np.float64_t, mode="c", ndim=1] vec, int n): mju_cholSolve(&res[0], &mat[0], &vec[0], n) @@ -4488,26 +5412,17 @@ def _mju_cholSolve(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np def _mju_cholUpdate(np.ndarray[np.float64_t, mode="c", ndim=1] mat, np.ndarray[np.float64_t, mode="c", ndim=1] x, int n, int flg_plus): return mju_cholUpdate(&mat[0], &x[0], n, flg_plus) -def _mju_cholFactorSparse(np.ndarray[np.float64_t, mode="c", ndim=1] mat, int n, uintptr_t rownnz, uintptr_t rowadr, uintptr_t colind, np.ndarray[np.float64_t, mode="c", ndim=1] scratch, int nscratch): - return mju_cholFactorSparse(&mat[0], n, rownnz, rowadr, colind, &scratch[0], nscratch) - -def _mju_cholSolveSparse(np.ndarray[np.float64_t, mode="c", ndim=1] res, np.ndarray[np.float64_t, mode="c", ndim=1] mat, np.ndarray[np.float64_t, mode="c", ndim=1] vec, int n, uintptr_t rownnz, uintptr_t rowadr, uintptr_t colind): - mju_cholSolveSparse(&res[0], &mat[0], &vec[0], n, rownnz, rowadr, colind) - -def _mju_cholUpdateSparse(np.ndarray[np.float64_t, mode="c", ndim=1] mat, np.ndarray[np.float64_t, mode="c", ndim=1] x, int n, int flg_plus, uintptr_t rownnz, uintptr_t rowadr, uintptr_t colind, int x_nnz, uintptr_t x_ind, np.ndarray[np.float64_t, mode="c", ndim=1] scratch, int nscratch): - return mju_cholUpdateSparse(&mat[0], &x[0], n, flg_plus, rownnz, rowadr, colind, x_nnz, x_ind, &scratch[0], nscratch) - def _mju_eig3(np.ndarray[np.float64_t, mode="c", ndim=1] eigval, np.ndarray[np.float64_t, mode="c", ndim=1] eigvec, np.ndarray[np.float64_t, mode="c", ndim=1] quat, np.ndarray[np.float64_t, mode="c", ndim=1] mat): return mju_eig3(&eigval[0], &eigvec[0], &quat[0], &mat[0]) -def _mju_muscleFVL(float len, float vel, float lmin, float lmax, np.ndarray[np.float64_t, mode="c", ndim=1] prm): - return mju_muscleFVL(len, vel, lmin, lmax, &prm[0]) +def _mju_muscleGain(float len, float vel, np.ndarray[np.float64_t, mode="c", ndim=1] lengthrange, float acc0, np.ndarray[np.float64_t, mode="c", ndim=1] prm): + return mju_muscleGain(len, vel, &lengthrange[0], acc0, &prm[0]) -def _mju_musclePassive(float len, float lmin, float lmax, np.ndarray[np.float64_t, mode="c", ndim=1] prm): - return mju_musclePassive(len, lmin, lmax, &prm[0]) +def _mju_muscleBias(float len, np.ndarray[np.float64_t, mode="c", ndim=1] lengthrange, float acc0, np.ndarray[np.float64_t, mode="c", ndim=1] prm): + return mju_muscleBias(len, &lengthrange[0], acc0, &prm[0]) -def _mju_pneumatic(float len, float len0, float vel, np.ndarray[np.float64_t, mode="c", ndim=1] prm, float act, float ctrl, float timestep, np.ndarray[np.float64_t, mode="c", ndim=1] jac): - return mju_pneumatic(len, len0, vel, &prm[0], act, ctrl, timestep, &jac[0]) +def _mju_muscleDynamics(float ctrl, float act, np.ndarray[np.float64_t, mode="c", ndim=1] prm): + return mju_muscleDynamics(ctrl, act, &prm[0]) def _mju_encodePyramid(np.ndarray[np.float64_t, mode="c", ndim=1] pyramid, np.ndarray[np.float64_t, mode="c", ndim=1] force, np.ndarray[np.float64_t, mode="c", ndim=1] mu, int dim): mju_encodePyramid(&pyramid[0], &force[0], &mu[0], dim) diff --git a/mujoco_py/mjrendercontext.pyx b/mujoco_py/mjrendercontext.pyx index 06fc90e5..b3e0a421 100644 --- a/mujoco_py/mjrendercontext.pyx +++ b/mujoco_py/mjrendercontext.pyx @@ -33,7 +33,7 @@ cdef class MjRenderContext(object): def __cinit__(self): maxgeom = 1000 - mjv_makeScene(&self._scn, maxgeom) + mjv_makeScene(self._model_ptr, &self._scn, maxgeom) mjv_defaultCamera(&self._cam) mjv_defaultOption(&self._vopt) mjr_defaultContext(&self._con) diff --git a/mujoco_py/pxd/mjdata.pxd b/mujoco_py/pxd/mjdata.pxd index 6d154834..d76f5f67 100644 --- a/mujoco_py/pxd/mjdata.pxd +++ b/mujoco_py/pxd/mjdata.pxd @@ -1,6 +1,3 @@ -include "mjmodel.pxd" - - cdef extern from "mjdata.h" nogil: #---------------------------- primitive types (mjt) ------------------------------------ @@ -137,6 +134,7 @@ cdef extern from "mjdata.h" nogil: mjtNum* qpos # position (nq x 1) mjtNum* qvel # velocity (nv x 1) mjtNum* act # actuator activation (na x 1) + mjtNum* qacc_warmstart # acceleration used for warmstart (nv x 1) # control mjtNum* ctrl # control (nu x 1) @@ -184,8 +182,11 @@ cdef extern from "mjdata.h" nogil: # computed by mj_fwdPosition/mj_tendon int* ten_wrapadr # start address of tendon's path (ntendon x 1) int* ten_wrapnum # number of wrap points in path (ntendon x 1) + int* ten_J_rownnz # number of non-zeros in Jacobian row (ntendon x 1) + int* ten_J_rowadr # row start address in colind array (ntendon x 1) + int* ten_J_colind # column indices in sparse Jacobian (ntendon x nv) mjtNum* ten_length # tendon lengths (ntendon x 1) - mjtNum* ten_moment # tendon moment arms (ntendon x nv) + mjtNum* ten_J # tendon Jacobian (ntendon x nv) int* wrap_obj # geom id; -1: site; -2: pulley (nwrap*2 x 1) mjtNum* wrap_xpos # Cartesian 3D points in all path (nwrap*2 x 3) @@ -210,18 +211,21 @@ cdef extern from "mjdata.h" nogil: int* efc_id # id of object of specified type (njmax x 1) int* efc_J_rownnz # number of non-zeros in Jacobian row (njmax x 1) int* efc_J_rowadr # row start address in colind array (njmax x 1) + int* efc_J_rowsuper # number of subsequent rows in supernode (njmax x 1) int* efc_J_colind # column indices in sparse Jacobian (njmax x nv) int* efc_JT_rownnz # number of non-zeros in Jacobian row T (nv x 1) int* efc_JT_rowadr # row start address in colind array T (nv x 1) + int* efc_JT_rowsuper # number of subsequent rows in supernode T (nv x 1) int* efc_JT_colind # column indices in sparse Jacobian T (nv x njmax) mjtNum* efc_solref # constraint solver reference (njmax x mjNREF) mjtNum* efc_solimp # constraint solver impedance (njmax x mjNIMP) - mjtNum* efc_margin # inclusion margin (contact) (njmax x 1) - mjtNum* efc_frictionloss # frictionloss (friction) (njmax x 1) - mjtNum* efc_pos # constraint position (equality, contact) (njmax x 1) mjtNum* efc_J # constraint Jacobian (njmax x nv) mjtNum* efc_JT # sparse constraint Jacobian transposed (nv x njmax) + mjtNum* efc_pos # constraint position (equality, contact) (njmax x 1) + mjtNum* efc_margin # inclusion margin (contact) (njmax x 1) + mjtNum* efc_frictionloss # frictionloss (friction) (njmax x 1) mjtNum* efc_diagApprox # approximation to diagonal of A (njmax x 1) + mjtNum* efc_KBIP # stiffness, damping, impedance, imp' (njmax x 4) mjtNum* efc_D # constraint mass (njmax x 1) mjtNum* efc_R # inverse constraint mass (njmax x 1) @@ -270,7 +274,6 @@ cdef extern from "mjdata.h" nogil: mjtNum* efc_force # constraint force in constraint space (njmax x 1) int* efc_state # constraint state (mjtConstraintState) (njmax x 1) mjtNum* qfrc_constraint # constraint force (nv x 1) - mjtNum* qacc_warmstart # acceleration used for warmstart (nv x 1) # computed by mj_inverse mjtNum* qfrc_inverse # net external force; should equal: (nv x 1) diff --git a/mujoco_py/pxd/mjmodel.pxd b/mujoco_py/pxd/mjmodel.pxd index 216ef35b..691f057c 100644 --- a/mujoco_py/pxd/mjmodel.pxd +++ b/mujoco_py/pxd/mjmodel.pxd @@ -11,7 +11,6 @@ cdef struct mjVisual_quality: # rendering quality int offsamples # number of multisamples for offscreen rendering int numslices # number of slices for Glu drawing int numstacks # number of stacks for Glu drawing - int numarrows # number of arrows for torque rendering int numquads # number of quads for box rendering cdef struct mjVisual_headlight: # head light @@ -30,8 +29,10 @@ cdef struct mjVisual_map: # mapping float fogend # OpenGL fog ends at fogend * mjModel.stat.extent float znear # near clipping plane = znear * mjModel.stat.extent float zfar # far clipping plane = zfar * mjModel.stat.extent + float haze # haze ratio float shadowclip # directional light: shadowclip * mjModel.stat.extent float shadowscale # spot light: shadowscale * light.cutoff + float actuatortendon # scale tendon width cdef struct mjVisual_scale: # scale of decor elements relative to mean body size float forcewidth # width of force arrow @@ -53,10 +54,13 @@ cdef struct mjVisual_scale: # scale of decor elements relative to mean body cdef struct mjVisual_rgba: # color of decor elements float fog[4] # external force + float haze[4] # haze float force[4] # external force float inertia[4] # inertia box float joint[4] # joint float actuator[4] # actuator + float actuatornegative[4] # actuator, negative limit + float actuatorpositive[4] # actuator, positive limit float com[4] # center of mass float camera[4] # camera object float light[4] # light object @@ -66,6 +70,8 @@ cdef struct mjVisual_rgba: # color of decor elements float contactforce[4] # contact force float contactfriction[4] # contact friction force float contacttorque[4] # contact torque + float contactgap[4] # contact point in gap + float rangefinder[4] # rangefinder ray float constraint[4] # constraint float slidercrank[4] # slidercrank float crankbroken[4] # used when crank must be stretched/broken @@ -73,6 +79,7 @@ cdef struct mjVisual_rgba: # color of decor elements cdef extern from "mjmodel.h" nogil: # ---------------------------- floating-point definitions ------------------------------- ctypedef double mjtNum + # global constants enum: mjPI enum: mjMAXVAL @@ -386,8 +393,6 @@ cdef extern from "mjmodel.h" nogil: # discrete settings int integrator # integration mode (mjtIntegrator) int collision # collision mode (mjtCollision) - int impedance # how to interpret solimp (mjtImp) - int reference # how to interpret solref (mjtRef) int cone # type of friction cone (mjtCone) int jacobian # type of Jacobian (mjtJacobian) int solver # solver mode (mjtSolver) @@ -397,6 +402,23 @@ cdef extern from "mjmodel.h" nogil: int disableflags # bit flags for disabling standard features int enableflags # bit flags for enabling optional features + #------------------------------ mjLROpt ------------------------------------------------ + + ctypedef struct mjLROpt: + # flags + int mode # which actuators to process (mjtLRMode) + int useexisting # use existing length range if available + int uselimit # use joint and tendon limits if available + + # algorithm parameters + mjtNum accel # target acceleration used to compute force + mjtNum maxforce # maximum force; 0: no limit + mjtNum timeconst # time constant for velocity reduction; min 0.01 + mjtNum timestep # simulation timestep; 0: use mjOption.timestep + mjtNum inttotal # total simulation time interval + mjtNum inteval # evaluation time interval (at the end) + mjtNum tolrange # convergence tolerance (relative to range) + #------------------------------ mjVisual ----------------------------------------------- @@ -435,8 +457,15 @@ cdef extern from "mjmodel.h" nogil: int nlight # number of lights int nmesh # number of meshes int nmeshvert # number of vertices in all meshes + int nmeshtexvert; # number of vertices with texcoords in all meshes int nmeshface # number of triangular faces in all meshes int nmeshgraph # number of ints in mesh auxiliary data + int nskin # number of skins + int nskinvert # number of vertices in all skins + int nskintexvert # number of vertiex with texcoords in all skins + int nskinface # number of triangular faces in all skins + int nskinbone # number of bones in all skins + int nskinbonevert # number of vertices in all skin bones int nhfield # number of heightfields int nhfielddata # number of data points in all heightfields int ntex # number of textures @@ -465,7 +494,7 @@ cdef extern from "mjmodel.h" nogil: int nuser_sensor # number of mjtNums in sensor_user int nnames # number of chars in all names - # sizes set after mjModel construction (only affect mjData) + # sizes set after jModel construction (only affect mjData) int nM # number of non-zeros in sparse inertia matrix int nemax # number of potential equality-constraint rows int njmax # number of available rows in constraint Jacobian @@ -503,6 +532,8 @@ cdef extern from "mjmodel.h" nogil: int* body_dofadr # start addr of dofs; -1: no dofs (nbody x 1) int* body_geomnum # number of geoms (nbody x 1) int* body_geomadr # start addr of geoms; -1: no geoms (nbody x 1) + mjtByte* body_simple # body is simple (has diagonal M) (nbody x 1) + mjtByte* body_sameframe # inertial frame is same as body frame (nbody x 1) mjtNum* body_pos # position offset rel. to parent body (nbody x 3) mjtNum* body_quat # orientation offset rel. to parent body (nbody x 4) mjtNum* body_ipos # local position of center of mass (nbody x 3) @@ -518,6 +549,7 @@ cdef extern from "mjmodel.h" nogil: int* jnt_qposadr # start addr in 'qpos' for joint's data (njnt x 1) int* jnt_dofadr # start addr in 'qvel' for joint's data (njnt x 1) int* jnt_bodyid # id of joint's body (njnt x 1) + int* jnt_group # group for visibility (njnt x 1) mjtByte* jnt_limited # does joint have limits (njnt x 1) mjtNum* jnt_solref # constraint solver reference: limit (njnt x mjNREF) mjtNum* jnt_solimp # constraint solver impedance: limit (njnt x mjNIMP) @@ -533,12 +565,14 @@ cdef extern from "mjmodel.h" nogil: int* dof_jntid # id of dof's joint (nv x 1) int* dof_parentid # id of dof's parent; -1: none (nv x 1) int* dof_Madr # dof address in M-diagonal (nv x 1) + int* dof_simplenum # number of consecutive simple dofs (nv x 1) mjtNum* dof_solref # constraint solver reference:frictionloss (nv x mjNREF) mjtNum* dof_solimp # constraint solver impedance:frictionloss (nv x mjNIMP) mjtNum* dof_frictionloss # dof friction loss (nv x 1) mjtNum* dof_armature # dof armature inertia/mass (nv x 1) mjtNum* dof_damping # damping coefficient (nv x 1) mjtNum* dof_invweight0 # inv. diag. inertia in qpos0 (nv x 1) + mjtNum* dof_M0 # diag. inertia in qpos0 (nv x 1) # geoms int* geom_type # geometric type (mjtGeom) (ngeom x 1) @@ -549,6 +583,8 @@ cdef extern from "mjmodel.h" nogil: int* geom_dataid # id of geom's mesh/hfield (-1: none) (ngeom x 1) int* geom_matid # material id for rendering (ngeom x 1) int* geom_group # group for visibility (ngeom x 1) + int* geom_priority # geom contact priority (ngeom x 1) + mjtByte* geom_sameframe # same as body frame (1) or iframe (2) (ngeom x 1) mjtNum* geom_solmix # mixing coef for solref/imp in geom pair (ngeom x 1) mjtNum* geom_solref # constraint solver reference: contact (ngeom x mjNREF) mjtNum* geom_solimp # constraint solver impedance: contact (ngeom x mjNIMP) @@ -567,6 +603,7 @@ cdef extern from "mjmodel.h" nogil: int* site_bodyid # id of site's body (nsite x 1) int* site_matid # material id for rendering (nsite x 1) int* site_group # group for visibility (nsite x 1) + mjtByte* site_sameframe # same as body frame (1) or iframe (2) (nsite x 1) mjtNum* site_size # geom size for rendering (nsite x 3) mjtNum* site_pos # local position offset rel. to body (nsite x 3) mjtNum* site_quat # local orientation offset rel. to body (nsite x 4) @@ -606,16 +643,40 @@ cdef extern from "mjmodel.h" nogil: float* light_specular # specular rgb (alpha=1) (nlight x 3) # meshes - int* mesh_faceadr # first face address (nmesh x 1) - int* mesh_facenum # number of faces (nmesh x 1) int* mesh_vertadr # first vertex address (nmesh x 1) int* mesh_vertnum # number of vertices (nmesh x 1) + int* mesh_texcoordadr # texcoord data address; -1: no texcoord (nmesh x 1) + int* mesh_faceadr # first face address (nmesh x 1) + int* mesh_facenum # number of faces (nmesh x 1) int* mesh_graphadr # graph data address; -1: no graph (nmesh x 1) float* mesh_vert # vertex data for all meshes (nmeshvert x 3) float* mesh_normal # vertex normal data for all meshes (nmeshvert x 3) + float* mesh_texcoord # vertex texcoords for all meshes (nmeshtexvert x 2) int* mesh_face # triangle face data (nmeshface x 3) int* mesh_graph # convex graph data (nmeshgraph x 1) + # skins + int* skin_matid # skin material id; -1: none (nskin x 1) + float* skin_rgba # skin rgba (nskin x 4) + float* skin_inflate # inflate skin in normal direction (nskin x 1) + int* skin_vertadr # first vertex address (nskin x 1) + int* skin_vertnum # number of vertices (nskin x 1) + int* skin_texcoordadr # texcoord data address; -1: no texcoord (nskin x 1) + int* skin_faceadr # first face address (nskin x 1) + int* skin_facenum # number of faces (nskin x 1) + int* skin_boneadr # first bone in skin (nskin x 1) + int* skin_bonenum # number of bones in skin (nskin x 1) + float* skin_vert # vertex positions for all skin meshes (nskinvert x 3) + float* skin_texcoord # vertex texcoords for all skin meshes (nskintexvert x 2) + int* skin_face # triangle faces for all skin meshes (nskinface x 3) + int* skin_bonevertadr # first vertex in each bone (nskinbone x 1) + int* skin_bonevertnum # number of vertices in each bone (nskinbone x 1) + float* skin_bonebindpos # bind pos of each bone (nskinbone x 3) + float* skin_bonebindquat # bind quat of each bone (nskinbone x 4) + int* skin_bonebodyid # body id of each bone (nskinbone x 1) + int* skin_bonevertid # mesh ids of vertices in each bone (nskinbonevert x 1) + float* skin_bonevertweight # weights of vertices in each bone (nskinbonevert x 1) + # height fields mjtNum* hfield_size # (x, y, z_top, z_bottom) (nhfield x 4) int* hfield_nrow # number of rows in grid (nhfield x 1) @@ -667,6 +728,7 @@ cdef extern from "mjmodel.h" nogil: int* tendon_adr # address of first object in tendon's path (ntendon x 1) int* tendon_num # number of objects in tendon's path (ntendon x 1) int* tendon_matid # material id for rendering (ntendon x 1) + int* tendon_group # group for visibility (ntendon x 1) mjtByte* tendon_limited # does tendon have length limits (ntendon x 1) mjtNum* tendon_width # width for rendering (ntendon x 1) mjtNum* tendon_solref_lim # constraint solver reference: limit (ntendon x mjNREF) @@ -695,6 +757,7 @@ cdef extern from "mjmodel.h" nogil: int* actuator_gaintype # gain type (mjtGain) (nu x 1) int* actuator_biastype # bias type (mjtBias) (nu x 1) int* actuator_trnid # transmission id: joint, tendon, site (nu x 2) + int* actuator_group # group for visibility (nu x 1) mjtByte* actuator_ctrllimited; # is control limited (nu x 1) mjtByte* actuator_forcelimited;# is force limited (nu x 1) mjtNum* actuator_dynprm # dynamics parameters (nu x mjNDYN) @@ -704,7 +767,7 @@ cdef extern from "mjmodel.h" nogil: mjtNum* actuator_forcerange; # range of forces (nu x 2) mjtNum* actuator_gear # scale length and transmitted force (nu x 6) mjtNum* actuator_cranklength; # crank length for slider-crank (nu x 1) - mjtNum* actuator_invweight0; # inv. weight in qpos0 (nu x 1) + mjtNum* actuator_acc0 # acceleration from unit force in qpos0 (nu x 1) mjtNum* actuator_length0 # actuator length in qpos0 (nu x 1) mjtNum* actuator_lengthrange # ... not yet implemented ??? (nu x 2) mjtNum* actuator_user # user data (nu x nuser_actuator) @@ -752,9 +815,12 @@ cdef extern from "mjmodel.h" nogil: int* name_camadr # camera name pointers (ncam x 1) int* name_lightadr # light name pointers (nlight x 1) int* name_meshadr # mesh name pointers (nmesh x 1) + int* name_skinadr # skin name pointers (nskin x 1) int* name_hfieldadr # hfield name pointers (nhfield x 1) int* name_texadr # texture name pointers (ntex x 1) int* name_matadr # material name pointers (nmat x 1) + int* name_pairadr # geom pair name pointers (npair x 1) + int* name_excludeadr # exclude name pointers (nexclude x 1) int* name_eqadr # equality constraint name pointers (neq x 1) int* name_tendonadr # tendon name pointers (ntendon x 1) int* name_actuatoradr # actuator name pointers (nu x 1) @@ -762,4 +828,5 @@ cdef extern from "mjmodel.h" nogil: int* name_numericadr # numeric name pointers (nnumeric x 1) int* name_textadr # text name pointers (ntext x 1) int* name_tupleadr # tuple name pointers (ntuple x 1) + int* name_keyadr # keyframe name pointers (nkey x 1) char* names # names of all objects, 0-terminated (nnames x 1) diff --git a/mujoco_py/pxd/mjrender.pxd b/mujoco_py/pxd/mjrender.pxd index c98709c8..01b24fa6 100644 --- a/mujoco_py/pxd/mjrender.pxd +++ b/mujoco_py/pxd/mjrender.pxd @@ -1,4 +1,7 @@ cdef extern from "mjrender.h" nogil: + # Global constants + enum: mjNAUX + enum: mjMAXTEXTURE ctypedef enum mjtGridPos: # grid position for overlay mjGRID_TOPLEFT = 0, # top left @@ -35,11 +38,20 @@ cdef extern from "mjrender.h" nogil: float lineWidth # line width for wireframe rendering float shadowClip # clipping radius for directional lights float shadowScale # fraction of light cutoff for spot lights + float fogStart # fog start = stat.extent * vis.map.fogstart + float fogEnd # fog end = stat.extent * vis.map.fogend + float fogRGBA[4] # fog rgba int shadowSize # size of shadow map texture int offWidth # width of offscreen buffer int offHeight # height of offscreen buffer int offSamples # number of offscreen buffer multisamples + # parameters specified at creation + int fontScale; # font scale + int auxWidth[mjNAUX] # auxiliary buffer width + int auxHeight[mjNAUX] # auxiliary buffer height + int auxSamples[mjNAUX] # auxiliary buffer multisamples + # offscreen rendering objects unsigned int offFBO # offscreen framebuffer object unsigned int offFBO_r # offscreen framebuffer for resolving multisamples @@ -52,6 +64,12 @@ cdef extern from "mjrender.h" nogil: unsigned int shadowFBO # shadow map framebuffer object unsigned int shadowTex # shadow map texture + # auxiliary buffers + unsigned int auxFBO[mjNAUX] # auxiliary framebuffer object + unsigned int auxFBO_r[mjNAUX] # auxiliary framebuffer object for resolving + unsigned int auxColor[mjNAUX] # auxiliary color buffer + unsigned int auxColor_r[mjNAUX] # auxiliary color buffer for resolving + # texture objects and info int ntexture # number of allocated textures int textureType[100] # type of texture (mjtTexture) @@ -73,6 +91,13 @@ cdef extern from "mjrender.h" nogil: int rangeBuiltin # all builtin geoms, with quality from model int rangeFont # all characters in font + # skin VBOs + int nskin # number of skins + unsigned int* skinvertVBO # skin vertex position VBOs + unsigned int* skinnormalVBO # skin vertex normal VBOs + unsigned int* skintexcoordVBO # skin vertex texture coordinate VBOs + unsigned int* skinfaceVBO # skin face index VBOs + # character info int charWidth[127] # character widths: normal and shadow int charWidthBig[127] # chacarter widths: big diff --git a/mujoco_py/pxd/mjui.pxd b/mujoco_py/pxd/mjui.pxd new file mode 100644 index 00000000..c4d66fd0 --- /dev/null +++ b/mujoco_py/pxd/mjui.pxd @@ -0,0 +1,155 @@ +cdef extern from "mjui.h" nogil: + # Global constants + enum: mjMAXUISECT + enum: mjMAXUIITEM + enum: mjMAXUITEXT + enum: mjMAXUINAME + enum: mjMAXUIMULTI + enum: mjMAXUIEDIT + enum: mjMAXUIRECT + + + # predicate function: set enable/disable based on item category + ctypedef int (*mjfItemEnable)(int category, void* data); + + ctypedef struct mjuiState: # mouse and keyboard state + # constants set by user + int nrect # number of rectangles used + mjrRect rect[mjMAXUIRECT] # rectangles (index 0: entire window) + void* userdata # pointer to user data (for callbacks) + + # event type + int type # (type mjtEvent) + + # mouse buttons + int left # is left button down + int right # is right button down + int middle # is middle button down + int doubleclick # is last press a double click + int button # which button was pressed (mjtButton) + double buttontime # time of last button press + + # mouse position + double x # x position + double y # y position + double dx # x displacement + double dy # y displacement + double sx # x scroll + double sy # y scroll + + # keyboard + int control # is control down + int shift # is shift down + int alt # is alt down + int key # which key was pressed + double keytime # time of last key press + + # rectangle ownership and dragging + int mouserect # which rectangle contains mouse + int dragrect # which rectangle is dragged with mouse + int dragbutton # which button started drag (mjtButton) + + ctypedef struct mjuiThemeSpacing: # UI visualization theme spacing + int total # total width + int scroll # scrollbar width + int label # label width + int section # section gap + int itemside # item side gap + int itemmid # item middle gap + int itemver # item vertical gap + int texthor # text horizontal gap + int textver # text vertical gap + int linescroll # number of pixels to scroll + int samples # number of multisamples + + + ctypedef struct mjuiThemeColor: # UI visualization theme color + float master[3] # master background + float thumb[3] # scrollbar thumb + float secttitle[3] # section title + float sectfont[3] # section font + float sectsymbol[3] # section symbol + float sectpane[3] # section pane + float shortcut[3] # shortcut background + float fontactive[3] # font active + float fontinactive[3] # font inactive + float decorinactive[3] # decor inactive + float decorinactive2[3] # inactive slider color 2 + float button[3] # button + float check[3] # check + float radio[3] # radio + float select[3] # select + float select2[3] # select pane + float slider[3] # slider + float slider2[3] # slider color 2 + float edit[3] # edit + float edit2[3] # edit invalid + float cursor[3] # edit cursor + + + ctypedef struct mjuiItem: # UI item + # common properties + int type # type (mjtItem) + char name[mjMAXUINAME] # name + int state # 0: disable, 1: enable, 2+: use predicate + void *pdata # data pointer (type-specific) + int sectionid # id of section containing item + int itemid # id of item within section + + # internal + mjrRect rect # rectangle occupied by item + + + ctypedef struct mjuiSection: # UI section + # properties + char name[mjMAXUINAME] # name + int state # 0: closed, 1: open + int modifier # 0: none, 1: control, 2: shift; 4: alt + int shortcut # shortcut key; 0: undefined + int nitem # number of items in use + mjuiItem item[mjMAXUIITEM] # preallocated array of items + # internal + mjrRect rtitle # rectangle occupied by title + mjrRect rcontent # rectangle occupied by content + + + ctypedef struct mjUI: # entire UI + # constants set by user + mjuiThemeSpacing spacing # UI theme spacing + mjuiThemeColor color # UI theme color + mjfItemEnable predicate # callback to set item state programmatically + void* userdata # pointer to user data (passed to predicate) + int rectid # index of this ui rectangle in mjuiState + int auxid # aux buffer index of this ui + int radiocol # number of radio columns (0 defaults to 2) + + # UI sizes (framebuffer units) + int width # width + int height # current heigth + int maxheight # height when all sections open + int scroll # scroll from top of UI + + # mouse focus + int mousesect # 0: none, -1: scroll, otherwise 1+section + int mouseitem # item within section + int mousehelp # help button down: print shortcuts + + # keyboard focus and edit + int editsect # 0: none, otherwise 1+section + int edititem # item within section + int editcursor # cursor position + int editscroll # horizontal scroll + char edittext[mjMAXUITEXT] # current text + mjuiItem* editchanged # pointer to changed edit in last mjui_event + + # sections + int nsect # number of sections in use + mjuiSection sect[mjMAXUISECT] # preallocated array of sections + + + ctypedef struct mjuiDef: + int type # type (mjtItem); -1: section + char name[mjMAXUINAME] # name + int state # state + void* pdata # pointer to data + char other[mjMAXUITEXT] # string with type-specific properties diff --git a/mujoco_py/pxd/mjvisualize.pxd b/mujoco_py/pxd/mjvisualize.pxd index a4a86a29..535530d3 100644 --- a/mujoco_py/pxd/mjvisualize.pxd +++ b/mujoco_py/pxd/mjvisualize.pxd @@ -1,6 +1,3 @@ -include "mjmodel.pxd" - - cdef extern from "mjvisualize.h" nogil: #---------------------------- global constants ----------------------------------------- @@ -114,6 +111,7 @@ cdef extern from "mjvisualize.h" nogil: ctypedef struct mjvPerturb: # object selection and perturbation int select # selected body id; non-positive: none + int skinselect; # selected skin id; non-positive: none int active # perturbation bitmask (mjtPertBit) mjtNum refpos[3] # desired position for selected object mjtNum refquat[4] # desired orientation for selected object @@ -157,6 +155,8 @@ cdef extern from "mjvisualize.h" nogil: int category # visual category int texid # texture id; -1: no texture int texuniform # uniform cube mapping + int texcoord # mesh geom has texture coordinates + int segid # segmentation id; -1: not shown # OpenGL info float texrepeat[2] # texture repetition for 2D mapping @@ -191,11 +191,14 @@ cdef extern from "mjvisualize.h" nogil: ctypedef struct mjvOption: # abstract visualization options - int label # what objects to label (mjtLabel) - int frame # which frame to show (mjtFrame) - mjtByte geomgroup[mjNGROUP] # geom visualization by group - mjtByte sitegroup[mjNGROUP] # site visualization by group - mjtByte flags[mjNVISFLAG] # visualization flags (indexed by mjtVisFlag) + int label # what objects to label (mjtLabel) + int frame # which frame to show (mjtFrame) + mjtByte geomgroup[mjNGROUP] # geom visualization by group + mjtByte sitegroup[mjNGROUP] # site visualization by group + mjtByte jointgroup[mjNGROUP] # joint visualization by group + mjtByte tendongroup[mjNGROUP] # tendon visualization by group + mjtByte actuatorgroup[mjNGROUP] # actuator visualization by group + mjtByte flags[mjNVISFLAG] # visualization flags (indexed by mjtVisFlag) ctypedef struct mjvScene: # abstract scene passed to OpenGL renderer @@ -205,6 +208,15 @@ cdef extern from "mjvisualize.h" nogil: mjvGeom* geoms # buffer for geoms int* geomorder # buffer for ordering geoms by distance to camera + # skin data + int nskin # number of skins + int* skinfacenum # number of faces in skin + int* skinvertadr # address of skin vertices + int* skinvertnum # number of vertices in skin + float* skinvert # skin vertex data + float* skinnormal # skin normal data + + # OpenGL lights int nlight # number of lights currently in buffer mjvLight lights[8] # buffer for lights @@ -230,12 +242,18 @@ cdef extern from "mjvisualize.h" nogil: int flg_ticklabel[2] # show grid tick labels (x,y) int flg_extend # automatically extend axis ranges to fit data int flg_barplot # isolated line segments (i.e. GL_LINES) + int flg_selection # vertical selection line + int flg_symmetric # symmetric y-axis # figure options + int legendoff # number of lines to offset legend int gridsize[2] # number of grid points in (x,y) + int selection # selection line x-value + int highlight[2] # if point is in legend rect, highlight line float gridrgb[3] # grid line rgb float gridwidth # grid line width float figurergba[4] # figure color and alpha + float panergba[4] # pane color and alpha float legendrgba[4] # legend color and alpha float textrgb[3] # text color float range[2][2] # axis ranges; (min>=max) automatic @@ -252,3 +270,9 @@ cdef extern from "mjvisualize.h" nogil: float linedata[mjMAXLINE][2*mjMAXLINEPNT] # line data (x,y) char linename[mjMAXLINE][100] # line name for legend + # output from renderer + int xaxispixel[2] # range of x-axis in pixels + int yaxispixel[2] # range of y-axis in pixels + float xaxisdata[2] # range of x-axis in data units + float yaxisdata[2] # range of y-axis in data units + diff --git a/mujoco_py/pxd/mujoco.pxd b/mujoco_py/pxd/mujoco.pxd index c2a5c8d4..304abad8 100644 --- a/mujoco_py/pxd/mujoco.pxd +++ b/mujoco_py/pxd/mujoco.pxd @@ -1,6 +1,7 @@ include "mjmodel.pxd" include "mjdata.pxd" include "mjrender.pxd" +include "mjui.pxd" include "mjvisualize.pxd" @@ -125,12 +126,21 @@ cdef extern from "mujoco.h" nogil: int skipstage, int skipsensorenergy); # Inverse dynamics with skip; skipstage is mjtStage. - void mj_inverseSkip(const mjModel* m, mjData* d, - int skipstage, int skipsensorenergy); + void mj_inverseSkip(const mjModel* m, mjData* d, + int skipstage, int skipsensorenergy); + + # Forward dynamics with skip; skipstage is mjtStage. + void mj_forwardSkip(const mjModel* m, mjData* d, int skipstage, int skipsensor); + + # Inverse dynamics with skip; skipstage is mjtStage. + void mj_inverseSkip(const mjModel* m, mjData* d, int skipstage, int skipsensor); #--------------------- Initialization ------------------------------------------------- + # Set default options for length range computation. + void mj_defaultLROpt(mjLROpt* opt); + # Set solver parameters to default values. void mj_defaultSolRefImp(mjtNum* solref, mjtNum* solimp); @@ -181,9 +191,11 @@ cdef extern from "mujoco.h" nogil: void mj_resetCallbacks(); # Set constant fields of mjModel, corresponding to qpos0 configuration. - # The flag flg_actrange currently has no effect. - void mj_setConst(mjModel* m, mjData* d, int flg_actrange); + void mj_setConst(mjModel* m, mjData* d); + # Set actuator_lengthrange for specified actuator; return 1 if ok, 0 if error. + int mj_setLengthRange(mjModel* m, mjData* d, int index, + const mjLROpt* opt, char* error, int error_sz); #--------------------- Printing ------------------------------------------------------- @@ -297,6 +309,9 @@ cdef extern from "mujoco.h" nogil: # Compute qfrc_passive from spring-dampers, viscosity and density. void mj_passive(const mjModel* m, mjData* d); + # subtree linear velocity and angular momentum + void mj_subtreeVel(const mjModel* m, mjData* d); + # RNE: compute M(qpos)*qacc + C(qpos,qvel); flg_acc=0 removes inertial term. void mj_rne(const mjModel* m, mjData* d, int flg_acc, mjtNum* result); @@ -379,6 +394,9 @@ cdef extern from "mujoco.h" nogil: # Multiply vector by inertia matrix. void mj_mulM(const mjModel* m, const mjData* d, mjtNum* res, const mjtNum* vec); + # Multiply vector by (inertia matrix)^(1/2). + void mj_mulM2(const mjModel* m, const mjData* d, mjtNum* res, const mjtNum* vec); + # Add inertia matrix to destination matrix. # Destination can be sparse uncompressed, or dense when all int* are NULL void mj_addM(const mjModel* m, mjData* d, mjtNum* dst, @@ -397,13 +415,13 @@ cdef extern from "mujoco.h" nogil: void mj_objectAcceleration(const mjModel* m, const mjData* d, int objtype, int objid, mjtNum* res, int flg_local); - # Compute velocity by finite-differencing two positions. - void mj_differentiatePos(const mjModel* m, mjtNum* qvel, mjtNum dt, - const mjtNum* qpos1, const mjtNum* qpos2); - # Extract 6D force:torque for one contact, in contact frame. void mj_contactForce(const mjModel* m, const mjData* d, int id, mjtNum* result); + # Compute velocity by finite-differencing two positions. + void mj_differentiatePos(const mjModel* m, mjtNum* qvel, mjtNum dt, + const mjtNum* qpos1, const mjtNum* qpos2); + # Integrate position with given velocity. void mj_integratePos(const mjModel* m, mjtNum* qpos, const mjtNum* qvel, mjtNum dt); @@ -411,8 +429,8 @@ cdef extern from "mujoco.h" nogil: void mj_normalizeQuat(const mjModel* m, mjtNum* qpos); # Map from body local to global Cartesian coordinates. - void mj_local2Global(mjData* d, mjtNum* xpos, mjtNum* xmat, - const mjtNum* pos, const mjtNum* quat, int body); + void mj_local2Global(mjData* d, mjtNum* xpos, mjtNum* xmat, const mjtNum* pos, const mjtNum* quat, + int body, mjtByte sameframe); # Sum all body masses. mjtNum mj_getTotalmass(const mjModel* m); @@ -503,11 +521,10 @@ cdef extern from "mujoco.h" nogil: # Return the average of two OpenGL cameras. mjvGLCamera mjv_averageCamera(const mjvGLCamera* cam1, const mjvGLCamera* cam2); - # Select model geom with mouse, return -1 if none selected. selpnt is the 3D point. + # Select geom or skin with mouse, return bodyid; -1: none selected. int mjv_select(const mjModel* m, const mjData* d, const mjvOption* vopt, - mjtNum aspectratio, mjtNum relx, mjtNum rely, - const mjvScene* scn, mjtNum* selpnt); - + mjtNum aspectratio, mjtNum relx, mjtNum rely, + const mjvScene* scn, mjtNum* selpnt, int* geomid, int* skinid); #--------------------- Visualization -------------------------------------------------- @@ -527,8 +544,11 @@ cdef extern from "mujoco.h" nogil: mjtNum a0, mjtNum a1, mjtNum a2, mjtNum b0, mjtNum b1, mjtNum b2); - # Allocate and init abstract scene. - void mjv_makeScene(mjvScene* scn, int maxgeom); + # Set default abstract scene. + void mjv_defaultScene(mjvScene* scn); + + # Allocate resources in abstract scene. + void mjv_makeScene(const mjModel* m, mjvScene* scn, int maxgeom); # Free abstract scene. void mjv_freeScene(mjvScene* scn); @@ -541,9 +561,14 @@ cdef extern from "mujoco.h" nogil: void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* opt, const mjvPerturb* pert, int catmask, mjvScene* scn); + # Make list of lights. + void mjv_makeLights(const mjModel* m, mjData* d, mjvScene* scn); + # Update camera only. void mjv_updateCamera(const mjModel* m, mjData* d, mjvCamera* cam, mjvScene* scn); + # Update skins. + void mjv_updateSkin(const mjModel* m, mjData* d, mjvScene* scn); #--------------------- OpenGL rendering ----------------------------------------------- @@ -553,6 +578,12 @@ cdef extern from "mujoco.h" nogil: # Allocate resources in custom OpenGL context; fontscale is mjtFontScale. void mjr_makeContext(const mjModel* m, mjrContext* con, int fontscale); + # Change font of existing context. + void mjr_changeFont(int fontscale, mjrContext* con); + + # Add Aux buffer with given index to context; free previous Aux buffer. + void mjr_addAux(int index, int width, int height, int samples, mjrContext* con); + # Free resources in custom OpenGL context, set to default. void mjr_freeContext(mjrContext* con); @@ -565,6 +596,9 @@ cdef extern from "mujoco.h" nogil: # Upload height field to GPU, overwriting previous upload if any. void mjr_uploadHField(const mjModel* m, const mjrContext* con, int hfieldid); + # Make con->currentBuffer current again. + void mjr_restoreBuffer(const mjrContext* con); + # Set OpenGL framebuffer for rendering: mjFB_WINDOW or mjFB_OFFSCREEN. # If only one buffer is available, set that buffer and ignore framebuffer argument. void mjr_setBuffer(int framebuffer, mjrContext* con); @@ -581,8 +615,13 @@ cdef extern from "mujoco.h" nogil: # Blit from src viewpoint in current framebuffer to dst viewport in other framebuffer. # If src, dst have different size and flg_depth==0, color is interpolated with GL_LINEAR. - void mjr_blitBuffer(mjrRect src, mjrRect dst, - int flg_color, int flg_depth, const mjrContext* con); + void mjr_blitBuffer(mjrRect src, mjrRect dst, int flg_color, int flg_depth, const mjrContext* con); + + # Set Aux buffer for custom OpenGL rendering (call restoreBuffer when done). + void mjr_setAux(int index, const mjrContext* con); + + # Blit from Aux buffer to con->currentBuffer. + void mjr_blitAux(int index, mjrRect src, int left, int bottom, const mjrContext* con); # Draw text at (x,y) in relative coordinates; font is mjtFont. void mjr_text(int font, const char* txt, const mjrContext* con, @@ -610,6 +649,26 @@ cdef extern from "mujoco.h" nogil: # Call glGetError and return result. int mjr_getError(); + # Find first rectangle containing mouse, -1: not found. + int mjr_findRect(int x, int y, int nrect, const mjrRect* rect); + + #---------------------- UI framework --------------------------------------------------- + + # Add definitions to UI. + void mjui_add(mjUI* ui, const mjuiDef* _def); + + # Compute UI sizes. + void mjui_resize(mjUI* ui, const mjrContext* con); + + # Update specific section/item; -1: update all. + void mjui_update(int section, int item, const mjUI* ui, const mjuiState* state, const mjrContext* con); + + # Handle UI event, return pointer to changed item, NULL if no change. + mjuiItem* mjui_event(mjUI* ui, mjuiState* state, const mjrContext* con); + + # Copy UI image to current buffer. + void mjui_render(mjUI* ui, const mjuiState* state, const mjrContext* con); + #--------------------- Error and memory ----------------------------------------------- @@ -756,6 +815,12 @@ cdef extern from "mujoco.h" nogil: # Set res = vec. void mju_copy(mjtNum* res, const mjtNum* data, int n); + # Return sum(vec). + mjtNum mju_sum(const mjtNum* vec, int n); + + # Return L1 norm: sum(abs(vec)). + mjtNum mju_L1(const mjtNum* vec, int n); + # Set res = vec*scl. void mju_scl(mjtNum* res, const mjtNum* vec, mjtNum scl, int n); @@ -887,6 +952,9 @@ cdef extern from "mujoco.h" nogil: # Convert quaternion (corresponding to orientation difference) to 3D velocity. void mju_quat2Vel(mjtNum res[3], const mjtNum quat[4], mjtNum dt); + # Subtract quaternions, express as 3D velocity: qb*quat(res) = qa. + void mju_subQuat(mjtNum res[3], const mjtNum qa[4], const mjtNum qb[4]); + # Convert quaternion to 3D rotation matrix. void mju_quat2Mat(mjtNum res[9], const mjtNum quat[4]); @@ -922,7 +990,7 @@ cdef extern from "mujoco.h" nogil: #--------------------- Decompositions -------------------------------------------------- # Cholesky decomposition: mat = L*L'; return rank. - int mju_cholFactor(mjtNum* mat, int n); + int mju_cholFactor(mjtNum* mat, int n, mjtNum mindiag); # Solve mat * res = vec, where mat is Cholesky-factorized void mju_cholSolve(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int n); @@ -930,39 +998,23 @@ cdef extern from "mujoco.h" nogil: # Cholesky rank-one update: L*L' +/- x*x'; return rank. int mju_cholUpdate(mjtNum* mat, mjtNum* x, int n, int flg_plus); - # Sparse reverse-order Cholesky decomposition: mat = L'*L; return 'rank'. - # mat must have uncompressed layout; rownnz is modified to end at diagonal. - # The required scratch space is 2*n. - int mju_cholFactorSparse(mjtNum* mat, int n, - int* rownnz, int* rowadr, int* colind, - mjtNum* scratch, int nscratch); - - # Solve mat * res = vec, where mat is sparse reverse-order Cholesky factorized. - void mju_cholSolveSparse(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int n, - const int* rownnz, const int* rowadr, const int* colind); - - # Sparse reverse-order Cholesky rank-one update: L'*L +/- x*x'; return rank. - # The vector x is sparse; changes in sparsity pattern of mat are not allowed. - # The required scratch space is 2*n. - int mju_cholUpdateSparse(mjtNum* mat, mjtNum* x, int n, int flg_plus, - int* rownnz, int* rowadr, int* colind, int x_nnz, int* x_ind, - mjtNum* scratch, int nscratch); - # Eigenvalue decomposition of symmetric 3x3 matrix. int mju_eig3(mjtNum* eigval, mjtNum* eigvec, mjtNum* quat, const mjtNum* mat); #--------------------- Miscellaneous -------------------------------------------------- - # Muscle model; not yet implemented. - mjtNum mju_muscleFVL(mjtNum len, mjtNum vel, mjtNum lmin, mjtNum lmax, mjtNum* prm); + # Muscle active force, prm = (range[2], force, scale, lmin, lmax, vmax, fpmax, fvmax). + mjtNum mju_muscleGain(mjtNum len, mjtNum vel, const mjtNum lengthrange[2], + mjtNum acc0, const mjtNum prm[9]); + + # Muscle passive force, prm = (range[2], force, scale, lmin, lmax, vmax, fpmax, fvmax). + mjtNum mju_muscleBias(mjtNum len, const mjtNum lengthrange[2], + mjtNum acc0, const mjtNum prm[9]); - # Passive muscle force; not yet implemented. - mjtNum mju_musclePassive(mjtNum len, mjtNum lmin, mjtNum lmax, mjtNum* prm); + # Muscle activation dynamics, prm = (tau_act, tau_deact). + mjtNum mju_muscleDynamics(mjtNum ctrl, mjtNum act, const mjtNum prm[2]); - # Pneumatic cylinder dynamics; not yet implemented. - mjtNum mju_pneumatic(mjtNum len, mjtNum len0, mjtNum vel, mjtNum* prm, - mjtNum act, mjtNum ctrl, mjtNum timestep, mjtNum* jac); # Convert contact force to pyramid representation. void mju_encodePyramid(mjtNum* pyramid, const mjtNum* force, diff --git a/mujoco_py/test_imgs/test_rendering.freecam.depth-darwin.png b/mujoco_py/test_imgs/test_rendering.freecam.depth-darwin.png new file mode 100644 index 00000000..4acc1561 Binary files /dev/null and b/mujoco_py/test_imgs/test_rendering.freecam.depth-darwin.png differ diff --git a/mujoco_py/tests/test_composite.py b/mujoco_py/tests/test_composite.py new file mode 100644 index 00000000..95747ab9 --- /dev/null +++ b/mujoco_py/tests/test_composite.py @@ -0,0 +1,20 @@ +""" +Test whether library can parse composite object definitions - new in MuJoCo 2.0 +""" + +from mujoco_py import load_model_from_xml + + +PARTICLE_XML = """ + + + + + + + +""" + + +def test_load_particle(): + load_model_from_xml(PARTICLE_XML) diff --git a/mujoco_py/tests/test_cymj.py b/mujoco_py/tests/test_cymj.py index de5d5212..f164eaca 100644 --- a/mujoco_py/tests/test_cymj.py +++ b/mujoco_py/tests/test_cymj.py @@ -1,19 +1,21 @@ +import numpy as np import pytest +import sys import unittest -from numbers import Number + from io import BytesIO, StringIO -import numpy as np +from multiprocessing import get_context +from numbers import Number from numpy.testing import assert_array_equal, assert_array_almost_equal +# from threading import Thread, Event +from PIL import Image + from mujoco_py import (MjSim, load_model_from_xml, load_model_from_path, MjSimState, ignore_mujoco_warnings, load_model_from_mjb) from mujoco_py import const, cymj from mujoco_py.tests.utils import compare_imgs -import scipy.misc -from threading import Thread, Event -from multiprocessing import get_context -import sys BASIC_MODEL_XML = """ @@ -39,6 +41,7 @@ """ + def test_nested(): model = load_model_from_xml(BASIC_MODEL_XML) model.vis.global_.fovy @@ -534,7 +537,12 @@ def test_rendering(): depth = (depth - np.min(depth)) / (np.max(depth) - np.min(depth)) depth = np.asarray(depth * 255, dtype=np.uint8) assert depth.shape == (200, 200) - compare_imgs(depth, 'test_rendering.freecam.depth.png') + + # Unfortunately mujoco 2.0 renders slightly different depth image on mac and on linux here + if "darwin" in sys.platform.lower(): + compare_imgs(depth, 'test_rendering.freecam.depth-darwin.png') + else: + compare_imgs(depth, 'test_rendering.freecam.depth.png') img = sim.render(100, 100, camera_name="camera1") assert img.shape == (100, 100, 3) @@ -604,49 +612,13 @@ def test_sensors(): sim.data.get_sensor("touchsensor") -@pytest.mark.requires_rendering -@pytest.mark.skipif("Darwin" not in sys.platform, - reason="Only Darwin code is thread safe.") -def test_concurrent_rendering(): - '''Best-effort testing that concurrent multi-threaded rendering works. - The test has no guarantees around being deterministic, but if it fails - you know something is wrong with concurrent rendering. If it passes, - things are probably working.''' - err = None - def func(sim, event): - event.wait() - sim.data.qpos[:] = 0.0 - sim.forward() - img1 = sim.render(width=40, height=40, camera_name="camera1") - img2 = sim.render(width=40, height=40, camera_name="camera2") - try: - assert np.sum(img1[:]) == 23255 - assert np.sum(img2[:]) == 12007 - except Exception as e: - nonlocal err - err = e - - model = load_model_from_xml(BASIC_MODEL_XML) - sim = MjSim(model) - sim.render(100, 100) - event = Event() - threads = [] - for _ in range(100): - thread = Thread(target=func, args=(sim, event)) - threads.append(thread) - thread.start() - event.set() - for thread in threads: - thread.join() - assert err is None, "Exception: %s" % (str(err)) - @pytest.mark.requires_rendering def test_high_res(): model = load_model_from_xml(BASIC_MODEL_XML) sim = MjSim(model) sim.forward() img = sim.render(1000, 1000) - img = scipy.misc.imresize(img, (200, 200, 3)) + img = np.array(Image.fromarray(img).resize(size=(200, 200))) assert img.shape == (200, 200, 3) compare_imgs(img, 'test_rendering.freecam.png') @@ -673,8 +645,8 @@ def test_multiprocess(): def import_process(queue): try: from mujoco_py import builder - mjpro_path, key_path = builder.discover_mujoco() - builder.load_cython_ext(mjpro_path) + mujoco_path, key_path = builder.discover_mujoco() + builder.load_cython_ext(mujoco_path) except Exception as e: queue.put(False) else: diff --git a/mujoco_py/utils.py b/mujoco_py/utils.py index 90aa53c2..6e99eef3 100644 --- a/mujoco_py/utils.py +++ b/mujoco_py/utils.py @@ -16,7 +16,7 @@ If python tries to activate an invalid license, the process will exit. ''' -MISSING_MJPRO_MESSAGE = ''' +MISSING_MUJOCO_MESSAGE = ''' You appear to be missing MuJoCo. We expected to find the file here: {} This package only provides python bindings, the library must be installed separately. @@ -75,20 +75,20 @@ def discover_mujoco(): Currently assumes path is in ~/.mujoco Returns: - - mjpro_path (str): Path to MuJoCo Pro 1.50 directory. + - mujoco_path (str): Path to MuJoCo 2.0 directory. - key_path (str): Path to the MuJoCo license key. """ key_path = os.getenv('MUJOCO_PY_MJKEY_PATH') if not key_path: key_path = join(expanduser('~'), '.mujoco', 'mjkey.txt') - mjpro_path = os.getenv('MUJOCO_PY_MJPRO_PATH') - if not mjpro_path: - mjpro_path = join(expanduser('~'), '.mujoco', 'mjpro150') + mujoco_path = os.getenv('MUJOCO_PY_MUJOCO_PATH') + if not mujoco_path: + mujoco_path = join(expanduser('~'), '.mujoco', 'mujoco200') # We get lots of github issues that seem to be missing these # so check that mujoco is really there and raise errors if not. - if not exists(mjpro_path): - message = MISSING_MJPRO_MESSAGE.format(mjpro_path) + if not exists(mujoco_path): + message = MISSING_MUJOCO_MESSAGE.format(mujoco_path) print(message, file=sys.stderr) raise Exception(message) if not exists(key_path): @@ -96,4 +96,4 @@ def discover_mujoco(): print(message, file=sys.stderr) raise Exception(message) - return (mjpro_path, key_path) + return (mujoco_path, key_path) diff --git a/mujoco_py/version.py b/mujoco_py/version.py index 44fb06fb..9cdcee68 100644 --- a/mujoco_py/version.py +++ b/mujoco_py/version.py @@ -1,13 +1,13 @@ __all__ = ['__version__', 'get_version'] -version_info = (1, 50, 1, 68) +version_info = (2, 0, 2, 0) # format: # ('mujoco_major', 'mujoco_minor', 'mujoco_py_major', 'mujoco_py_minor') def get_version(): "Returns the version as a human-format string." - return '%d.%d.%d.%d' % version_info + return '%d.%d.%d.%da1' % version_info __version__ = get_version() diff --git a/requirements.dev.txt b/requirements.dev.txt index 4412b0bf..5d11ffa9 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -4,7 +4,6 @@ Pillow>=4.0.0 pycparser>=2.17.0 pytest>=3.0.5 pytest-instafail==0.3.0 -scipy>=0.18.0 sphinx sphinx_rtd_theme numpydoc diff --git a/scripts/gen_wrappers.py b/scripts/gen_wrappers.py index 716dba7d..95a08d08 100644 --- a/scripts/gen_wrappers.py +++ b/scripts/gen_wrappers.py @@ -1,17 +1,22 @@ +import codecs import os +import pycparser import re import subprocess +import sys import tempfile +import traceback + + from collections import OrderedDict -import sys -import pycparser -from pycparser.c_ast import ArrayDecl, TypeDecl, PtrDecl -import sys +from pycparser.c_ast import ArrayDecl, TypeDecl, PtrDecl, Union, BinaryOp, UnaryOp + c_compiler = "cc" if sys.platform.startswith("win"): c_compiler = "cl" + def tryint(x): try: return int(x) @@ -72,8 +77,12 @@ def get_struct_dict(struct, struct_name, array_shapes): # but currently that never happens. if struct_name != 'mjModel': struct_dict[struct_name]['depends_on_model'] = True + elif isinstance(child_type, Union): + # I'm ignoring unions for now until we think they're necessary + continue else: raise NotImplementedError + assert isinstance(struct_dict, OrderedDict), 'Must be deterministic' return struct_dict @@ -82,7 +91,8 @@ def get_full_scr_lines(HEADER_DIR, HEADER_FILES): # ===== Read all header files ===== file_contents = [] for filename in HEADER_FILES: - with open(os.path.join(HEADER_DIR, filename), 'r') as f: + # mujoco 2.0 header files fail when parsed as utf-8 + with codecs.open(os.path.join(HEADER_DIR, filename), 'r', encoding='latin-1') as f: file_contents.append(f.read()) full_src_lines = [line.strip() for line in '\n'.join(file_contents).splitlines()] @@ -149,19 +159,45 @@ def get_const_from_enum(processed_src): assert (node[1].name is None) == isinstance( node[1].type, pycparser.c_ast.Struct) struct = node[1].children()[0][1] + + # Check if it is an enum if hasattr(struct, "type") and isinstance(struct.type, pycparser.c_ast.Enum): lines.append(" # " + struct.type.name) + + # enum list os a list of key-value enumerations enumlist = struct.children()[0][1].children()[0][1].children() + last_value = None + for _, enum in enumlist: var = enum.name[2:] + + # Enum has two parts - name and value if enum.value is not None: - children = enum.value.children() - if len(children) > 0: - value = children[1][1].value + if isinstance(enum.value, BinaryOp): + # An enum is actually a binary operation + if enum.value.op == '<<': + # Parse and evaluate simple constant expression. Will throw if it's anything more complex + value = int(enum.value.children()[0][1].value) << int(enum.value.children()[1][1].value) + else: + raise NotImplementedError + elif isinstance(enum.value, UnaryOp): + # If we want to be correct we need to do a bit of parsing here.... + if enum.value.op == '-': + # Again, if some assumptions I'm making here are not correct, this should throw + value = -int(enum.value.expr.value) + else: + raise NotImplementedError else: - value = enum.value.value - value = int(value) + children = enum.value.children() + + if len(children) > 0: + value = children[1][1].value + else: + value = enum.value.value + + value = int(value) + last_value = value new_line = str(var) + " = " + str(value) lines.append(new_line) @@ -295,29 +331,42 @@ def {obj_type}_name2id(self, name): def get_const_from_define(full_src_lines): define_code = [] + for line in full_src_lines: define = "#define" if line.find(define) > -1: line = line[len(define):].strip() last_len = 100000 + while last_len != len(line): last_len = len(line) line = line.replace(" ", " ") line = line.replace("\t", " ") + comment = "" + if line.find("//") > -1: line, comment = line.split("//") + line, comment = line.strip(), comment.strip() + if line.find(" ") > -1: var, val = line.split(" ") try: + # In C/C++ numbers can have an 'f' suffix, specifying a single-precision number. + # That is not supported by the Python floating point parser, therefore we need to strip that bit. + if val[-1] == 'f': + val = val[:-1] + val = float(val) new_line = var[2:] + " = " + str(val) new_line += " " * (35 - len(new_line)) new_line += " # " + comment define_code.append(new_line) - except: + except Exception: + traceback.print_exc() print("Couldn't parse line: %s" % line) + return define_code @@ -325,6 +374,7 @@ def get_funcs(fname): src = subprocess.check_output([c_compiler, '-E', '-P', fname]).decode() src = src[src.find("int mj_activat"):] l = -1 + while l != len(src): l = len(src) src = src.replace(" ", " ") @@ -333,27 +383,40 @@ def get_funcs(fname): src = src.replace("const ", "") src = src.replace(", ", ",") src = src.strip() + funcs = src.split(";") funcs = [f.strip() for f in funcs if len(f) > 0] ret = "" count = 0 + for f in funcs: ret_name = f.split(" ")[0] func_name = f.split(" ")[1].split("(")[0] + args = f.split("(")[1][:-1] skip = False + py_args_string = [] c_args_string = [] + if args != "void": args = args.split(",") + for arg in args: arg = arg.strip() data_type = " ".join(arg.split(" ")[:-1]) var_name = arg.split(" ")[-1] + if var_name.find("[") > -1: #arr_size = var_name[var_name.find("[") + 1:var_name.find("]")] data_type = data_type + "*" var_name = var_name[:var_name.find("[")] + + # Some words are keywords in Python that are not keywords in C/C++, therefore they can be used as + # variable identifiers. We need to handle these situations. + if var_name in ['def']: + var_name = '_' + var_name + if data_type in ["char*"]: py_args_string.append("str " + var_name) c_args_string.append(var_name + ".encode()") @@ -397,6 +460,7 @@ def get_funcs(fname): py_args_string.append("uintptr_t " + var_name) c_args_string.append("" + var_name) continue + # XXX skip = True @@ -424,25 +488,27 @@ def get_funcs(fname): def main(): - HEADER_DIR = os.path.expanduser(os.path.join('~', '.mujoco', 'mjpro150', 'include')) + HEADER_DIR = os.path.expanduser(os.path.join('~', '.mujoco', 'mujoco200', 'include')) HEADER_FILES = [ 'mjmodel.h', 'mjdata.h', 'mjvisualize.h', 'mjrender.h', + 'mjui.h' ] if len(sys.argv) > 1: OUTPUT = sys.argv[1] else: OUTPUT = os.path.join('mujoco_py', 'generated', 'wrappers.pxi') OUTPUT_CONST = os.path.join('mujoco_py', 'generated', 'const.py') + funcs = get_funcs(os.path.join(HEADER_DIR, "mujoco.h")) full_src_lines = get_full_scr_lines(HEADER_DIR, HEADER_FILES) array_shapes = get_array_shapes(full_src_lines) processed_src = get_processed_src(HEADER_DIR, full_src_lines) struct_dict = get_full_struct_dict(processed_src, array_shapes) - structname2wrappername, structname2wrapfuncname = get_struct_wrapper( - struct_dict) + + structname2wrappername, structname2wrapfuncname = get_struct_wrapper(struct_dict) define_const = get_const_from_define(full_src_lines) enum_const = get_const_from_enum(processed_src) @@ -893,5 +959,6 @@ def uintptr(self): return self.ptr with open(OUTPUT, 'w') as f: f.write(code) + if __name__ == "__main__": main() diff --git a/setup.py b/setup.py index aebea65d..26bcd74e 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import os + from os.path import join, dirname, realpath from setuptools import find_packages, setup from distutils.command.build import build as DistutilsBuild