Giter Site home page Giter Site logo

openai / mujoco-py Goto Github PK

View Code? Open in Web Editor NEW
2.8K 199.0 810.0 5.69 MB

MuJoCo is a physics engine for detailed, efficient rigid body simulations with contacts. mujoco-py allows using MuJoCo from Python 3.

License: Other

Makefile 0.54% Python 26.38% C 13.07% Dockerfile 0.34% Cython 59.67%

mujoco-py's Introduction

Status: Deprecated

mujoco-py does not support versions of MuJoCo after 2.1.0.

New users should depend on the official MuJoCo Python bindings.

mujoco-py Documentation Build Status

MuJoCo 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.1 released on 2021-10-18.

Synopsis

Requirements

The following platforms are currently supported:

  • Linux with Python 3.6+. See the Dockerfile for the canonical list of system dependencies.
  • OS X with Python 3.6+.

The following platforms are DEPRECATED and unsupported:

  • Windows support has been DEPRECATED and removed in 2.0.2.0. One known good past version is 1.50.1.68.
  • Python 2 has been DEPRECATED and removed in 1.50.1.0. Python 2 users can stay on the 0.5 branch. The latest release there is 0.5.7 which can be installed with pip install mujoco-py==0.5.7.

Install MuJoCo

  1. Download the MuJoCo version 2.1 binaries for Linux or OSX.
  2. Extract the downloaded mujoco210 directory into ~/.mujoco/mujoco210.

If you want to specify a nonstandard location for the package, use the env variable 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<2.2,>=2.1

To play with mujoco-py interactively, follow these steps:

$ pip3 install -U 'mujoco-py<2.2,>=2.1'
$ python3
import mujoco_py
import os
mj_path = mujoco_py.utils.discover_mujoco()
xml_path = os.path.join(mj_path, 'model', 'humanoid.xml')
model = mujoco_py.load_model_from_path(xml_path)
sim = mujoco_py.MjSim(model)

print(sim.data.qpos)
# [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]

sim.step()
print(sim.data.qpos)
# [-2.09531783e-19  2.72130735e-05  6.14480786e-22 -3.45474715e-06
#   7.42993721e-06 -1.40711141e-04 -3.04253586e-04 -2.07559344e-04
#   8.50646247e-05 -3.45474715e-06  7.42993721e-06 -1.40711141e-04
#  -3.04253586e-04 -2.07559344e-04 -8.50646247e-05  1.11317030e-04
#  -7.03465386e-05 -2.22862221e-05 -1.11317030e-04  7.03465386e-05
#  -2.22862221e-05]

See the full documentation for advanced usage.

Troubleshooting

You're on MacOS and you see clang: error: unsupported option '-fopenmp'

If this happend during installation or just running python -c "import mujoco_py" then the issue seems to be related to this and the TL;DR is that for macOS the default compiler Apple clang LLVM does not support openmp. So you can try to install another clang/llvm installation. For example (requires brew):

brew install llvm
brew install boost
brew install hdf5

# Add this to your .bashrc/.zshrc:
export PATH="/usr/local/opt/llvm/bin:$PATH"

export CC="/usr/local/opt/llvm/bin/clang"
export CXX="/usr/local/opt/llvm/bin/clang++"
export CXX11="/usr/local/opt/llvm/bin/clang++"
export CXX14="/usr/local/opt/llvm/bin/clang++"
export CXX17="/usr/local/opt/llvm/bin/clang++"
export CXX1X="/usr/local/opt/llvm/bin/clang++"

export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"

Note: Don't forget to source your .bashrc/.zshrc after editing it and try to install mujoco-py again:

# Make sure your python environment is activated
pip install -U 'mujoco-py<2.2,>=2.1'

Missing GLFW

A common error when installing is:

raise ImportError("Failed to load GLFW3 shared library.")

Which happens when the glfw python package fails to find a GLFW dynamic library.

MuJoCo ships with its own copy of this library, which can be used during installation.

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

LD_LIBRARY_PATH=$HOME/.mujoco/mujoco210/bin pip install mujoco-py

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

Ubuntu installtion troubleshooting

Because mujoco_py has compiled native code that needs to be linked to a supplied MuJoCo binary, it's installation on linux can be more challenging than pure Python source packages.

To install mujoco-py on Ubuntu, make sure you have the following libraries installed:

sudo apt install libosmesa6-dev libgl1-mesa-glx libglfw3

If you installed above libraries and you still see an error that -lGL cannot be found, most likely you need to create the symbolic link directly:

sudo ln -s /usr/lib/x86_64-linux-gnu/libGL.so.1 /usr/lib/x86_64-linux-gnu/libGL.so

Usage Examples

A number of examples demonstrating some advanced features of mujoco-py can be found in examples/. These include:

See the full documentation for advanced usage.

Development

To run the provided unit and integrations tests:

make test

To test GPU-backed rendering, run:

make test_gpu

This is somewhat dependent on internal OpenAI infrastructure at the moment, but it should run if you change the Makefile parameters for your own setup.

Changelog

  • 03/08/2018: We removed MjSimPool, because most of benefit one can get with multiple processes having single simulation.

Credits

mujoco-py is maintained by the OpenAI Robotics team. Contributors include:

  • Alex Ray
  • Bob McGrew
  • Jonas Schneider
  • Jonathan Ho
  • Peter Welinder
  • Wojciech Zaremba
  • Jerry Tworek

mujoco-py's People

Contributors

aray-openai avatar bayesian avatar bchess avatar bmcgrew avatar bowenbaker avatar christopherhesse avatar dementrock avatar ethanabrooks avatar gautam1858 avatar gdb avatar hponde avatar ilge avatar jeffkaufman avatar jonasschneider avatar kevinzakka avatar machinaut avatar maciekcc avatar matthiasplappert avatar millionintegrals avatar nimrod-gileadi avatar ntezak avatar rfong avatar roboticsdashboard avatar rubendsa avatar siemanko avatar tlbtlbtlb avatar tylerneylon avatar welinder avatar wojzaremba avatar wookayin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mujoco-py's Issues

Mujoco's simulator does not display anything

