MuJoCo Playground 是一个用于 GPU 加速机器人学习和模拟到现实传输的开源库。
该项目使用 MuJoCo MJX (https://github.com/shacklettbp/madrona_mjx) 构建的用于机器人学习研究和模拟到现实的 GPU 加速环境综合套件。
功能包括
- 在 MJX 中重新实现 dm_control 的经典控制环境。
- 四足和双足运动环境。
- 非理解性和灵巧操纵环境。
- 通过 Madrona-MJX 提供基于视觉的支持。
- 更多详情,请访问项目网站:Playground 。
下面开始该项目的复现:
注意:该项目需要安装CUDA与显卡驱动,其中CUDA的安装教程:
Ubuntu20.04 Cuda-12.1安装记录_ubuntu20 安装cuda12.0-CSDN博客
我的电脑系统使用的是ubuntu20.04,linux系统(不是虚拟机)
首先是创建conda环境:Requires Python 3.10 or later.
conda create -n mujo_play python=3.10
conda activate mujo_play
选择一个code放置的目录,在此目录下继续运行指令:
git clone https://github.com/google-deepmind/mujoco_playground.git
cd mujoco_playground
进入到mujoco_playground目录当中后,启用mujo_play的conda环境:
conda activate mujo_play
pip install uv
下面继续 Install CUDA 12 jax:
uv pip install -U "jax[cuda12]"
验证 GPU 后端的指令:
python -c "import jax; print(jax.default_backend())"
# 应该打印出 gpu
继续Install playground:
uv pip install -e ".[all]"
再验证安装(并下载 Menagerie):
python -c "import mujoco_playground"
终端中出现如下信息,则说明安装下载成功:
下面在pycharm编辑器中打开项目,并执行python测试脚本manipulation_test.py:
运行完成后,没有报错则说明环境配置无误!测试代码执行无误的界面如下:
下面接着运行官方的demo,找到sim2sim目录下的play_bh_joystick.py文件并运行会出现报错:
Traceback (most recent call last):
File "/home/hjx/hjx_file/mujoco_playground/mujoco_playground/experimental/sim2sim/play_bh_joystick.py", line 21, in <module>
import onnxruntime as rt
ModuleNotFoundError: No module named 'onnxruntime'
解决方法:
pip install onnxruntime
再次运行,遇到报错:
Traceback (most recent call last):
File "/home/hjx/hjx_file/mujoco_playground/mujoco_playground/experimental/sim2sim/play_bh_joystick.py", line 25, in <module>
from mujoco_playground.experimental.sim2sim.gamepad_reader import Gamepad
File "/home/hjx/hjx_file/mujoco_playground/mujoco_playground/experimental/sim2sim/gamepad_reader.py", line 23, in <module>
import hid
ModuleNotFoundError: No module named 'hid'
解决方法:
pip install hidapi
问题得到解决后,再次运行会出现如下界面:
说明代码运行成功!
Gamepad.__init__() got an unexpected keyword argument 'deadzone'
参考: