mujoco-py icon indicating copy to clipboard operation
mujoco-py copied to clipboard

python3 setting_state.py ERROR

Open Rashikesh opened this issue 11 months ago • 1 comments

Describe the bug All step are done but facing this issues & i don't have export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia NVIDIA or graphics card is it because of that

mujoco_e1 mujoco_e2

what step should i follow to eliminate the problem is facing

This COMMAND is also not executable

sudo apt-get install libxslt1-dev zlib1g-dev libglew1.5 libglew-dev python3-pip

I hope the solution is there for this issues

Rashikesh avatar Dec 23 '24 13:12 Rashikesh

To suppoert MUJOCO envs is a bit tedious, you need to:

  1. Go to the mujoco-py github page. Follow the installation instructions in the README
  2. Then, install some libraries (assume you are using Ubuntu)
    sudo apt install libosmesa6-dev libgl1-mesa-glx libglfw3
    sudo apt-get install patchelf # From https://gist.github.com/saratrajput/60b1310fe9d9df664f9983b38b50d5da
    pip install "cython<3" # From https://github.com/openai/mujoco-py/issues/773#issuecomment-1639684035
    sudo apt-get install libglew-dev # From https://stackoverflow.com/questions/76985054/import-mujoco-py-is-giving-me-compiling-errors
    
  3. To install mujoco-py:
    wget https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz
    mkdir -p ~/.mujoco
    tar -xvzf mujoco210-linux-x86_64.tar.gz -C ~/.mujoco
    ls ~/.mujoco/mujoco210
    pip3 install -U 'mujoco-py<2.2,>=2.1'
    

After that, you should be able to run this script:

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]

LYK-love avatar Feb 06 '25 06:02 LYK-love