Hello, I am planning to use open ai gym and mujoco model.
But I have a problem.
I run open-ai-gym's sample program ( For example, I run random_agent.py with Humanoid-v1 model).
The simulator starts up normally, but Mujoco's simulator does not display anything.
I try sample program on both ubuntu14.04 and mac OS, and simulator does not display anything with neither OS.
(The simulator seems not to respond, but the program itself keep running)
Does anyone know this phenomenon causes ?
Please give me some advice.

I attach an image when I run sample program.
2017-06-21 11 30 56

Fedora support

I can't figure out how to get this to build on Fedora. I looked at the dockerfile and installed the closest packages I can find, then anything that looked remotely related, yet I'm still getting undefined symbols when I try and build:

/home/rofer/.mujoco/mjpro150/bin/libmujoco150.so: undefined symbol: glNormal3f

Perturb an object in the scene

Hi,
I am new to mujoco-py. I would like to apply random forces such that it perturbs the object in the scene. Is there a way to do it using mujoco-py ?

'import mujoco_py' returns an error

I have installed everything but unfortunately when I import mujoco_py, I get the following error.

running build_ext
building 'mujoco_py.cymj' extension
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/ubuntu/metis/mujoco-py/mujoco_py -I/home/ubuntu/.mujoco/mjpro150/include -I/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/site-packages/numpy/core/include -I/home/ubuntu/anaconda2/envs/rllab3/include/python3.5m -c /home/ubuntu/metis/mujoco-py/mujoco_py/cymj.c -o /home/ubuntu/metis/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/home/ubuntu/metis/mujoco-py/mujoco_py/cymj.o -fopenmp -w
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/ubuntu/metis/mujoco-py/mujoco_py -I/home/ubuntu/.mujoco/mjpro150/include -I/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/site-packages/numpy/core/include -I/home/ubuntu/anaconda2/envs/rllab3/include/python3.5m -c /home/ubuntu/metis/mujoco-py/mujoco_py/gl/osmesashim.c -o /home/ubuntu/metis/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/home/ubuntu/metis/mujoco-py/mujoco_py/gl/osmesashim.o -fopenmp -w
gcc -pthread -shared -L/home/ubuntu/anaconda2/envs/rllab3/lib -Wl,-rpath=/home/ubuntu/anaconda2/envs/rllab3/lib,--no-as-needed /home/ubuntu/metis/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/home/ubuntu/metis/mujoco-py/mujoco_py/cymj.o /home/ubuntu/metis/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/home/ubuntu/metis/mujoco-py/mujoco_py/gl/osmesashim.o -L/home/ubuntu/.mujoco/mjpro150/bin -L/home/ubuntu/anaconda2/envs/rllab3/lib -Wl,--enable-new-dtags,-R/home/ubuntu/.mujoco/mjpro150/bin -lmujoco150 -lglewosmesa -lOSMesa -lGL -lpython3.5m -o /home/ubuntu/metis/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/lib.linux-x86_64-3.5/mujoco_py/cymj.cpython-35m-x86_64-linux-gnu.so -fopenmp
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
Traceback (most recent call last):
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/distutils/unixccompiler.py", line 196, in link
self.spawn(linker + ld_args)
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/distutils/ccompiler.py", line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/distutils/spawn.py", line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
% (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/home/ubuntu/metis/mujoco-py/mujoco_py/init.py", line 1, in
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
File "/home/ubuntu/metis/mujoco-py/mujoco_py/builder.py", line 296, in
cymj = load_cython_ext(mjpro_path)
File "/home/ubuntu/metis/mujoco-py/mujoco_py/builder.py", line 56, in load_cython_ext
cext_so_path = builder.build()
File "/home/ubuntu/metis/mujoco-py/mujoco_py/builder.py", line 119, in build
built_so_file_path = self._build_impl()
File "/home/ubuntu/metis/mujoco-py/mujoco_py/builder.py", line 139, in _build_impl
dist.run_commands()
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run
_build_ext.build_ext.run(self)
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/distutils/command/build_ext.py", line 338, in run
self.build_extensions()
File "/home/ubuntu/metis/mujoco-py/mujoco_py/builder.py", line 77, in build_extensions
build_ext.build_extensions(self)
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/site-packages/Cython/Distutils/old_build_ext.py", line 193, in build_extensions
self.build_extension(ext)
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/distutils/command/build_ext.py", line 557, in build_extension
target_lang=language)
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/distutils/ccompiler.py", line 717, in link_shared_object
extra_preargs, extra_postargs, build_temp, target_lang)
File "/home/ubuntu/anaconda2/envs/rllab3/lib/python3.5/distutils/unixccompiler.py", line 198, in link
raise LinkError(msg)
distutils.errors.LinkError: command 'gcc' failed with exit status 1

Any ideas of whats going wrong here?

Cheers!

Collisions detection

Dear developers,

is there a way I can check all collisions between geometries. Also can I somehow access force applied between two geometries which are colliding?

Thanks.

how to change the angle of camera

In initial state, the picture looks like below.
2016-06-23 21 04 37
I want to change the init state of camera so that the scene looks like this.
2016-06-23 21 05 18
What can I do?

OSError when using MjViewer.start()

I found there is a problem with MjViewer.start().
I'm using win10 with python3.6.1

import mujoco_py as mj

m = mj.MjModel("humanoid.xml")
v = mj.MjViewer()
v.set_model(m)
v.start()

Then error occurred:

Traceback (most recent call last): 
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda3\lib\site-packages\mujoco_py\mjviewer.py", line 180, in start _, _, refresh_rate = glfw.get_video_mode(glfw.get_primary_monitor()) 
  File "C:\Anaconda3\lib\site-packages\mujoco_py\glfw.py", line 719, in get_video_mode videomode = _glfw.glfwGetVideoMode(monitor).contents 
OSError: exception: access violation reading 0x0000000000000078

I don't know what the problem is and how to solve this.

Adding objects to the scene via OpenGL in mjviewer

Hi,

I was wondering if I could add primitive objects to the scene dynamically that is not present in the XML file. I don't want the physics of the objects to be simulated by mujoco. My core purpose is to translucent primitive shape in the scene that would show the prediction. For example, I have an box object in the scene that is described by the XML file. I want to overlay this box with an OpenGL cube that could be called from mjviewer so that I could remove this overlayed cube from time and again.

I tried adding it using the following bit of code to mjviewer.py. This draws a cube when independently tested. But I am unable to get it draw in the scene. Is it possible to do this or am I wasting time? Thanks for the time.

def drawCube(self, pos, ori, size):
        #this function expects center of the cube, orientation, and size as (length(x), breadh(y), height(z))
        
       glfw.make_context_current(self.window)
        self.gui_lock.acquire()

        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        gl.glLoadIdentity()
       
       gl.glTranslatef(pos[0],pos[1],pos[2])
        gl.glScalef(size[0],size[1],size[0])
 
        gl.glRotatef(ori[0],1.0,0.0,0.0)
        gl.glRotatef(ori[1],0.0,1.0,0.0)
        gl.glRotatef(ori[2],0.0,0.0,1.0)
 
        # Draw Cube (multiple quads)
        gl.glBegin(gl.GL_QUADS)
 
        gl.glColor3f(0.0,1.0,0.0)
        gl.glVertex3f( 1.0, 1.0,-1.0)
        gl.glVertex3f(-1.0, 1.0,-1.0)
        gl.glVertex3f(-1.0, 1.0, 1.0)
        gl.glVertex3f( 1.0, 1.0, 1.0) 
 
        gl.glColor3f(1.0,0.0,0.0)
        gl.glVertex3f( 1.0,-1.0, 1.0)
        gl.glVertex3f(-1.0,-1.0, 1.0)
        gl.glVertex3f(-1.0,-1.0,-1.0)
        gl.glVertex3f( 1.0,-1.0,-1.0) 
 
        gl.glColor3f(0.0,1.0,0.0)
        gl.glVertex3f( 1.0, 1.0, 1.0)
        gl.glVertex3f(-1.0, 1.0, 1.0)
        gl.glVertex3f(-1.0,-1.0, 1.0)
        gl.glVertex3f( 1.0,-1.0, 1.0)
 
        gl.glColor3f(1.0,1.0,0.0)
        gl.glVertex3f( 1.0,-1.0,-1.0)
        gl.glVertex3f(-1.0,-1.0,-1.0)
        gl.glVertex3f(-1.0, 1.0,-1.0)
        gl.glVertex3f( 1.0, 1.0,-1.0)
 
        gl.glColor3f(0.0,0.0,1.0)
        gl.glVertex3f(-1.0, 1.0, 1.0) 
        gl.glVertex3f(-1.0, 1.0,-1.0)
        gl.glVertex3f(-1.0,-1.0,-1.0) 
        gl.glVertex3f(-1.0,-1.0, 1.0) 
 
        gl.glColor3f(1.0,0.0,1.0)
        gl.glVertex3f( 1.0, 1.0,-1.0) 
        gl.glVertex3f( 1.0, 1.0, 1.0)
        gl.glVertex3f( 1.0,-1.0, 1.0)
        gl.glVertex3f( 1.0,-1.0,-1.0)

        gl.glEnd()
        self.gui_lock.release()

mujoco1.5.1.0 cant be installed on win10 64 with python 3.5.2 for the following reasons

cl : Command line warning D9025 : overriding '/W3' with '/w'
cl : Command line warning D9002 : ignoring unknown option '-fopenmp'
cymj.c
c:\users\yt\appdata\local\temp\pip-build-st333rsf\mujoco-py\mujoco_py\cymj.c(466): fatal error C1083: Cannot open include file: 'mjmodel.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2

----------------------------------------

Command "c:\users\yt\appdata\local\programs\python\python35\python.exe -u -c "import setuptools, tokenize;file='C:\Users\YT\AppData\Local\Temp\pip-build-st333rsf\mujoco-py\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\YT\AppData\Local\Temp\pip-w5zy5wak-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\YT\AppData\Local\Temp\pip-build-st333rsf\mujoco-py\

when i use easy_install, I can

Finished processing dependencies for mujoco_py
8orsv1htdzx7jb i6g z ij

then I use pip3
aei 7tsmi5 r9h 7b_ zjbu

finish the installation .but when i use it in IDE ,there stiil are some errors,
pej7 _5 hdda5m5hjexbv
which means it can not find the directory

besides ,I dont know how to implement the tha appveyor file for the canonical list of dependecies . I dont know what you mean. onece I run the python setup.py install . will it do all that nedded autonomously?
q0n0 x3imvztkdbq1pp5kja

@jonasschneider @welinder @avital @luddep @ @ @machinaut @

Setting state to model.data.qpos

Hi,

In the C code of mujoco, we could set the state of the robot by: mju_copy(data->qpos, ptr, model->nq), where ptr is the pointer to the data to be copied. But in python, it doesn't allow me to copy any value to the model.data.qpos.
This doesn't throw any error model.data.qpos = qnew => but doesn't work
Trying this: np.copyto(model.data.qpos,qnew) throws error:
ValueError: assignment destination is read-only I tried to change the model.data.qpos.flags.writeable = True, but still nothing happens.
I tried to use the mjlib.mju_copy.argtypes = [POINTER(c_double), POINTER(c_double), c_int]through a wrapper:

def copy(self, data_d, data_s, length):
        mjlib.mju_copy(data_d.ctypes.data_as(POINTER(c_double)), data_s.ctypes.data_as(POINTER(c_double)), c_int(length))

, no errors are thrown, but still it doesn't set my state.

Any help?

Segmentation fault in MjViewer()

I installed version 1.50.1.0 on Ubuntu 14.04 using Python 3.5.

Houever, when I tried examples/ programs, I got
running build_ext
Creating window glfw
Segmentation fault.

So I tried examples/disco_fetch.py line by line on IPython, but similarly, I got segmentation fault in "viewer = MjViewer(sim)" line.

I think this is the trouble of mujoco-py.MjViewer().
I'm investigating the cause, but I share the problem for the moment.

Environment changed, not working for python2 anymore

In setup.py, the first line

import importlib.util

This works only with python3! Also as mentioned in the installation guide, the eggs are not available through pip. I had to install using git (which failed of course!).

Error message in config.py

The error message in config.py for missing binaries and keys reads:
'To use MuJoCo, you need to either populate ~/.mujoco/mjkey.txt and ~/.mujco/mjpro131, or set the MUJOCO_PY_MJKEY_PATH and MUJOCO_PY_MJPRO_PATH environment variables appropriately. Follow the instructions on https://github.com/openai/mujoco-py for where to obtain these.'
But it should read:
'To use MuJoCo, you need to either populate ~/.mujoco/mjkey.txt and ~/.mujoco/mjpro131, or set the MUJOCO_PY_MJKEY_PATH and MUJOCO_PY_MJPRO_PATH environment variables appropriately. Follow the instructions on https://github.com/openai/mujoco-py for where to obtain these.'

(The difference is that the first says '/.mujco/mjpro131' but it should say './mujoco/mjpro131')

windows: anaconda: error running: The filename or extension is too long

hello,

On windows 10, I was finaly able to install mujoco-py. However when trying to run an example I am getting the following:

tensorflow-gpu) C:\test\mujoco-py\mujoco-py-master\examples>python tosser.py
running build_ext
building 'mujoco_py.cymj' extension
creating C:\Users\test\Anaconda3\envs\tensorflow-gpu\lib\site-packages\mujoco_py-1.50.1.7-py3.5.egg\mujoco_py\generated_pyxbld_WindowsExtensionBuilder\temp.win-amd64-3.5\Release\Users\test\Anaconda3\envs\tensorflow-gpu\lib\site-packages\mujoco_py-1.50.1.7-py3.5.egg
Traceback (most recent call last):
File "C:\Users\test\Anaconda3\envs\tensorflow-gpu\lib\distutils\dir_util.py", line 70, in mkpath
os.mkdir(head, mode)
FileNotFoundError: [WinError 206] The filename or extension is too long: 'C:\Users\test\Anaconda3\envs\tensorflow-gpu\lib\site-packages\mujoco_py-1.50.1.7-py3.5.egg\mujoco_py\generated\_pyxbld_WindowsExtensionBuilder\temp.win-amd64-3.5\Release\Users\test\Anaconda3\envs\tensorflow-gpu\lib\site-packages\mujoco_py-1.50.1.7-py3.5.egg'

distutils.errors.CompileError: command '/usr/local/bin/gcc-7' failed with exit status 1

Error:

>>> import mujoco_py
Compiling /Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.pyx because it changed.
[1/1] Cythonizing /Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.pyx
running build_ext
building 'mujoco_py.cymj' extension
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek/Packages
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek/Packages/mujoco-py
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek/Packages/mujoco-py/mujoco_py
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek/Packages/mujoco-py/mujoco_py/gl
/usr/local/bin/gcc-7 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/anaconda/envs/python3/include -arch x86_64 -DONMAC -I/Users/abhishek/Packages/mujoco-py/mujoco_py -I/Users/abhishek/.mujoco/mjpro150/include -I/Users/abhishek/.virtualenvs/python3/lib/python3.5/site-packages/numpy/core/include -I/Users/abhishek/.virtualenvs/python3/include/python3.5m -c /Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.c -o /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.o -fopenmp -w
/Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.c:476:10: fatal error: mjmodel.h: No such file or directory
 #include "mjmodel.h"
          ^~~~~~~~~~~
compilation terminated.
Traceback (most recent call last):
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/unixccompiler.py", line 118, in _compile
    extra_postargs)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
    % (cmd, exit_status))
distutils.errors.DistutilsExecError: command '/usr/local/bin/gcc-7' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/__init__.py", line 1, in <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 283, in <module>
    cymj = load_cython_ext(mjpro_path)
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 54, in load_cython_ext
    cext_so_path = builder.build()
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 200, in build
    so_file_path = super().build()
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 131, in build
    dist.run_commands()
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run
    _build_ext.build_ext.run(self)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 75, in build_extensions
    build_ext.build_extensions(self)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/site-packages/Cython/Distutils/old_build_ext.py", line 193, in build_extensions
    self.build_extension(ext)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/command/build_ext.py", line 533, in build_extension
    depends=ext.depends)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command '/usr/local/bin/gcc-7' failed with exit status 1

Version:

$ conda list | grep mujoco
mujoco-py                 1.50.0.7                  <pip>
$ python --version
Python 3.5.3 :: Anaconda 4.4.0 (x86_64)

OS:

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.12.5

Possible similar issues:
#43

Error installing

I am unable to install these it is showing this error TypeError: can't pickle Cython.Compiler.Code.FunctionState objects

Can mujoco-py be used via VirtualBox?

I am running mujoco-py via an Ubuntu 16.04 VM on a Macbook Pro. When I run make test, I get the following errors on the last 4 tests.

NullFunctionError: Attempt to call an undefined function glIsFramebuffer, check for bool(glIsFramebuffer) before calling

NullFunctionError: Attempt to call an undefined function glGenFramebuffers, check for bool(glGenFramebuffers) before calling

I have 3D acceleration turned on for the VM, and I have mujoco installed in the standard paths.

Any suggestions for fixing this issue would be appreciated. Thanks.

Setting a maximum velocity for a joint

Hi,

is it possible to set a maximum velocity for a joint, similarly to the "maxvel" property in earlier mujoco versions?
Directly setting the velocity data field does not work since it is write-protected.

Error installing version 1.50.1.0 on Mac

I'm easily able to install the older version even with my python3, but I get this error when trying to install the latest version:

Collecting mujoco-py<1.50.2,>=1.50.1
  Using cached mujoco-py-1.50.1.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/q0/n8dmc77j3n3gj91k_3p90kn40000gp/T/pip-build-0p9_zA/mujoco-py/setup.py", line 2, in <module>
        import importlib.util
    ImportError: No module named util

Trying to use one function of mjlib

Hi,

I have doubt, can anyone please help?

I want to use the mj_fullM function of mjlib. (line 172 and 173). This is commented. So in my forked version of mujoco-py, I tried to add a wrapper for same as follows:

Line 172 and 173 in mjlib

mjlib.mj_fullM.argtypes = [POINTER(MJMODEL), POINTER(c_double), POINTER(c_double)]
mjlib.mj_fullM.restype = None

in mjcore.py

def fullM(self):
        array_length = self.nv*self.nv*100
        fullqM = np.zeros((array_length))
        mjlib.mj_fullM(self.ptr, fullqM.astype(np.double).ctypes.data_as(POINTER(c_double)), self.data.qM.astype(np.double).ctypes.data_as(POINTER(c_double)))
        return fullqM

But on calling in my main:

myObj.model.fullM(), I get back just a bunch of zeros. While myObj.model.data.qM does have the values in it.

In the mujoco library the mj_fullM function converts the reduced inertia matrix to the complete inertia matrix.

What am I doing wrong? Any suggestion?

Error instaling on Ubuntu 14.04 with Python 3.6

I'm trying to install version 1.50.1.0 on Ubuntu 14.04 using Python 3.6.

I tried
$ pip install -U 'mujoco-py<1.50.2,>=1.50.1'
but returned unknown error.

So in ./mujoco-py, i tried
$ python setup.py install
and it looks like successfull.

However, when I import mujoco-py in IPython,
TypeError: can't pickle Cython.Compiler.Code.FunctionState objects
returned.

What should I do?

glfw Window freezes and becomes unresponsive

Just trying to get to know mujoco-py wrappers. But I do face the following issue.

from mujoco_py import mjviewer, mjcore
from mujoco_py import mjtypes
from mujoco_py import glfw

width = 1500
height = 1500
viewer = mjviewer.MjViewer(visible=True, init_width=width, init_height=height)
viewer.start()
model = mjcore.MjModel('/home/mjm/Documents/Python/Mujoco/cartpole.xml')
viewer.set_model(model)
(data, width, height) = viewer.get_image()
#viewer.finish()
#viewer = None

When I do this, the "Simulate" window pops up and freezes. Now the only way to stop it is by killing it.
It is unresponsive and does not display anything. Along with the python console also crashes and would have to reopen again.

Once I kill it, this is the error that I get in the terminal:

XIO:  fatal IO error 0 (Success) on X server ":0"

      after 212 requests (212 known processed) with 39 events remaining.

I am running Ubuntu 14.04 64bit on Macbook pro with Nvdia graphics card. My environment variable $DISPLAY:=0

I found a similar error in stackoverflow

Any idea why this happens? Is there a work around to it?

Any helpful suggestion is appreciated.

Adding wrapper for mj_applyFT

Hi,

This is a C++ helper function for mujoco: It applies cartesian force and torque (outside xfrc_applied mechanism)

MJAPI void mj_applyFT(const mjModel* m, mjData* d, 
                      const mjtNum* force, const mjtNum* torque, 
                      const mjtNum* point, int body, mjtNum* qfrc_target);

I added the wrapper in mjcore.py with the following statement.

mjlib.mj_applyFT(self.ptr, self.data.ptr,\
                         force.ctypes.data_as(POINTER(c_double)),\
                         torque.ctypes.data_as(POINTER(c_double)),\
                         point.ctypes.data_as(POINTER(c_double)),\
                         body_adr,\
                         self.data.qfrc_applied.ctypes.data_as(POINTER(c_double)));

force is a 3 x 1 ndarray, torque is a 3 x1 ndarray, point is a 3 x 1 ndarray and body_adr is the body index qfrc_target is the array to which we have to copy.

But it doesn't copy the values to self.data.qfrc_applied, but if I try to directly copy it, it works (i.e. self.data.qfrc_applied = np.hstack([force, torque])).

I called mj_forward() to see if it gets updated, but it doesn't.

Could you please suggest on what I am doing wrong?

Error

Hi I am getting the following error with python version 3.5.2 and gcc 4.2.1

gcc-7: warning: x86_64 conflicts with i386 (arch flags ignored)
    /private/var/folders/pc/5yb_kn9d69v4vgbrrvjrttww0000gn/T/pip-build-dpywvvan/mujoco-py/mujoco_py/cymj.c:476:10: fatal error: mjmodel.h: No such file or directory
     #include "mjmodel.h"
              ^~~~~~~~~~~
    compilation terminated.
    error: command '/usr/local/bin/gcc-7' failed with exit status 1
    
    ----------------------------------------
  Rolling back uninstall of mujoco-py
Command "/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/private/var/folders/pc/5yb_kn9d69v4vgbrrvjrttww0000gn/T/pip-build-dpywvvan/mujoco-py/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/pc/5yb_kn9d69v4vgbrrvjrttww0000gn/T/pip-9zmh2fbn-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/pc/5yb_kn9d69v4vgbrrvjrttww0000gn/T/pip-build-dpywvvan/mujoco-py/

OSx

Only Mujoco 1.5 works in OSx so could you guys release support for 1.5 instead of 1.31 version of Mujoco

Commented out functionality

In mjlib.py some of the function signature bindings are commented out. In particularly, I am interested in:
#mjlib.mj_applyFT.argtypes = [POINTER(MJMODEL), POINTER(MJDATA), POINTER(c_double), POINTER(c_double), POINTER(c_double), c_int, POINTER(c_double)]
#mjlib.mj_applyFT.restype = None
since I want to apply a force (or impulse) to a point in a global frame. Does it mean the bindings are not there yet or the signatures are automatically matched. If they are then, an example of how to use them (to apply predefined forces in specified locations) could be extremely useful.
Thank you.

Crashing when calling start() method on mujoco_py.MjViewer object

Hi there,
my program is crashing when calling the start() method on the MjViewer object.

self._viewer_main = mujoco_py.MjViewer(visible=True, init_width=AGENT_MUJOCO['image_width'],
            init_height=AGENT_MUJOCO['image_height'])

self._viewer_main.start()

The context for this code is here

It only crashes when running it on a desktop machine with the nvidia 1080, but runs without erros on my laptop with a much older graphics card.

When tracking the error down in 'self._viewer_main.start()' it appears to be crashing:
just here

Unfortunately I'm not getting a stack trace. It just says: Process finished with exit code 139 (interrupted by signal 11: SIGSEGV) So it seems its crashing inside glfw?

Any hints how to investigate this further?

Failed building wheel for mujoco-py

Here is the full log:

`pip3 install -U 'mujoco-py<1.50.2,>=1.50.1'
Collecting mujoco-py<1.50.2,>=1.50.1
Using cached mujoco-py-1.50.1.7.tar.gz
Requirement already up-to-date: glfw>=1.4.0 in /usr/local/lib/python3.5/dist-packages (from mujoco-py<1.50.2,>=1.50.1)
Requirement already up-to-date: numpy>=1.11 in ./.local/lib/python3.5/site-packages (from mujoco-py<1.50.2,>=1.50.1)
Requirement already up-to-date: Cython>=0.25.2 in /usr/local/lib/python3.5/dist-packages (from mujoco-py<1.50.2,>=1.50.1)
Requirement already up-to-date: imageio>=2.1.2 in ./.local/lib/python3.5/site-packages (from mujoco-py<1.50.2,>=1.50.1)
Requirement already up-to-date: pillow in ./.local/lib/python3.5/site-packages (from imageio>=2.1.2->mujoco-py<1.50.2,>=1.50.1)
Requirement already up-to-date: olefile in ./.local/lib/python3.5/site-packages (from pillow->imageio>=2.1.2->mujoco-py<1.50.2,>=1.50.1)
Building wheels for collected packages: mujoco-py
Running setup.py bdist_wheel for mujoco-py ... -
error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-lfrvbntl/mujoco-py/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/tmpfe_jl9xipip-wheel- --python-tag cp35:
running bdist_wheel
running build
Compiling /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/cymj.pyx because it changed.
[1/1] Cythonizing /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/cymj.pyx
running build_ext
building 'mujoco_py.cymj' extension
creating /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder
creating /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5
creating /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp
creating /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp/pip-build-lfrvbntl
creating /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp/pip-build-lfrvbntl/mujoco-py
creating /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py
creating /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/gl
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py -I/home/pco/.mujoco/mjpro150/include -I/home/pco/.local/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -c /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/cymj.c -o /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/cymj.o -fopenmp -w
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py -I/home/pco/.mujoco/mjpro150/include -I/home/pco/.local/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -c /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/gl/osmesashim.c -o /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/gl/osmesashim.o -fopenmp -w
creating /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/lib.linux-x86_64-3.5
creating /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/lib.linux-x86_64-3.5/mujoco_py
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/cymj.o /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/gl/osmesashim.o -L/home/pco/.mujoco/mjpro150/bin -Wl,--enable-new-dtags,-R/home/pco/.mujoco/mjpro150/bin -lmujoco150 -lglewosmesa -lOSMesa -o /tmp/pip-build-lfrvbntl/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/lib.linux-x86_64-3.5/mujoco_py/cymj.cpython-35m-x86_64-linux-gnu.so -fopenmp
���[��� �[V: not found
sh: 2: [
: not found
���[��� �[V: not found
sh: 2: [
: not found
���[��� �[V: not found
sh: 2: Syntax error: "(" unexpected
���[��� �[V: not found
sh: 2: Syntax error: "(" unexpected
ERROR: Invalid activation key

Press Enter to exit ...


Failed building wheel for mujoco-py
Running setup.py clean for mujoco-py
Failed to build mujoco-py
Installing collected packages: mujoco-py
Running setup.py install for mujoco-py ...
error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-lfrvbntl/mujoco-py/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-yeem0tw6-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
���[��� �[V: not found
sh: 2: [
: not found
���[��� �[V: not found
sh: 2: [
: not found
���[��� �[V: not found
sh: 2: Syntax error: "(" unexpected
���[��� �[V: not found
sh: 2: Syntax error: "(" unexpected
ERROR: Invalid activation key

Press Enter to exit ...

----------------------------------------

Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-lfrvbntl/mujoco-py/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-yeem0tw6-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-lfrvbntl/mujoco-py/
`
I did note "ERROR: Invalid activation key", but I am able to run ./simulate from mjpro150/bin directory with no problem. Also, this error comes after the strange binary characters. I've placed copies of my mjkey.txt file in .mujoco/ as specified in mujoco-py instructions

Mouse Controls results in error.

Mouse actions on the open window throws error and result in hanging. For example when the rendered window is tried to be scrolled to adjust zoom, following error comes up.

Traceback (most recent call last):
File "_ctypes/callbacks.c", line 314, in 'calling callback function'
File "/Library/Python/2.7/site-packages/mujoco_py/mjviewer.py", line 294, in handle_scroll
mjlib.mjv_moveCamera(MOUSE_ZOOM, 0, (-20*y_offset), byref(self.cam), width, height)
NameError: global name 'MOUSE_ZOOM' is not defined

Same is the case with left and right buttons. Is this a known issue?

Is there a work around?

I am running mujoco_py on mac osx El Captain

problem with load_model_from_path

Hi whenever I run a program having load_model_from_path, I am getting the following error
Example : python3 disco_fetch.py

Traceback (most recent call last):
  File "disco_fetch.py", line 9, in <module>
    model = load_model_from_path("xmls/fetch/main.xml")
  File "mujoco_py/cymj.pyx", line 113, in mujoco_py.cymj.load_model_from_path (/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mujoco_py-1.50.1.6-py3.5.egg/mujoco_py/cymj.c:122039)
Exception: Failed to load XML file: xmls/fetch/main.xml. mj_loadXML error: b'XML parse error at line 0, column 0:\nFailed to open file\n'

The program works fine for load_model_from_xml()

Python 3.6 support

As reported in #43, #47, #49, we currently don't support Python 3.6. We should fix these bugs and add 3.6 to the Travis build matrix.

How to copy value to mjcore.model.body_pos?

When I try to copy a value to this variable like this,
model.data_pos = newValue
it says,
ValueError: assignment destination is read-only.
So I tried to using the inbuilt function mjlib.mju_copy(data_d.ctypes.data_as(POINTER(c_double)), data_s.ctypes.data_as(POINTER(c_double)), c_int(length)) in the following way.
mjlib.mju_copy(model.data_pos.ctypes.data_as(POINTER(c_double)), newValue.ctypes.data_as(POINTER(c_double)), c_int(3))
This statement does not produce any error, nevertheless the value remain unchanged.
Could anyone please tell me how to copy a new value to it?

Error installing v1.5: "fatal error: mjmodel.h: No such file or directory"

If I run pip install mujoco-py on a new Python 3 anaconda environment, I get the following error.

gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tmp/pip-build-q027_l94/mujoco-py/mujoco_py -I/
home/vitchyr/.mujoco/mjpro150/include -I/home/vitchyr/.local/lib/python3.5/site-packages/numpy/core/include -I/home/v
itchyr/anaconda2/envs/rllab-vitchyr/include/python3.5m -c /tmp/pip-build-q027_l94/mujoco-py/mujoco_py/cymj.c -o /tmp/
pip-build-q027_l94/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp/pip-build
-q027_l94/mujoco-py/mujoco_py/cymj.o -fopenmp -w
    /tmp/pip-build-q027_l94/mujoco-py/mujoco_py/cymj.c:471:21: fatal error: mjmodel.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1

However, I'm able to install older versions, i.e. pip install mujoco-py==0.5.7 works. Is there a new dependency

Unknow error installing using Python3 and Anaconda3 on Linux

After coming to know that this is not available in Python2, I did fresh install of Anaconda3, set up python3 environment and tried installing.
However, it throws errors such as:

TypeError: can't pickle Cython.Compiler.Code.FunctionState objects

and

Command "/home/him/anaconda3/envs/tensorflow/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-j00wxlw4/mujoco-py/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-dstl1tts-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-j00wxlw4/mujoco-py/

Attaching hereby the full installation log file and hardware configuration for reference.
sysconfig.txt
install_log.txt

Edit: I was getting very similar errors after modifying the source code to make it compatible for Python2 too! Here is python2 install log.
python2_install_log.txt
(I really don't want you to bug you with python2 thing, since its now mentioned there that python2 isn't supported. Still I just want to see if it's not the problem of python2. If it's the case, I will make it compatible for python2.)

Multiple instances with RGB fails with X server

I'm trying to run several instances of a custom env which has an RGB state via MjViewer, but I get errors such as the following:

XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 216 requests (216 known processed) with 50 events remaining.
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 216 requests (216 known processed) with 50 events remaining.
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 218 requests (218 known processed) with 50 events remaining.

It works fine with one instance, but it crashes with more running in parallel. I've also tried initialising MjViewer with visible=True/False and go_fast=True/False, but this doesn't make a difference. For both one instance and many I start the envs through Python's multiprocessing.Process. At one point I saw the following error, which seems more informative:

[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
python: ../../src/xcb_io.c:274: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
XIO:  fatal IO error 0 (Success) on X server ":0"
      after 225 requests (225 known processed) with 0 events remaining.

I am running Ubuntu 14.04 with Python 3.6 and MuJoCo 1.31.

EDIT: The env works fine with threading.Thread, so it's definitely a problem with not being able to run in multiple processes. Although Python threads work, they are subject to the GIL, so this isn't ideal.

Does mujoco-py support access to MuJoCo's text rendering functions?

For instance the C++ allows rendering text using something like this:

    // no model: empty screen
    if( !m )
    {
	mjr_rectangle(1, rect, 0, 0, rect.width, rect.height, 
		0.2, 0.3, 0.4, 1);
        mjr_overlay(rect, mjGRID_TOPLEFT, 0, "Drag-and-drop model file here", 0, &con);
        gui_mutex.unlock();
        return;
    }

So I attempted to recreate that by adding the following to my step function:

mjrect = mjcore.MJRRECT(0, 0, 10, 10)
mjlib.mjr_overlay(mjrect, 0, 0, "Some Test Text", 0, self._get_viewer().con)

No text is displayed, but there are a lot of reasons that might be so. Is use of the mjr_overlay supported in this way? I noticed it was commented out.

Change Mujoco Model Parameters online

Hi there,

I am not sure if this is the correct forum for this question but I would like to ask whether it is possible, using your python wrappers, to change the Mujoco model parameters dynamically between time steps. For example, in inverted pendulum, can I change the mass or length of the pendulum at each time step?

Thanks!

Touch Sensors

Are touch sensors supported by mujoco-py? I am trying to create one using this xml-file:

<worldbody>
        <camera name="maincam" mode= "fixed" fovy="75" euler="0 0 0" pos="0 0 .75"/>
        <body name="particle" pos="0 0 0.03">
            <inertial pos="0 0 0" mass="5" diaginertia="166.667 166.667 166.667"/>
            <geom name="particle_geom" type="capsule" fromto="-0.01 0 0 0.01 0 0" size="0.05" rgba="0.9 0 0.1 0.6" />
            <joint name="ball_x" type="slide" pos="0 0 0" axis="1 0 0" />
            <joint name="ball_y" type="slide" pos="0 0 0" axis="0 1 0" />

            <sensor>
                <site name="sensorsurf" pos="0 0 0.035" size="0.05" type="ellipsoid" rgba="0.3 0.2 0.1 0.3"/>
                <touch name="touchsensor" site="sensorsurf" />
            </sensor>

        </body>

</worldbody>

However I'm getting the following error:

/site-packages/mujoco_py/mjcore.py", line 37, in __init__
    raise MjError(buf.value)
mujoco_py.mjcore.MjError: XML Error: Schema violation: unrecognized element

Element 'sensor', line 19, column 13

Do you have an example xml-file of how to define touch sensors?

If touch sensors are not yet supported what would need to be done to integrate them?
As an alternative to touch sensors, is there a straightforward way to obtain contact forces from mujoco-py?

Could not close renderer for InvertedPendulum-v1: _type_ must have storage info

I am trying to run some mujoco environments but unfortunately I get this error when I want to render and monitor the video. Any idea?

[2017-01-04 04:01:05,683] Starting new video recorder writing to /home/hipoglucido/Dropbox/Data_Science/Computational_Cognitive_Neuroscience/project/ddpg-aigym/results/InvertedPendulum-v1False/openaigym.video.0.2957.video000000.mp4
libGL error: unable to load driver: vmwgfx_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: vmwgfx
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
Traceback (most recent call last):
File "main.py", line 90, in
main()
File "main.py", line 52, in main
observation = env.reset()
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/core.py", line 124, in reset
observation = self._reset()
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/wrappers/monitoring.py", line 29, in _reset
self._monitor._after_reset(observation)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/monitoring/monitor_manager.py", line 264, in _after_reset
self._reset_video_recorder()
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/monitoring/monitor_manager.py", line 285, in _reset_video_recorder
self.video_recorder.capture_frame()
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/monitoring/video_recorder.py", line 106, in capture_frame
frame = self.env.render(mode=render_mode)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/core.py", line 175, in render
return self._render(mode=mode, close=close)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/core.py", line 344, in _render
return self.env.render(mode, close)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/core.py", line 175, in render
return self._render(mode=mode, close=close)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/envs/mujoco/mujoco_env.py", line 111, in _render
self._get_viewer().render()
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/envs/mujoco/mujoco_env.py", line 120, in _get_viewer
self.viewer.start()
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/mujoco_py/mjviewer.py", line 207, in start
self._init_framebuffer_object()
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/mujoco_py/mjviewer.py", line 137, in _init_framebuffer_object
fbo = gl.glGenFramebuffers(1)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/OpenGL/latebind.py", line 45, in call
return self._finalCall( *args, **named )
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/OpenGL/wrapper.py", line 657, in wrapperCall
result = wrappedOperation( *cArguments )
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/OpenGL/platform/baseplatform.py", line 407, in call
self.name, self.name,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glGenFramebuffers, check for bool(glGenFramebuffers) before calling
[2017-01-04 04:01:05,872] Could not close renderer for InvertedPendulum-v1: type must have storage info
[2017-01-04 04:01:05,873] Finished writing results. You can upload them to the scoreboard via gym.upload('/home/hipoglucido/Dropbox/Data_Science/Computational_Cognitive_Neuroscience/project/ddpg-aigym/results/InvertedPendulum-v1False')
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/home/hipoglucido/anaconda2/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/utils/closer.py", line 67, in close
closeable.close()
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/core.py", line 189, in close
self.render(close=True)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/core.py", line 166, in render
return self._render(close=close)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/envs/mujoco/mujoco_env.py", line 106, in _render
self._get_viewer().finish()
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/mujoco_py/mjviewer.py", line 325, in finish
glfw.destroy_window(self.window)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/mujoco_py/glfw.py", line 809, in destroy_window
window_addr = ctypes.cast(ctypes.pointer(window),
TypeError: type must have storage info
Error in sys.exitfunc:
Traceback (most recent call last):
File "/home/hipoglucido/anaconda2/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/utils/closer.py", line 67, in close
closeable.close()
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/core.py", line 189, in close
self.render(close=True)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/core.py", line 166, in render
return self._render(close=close)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/gym/envs/mujoco/mujoco_env.py", line 106, in _render
self._get_viewer().finish()
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/mujoco_py/mjviewer.py", line 325, in finish
glfw.destroy_window(self.window)
File "/home/hipoglucido/anaconda2/lib/python2.7/site-packages/mujoco_py/glfw.py", line 809, in destroy_window
window_addr = ctypes.cast(ctypes.pointer(window),
TypeError: type must have storage info

Big drop in performance in new version

Thanks a lot for the new release, I'm really excited about being able to use the newer version of MuJoCo and its features! 🎉

Unfortunately, since upgrading to the new bindings, I've seen a big drop in performance, specifically linked to RGB rendering.

I'm training an agent using RGB inputs, that I used to capture from a MjViewer instance (I actually capture 2 different views, but the problem is the same for a single view).
I now use the MjSim render() method (which is nicer, thanks) .

Unfortunately, I'm seeing a 3-4x drop in performance per thread, which compounds with multiprocessing, making training nearly impossibly slow right now...

Here are some profiling traces. Obviously there is some variability, but these numbers seem pretty consistent.

This is with the codebase v0.5:

*** PROFILER RESULTS ***
_step function called 1 times

         329 function calls in 0.018 seconds

   Ordered by: cumulative time, internal time, call count
   List reduced from 87 to 40 due to restriction <40>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.018    0.018 myenv.py:68(_step)
        1    0.000    0.000    0.016    0.016 myenv.py:42(_get_obs)
        2    0.000    0.000    0.016    0.008 mujoco_env.py:120(_render)
        1    0.000    0.000    0.014    0.014 myenv.py:52(_get_obs_rgb_view1)
        2    0.000    0.000    0.011    0.006 mjviewer.py:118(get_image)
        4    0.000    0.000    0.011    0.003 mjviewer.py:110(get_dimensions)
        4    0.011    0.003    0.011    0.003 glfw.py:916(get_framebuffer_size)
        2    0.004    0.002    0.004    0.002 mjviewer.py:91(render)
        1    0.000    0.000    0.001    0.001 myenv.py:60(_get_obs_rgb_view2)
        1    0.000    0.000    0.001    0.001 mujoco_env.py:105(do_simulation)
        4    0.001    0.000    0.001    0.000 mjcore.py:79(step)
        2    0.001    0.000    0.001    0.000 images.py:338(glReadPixels)

This is with the new codebase:

*** PROFILER RESULTS ***
step function called 1 times

         65 function calls in 0.058 seconds

   Ordered by: cumulative time, internal time, call count

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.058    0.058 myenv.py:131(step)
        1    0.000    0.000    0.056    0.056 myenv.py:114(get_obs)
        2    0.000    0.000    0.056    0.028 myenv.py:97(render)
        2    0.056    0.028    0.056    0.028 {method 'render' of 'mujoco_py.cymj.MjSim' objects}
        1    0.000    0.000    0.029    0.029 myenv.py:109(_get_obs_rgb_view2)
        1    0.000    0.000    0.028    0.028 myenv.py:104(_get_obs_rgb_view1)
        1    0.000    0.000    0.001    0.001 myenv.py:117(do_simulation)
        4    0.001    0.000    0.001    0.000 {method 'step' of 'mujoco_py.cymj.MjSim' objects}

My assumptions for why that may be are currently:

  1. There is no go_fast option in the new codebase anymore. Would that mean that we are stuck at 60Hz even in offscreen rendering?
  2. The render() function in the MjSim class and the MjRenderContext became slower due to added ifs and memory allocations?

Trying to force a GLFW context instead of the new OpenGL one didn't help.

I'm using CPU offscreen rendering, Linux Ubuntu 16.04, Python 3.5.2.

It would be great if you could tell me what I may be doing wrong or if you are seeing this on your side as well?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.