OpenAI-Gym Mojoco Walker2d-v4模型全局坐标错误

问题描述 投票:0回答:2

我收到错误

ValueError: XML Error: global coordinates no longer supported. To convert existing models, load and save them in MuJoCo 2.3.3 or older

当我尝试加载

walker2d-v4
模型时,即使使用
**kwargs

env = gym.make(
    'Walker2d-v4',
    # xml_file="walker2d.xml",
    forward_reward_weight=1.0,
    ctrl_cost_weight=1e-3,
    healthy_reward=1.0,
    terminate_when_unhealthy=True,
    healthy_z_range=(0.8, 2),
    healthy_angle_range=(-1, 1),
    reset_noise_scale=5e-3,
    exclude_current_positions_from_observation=True
)

有人遇到类似问题吗?


这是解决方案,感谢@yuval 指出。

您需要将出现此错误的

walker2d.xml
加载到模型中。为此,您需要安装 mujoco 2.3.3,然后运行以下代码,

model = mujoco.MjModel.from_xml_path('walker2d.xml')
mujoco.viewer.launch(model)

这应该打开一个 mujoco 查看器窗口,其中有一个“保存 XML”选项 - 这应该将更新的 xml 文件保存为当前目录中的

mjmodel.xml
。只需将其复制粘贴到
walker2d.xml
中,您的健身房代码现在应该可以运行了。

Walker2D XML 对我有用

<mujoco model="walker2d">
  <compiler angle="radian" autolimits="true"/>
  <option integrator="RK4"/>
  <default class="main">
    <joint limited="true" armature="0.01" damping="0.1"/>
    <geom conaffinity="0" friction="0.7 0.1 0.1" rgba="0.8 0.6 0.4 1"/>
  </default>
  <asset>
    <texture type="skybox" builtin="gradient" rgb1="0.4 0.5 0.6" rgb2="0 0 0" width="100" height="600"/>
    <texture type="cube" name="texgeom" builtin="flat" mark="cross" rgb1="0.8 0.6 0.4" rgb2="0.8 0.6 0.4" markrgb="1 1 1" width="127" height="762"/>
    <texture type="2d" name="texplane" builtin="checker" rgb1="0 0 0" rgb2="0.8 0.8 0.8" width="100" height="100"/>
    <material name="MatPlane" texture="texplane" texrepeat="60 60" specular="1" shininess="1" reflectance="0.5"/>
    <material name="geom" texture="texgeom" texuniform="true"/>
  </asset>
  <worldbody>
    <geom name="floor" size="40 40 40" type="plane" conaffinity="1" material="MatPlane" rgba="0.8 0.9 0.8 1"/>
    <light pos="0 0 1.3" dir="0 0 -1" directional="true" cutoff="100" exponent="1" diffuse="1 1 1" specular="0.1 0.1 0.1"/>
    <body name="torso" pos="0 0 1.25" gravcomp="0">
      <joint name="rootx" pos="0 0 -1.25" axis="1 0 0" limited="false" type="slide" armature="0" damping="0"/>
      <joint name="rootz" pos="0 0 -1.25" axis="0 0 1" limited="false" type="slide" ref="1.25" armature="0" damping="0"/>
      <joint name="rooty" pos="0 0 0" axis="0 1 0" limited="false" armature="0" damping="0"/>
      <geom name="torso_geom" size="0.05 0.2" type="capsule" friction="0.9 0.1 0.1"/>
      <camera name="track" pos="0 -3 -0.25" quat="0.707107 0.707107 0 0" mode="trackcom"/>
      <body name="thigh" pos="0 0 -0.2" gravcomp="0">
        <joint name="thigh_joint" pos="0 0 0" axis="0 -1 0" range="-2.61799 0"/>
        <geom name="thigh_geom" size="0.05 0.225" pos="0 0 -0.225" type="capsule" friction="0.9 0.1 0.1"/>
        <body name="leg" pos="0 0 -0.7" gravcomp="0">
          <joint name="leg_joint" pos="0 0 0.25" axis="0 -1 0" range="-2.61799 0"/>
          <geom name="leg_geom" size="0.04 0.25" type="capsule" friction="0.9 0.1 0.1"/>
          <body name="foot" pos="0.2 0 -0.35" gravcomp="0">
            <joint name="foot_joint" pos="-0.2 0 0.1" axis="0 -1 0" range="-0.785398 0.785398"/>
            <geom name="foot_geom" size="0.06 0.1" pos="-0.1 0 0.1" quat="0.707107 0 -0.707107 0" type="capsule" friction="0.9 0.1 0.1"/>
          </body>
        </body>
      </body>
      <body name="thigh_left" pos="0 0 -0.2" gravcomp="0">
        <joint name="thigh_left_joint" pos="0 0 0" axis="0 -1 0" range="-2.61799 0"/>
        <geom name="thigh_left_geom" size="0.05 0.225" pos="0 0 -0.225" type="capsule" friction="0.9 0.1 0.1" rgba="0.7 0.3 0.6 1"/>
        <body name="leg_left" pos="0 0 -0.7" gravcomp="0">
          <joint name="leg_left_joint" pos="0 0 0.25" axis="0 -1 0" range="-2.61799 0"/>
          <geom name="leg_left_geom" size="0.04 0.25" type="capsule" friction="0.9 0.1 0.1" rgba="0.7 0.3 0.6 1"/>
          <body name="foot_left" pos="0.2 0 -0.35" gravcomp="0">
            <joint name="foot_left_joint" pos="-0.2 0 0.1" axis="0 -1 0" range="-0.785398 0.785398"/>
            <geom name="foot_left_geom" size="0.06 0.1" pos="-0.1 0 0.1" quat="0.707107 0 -0.707107 0" type="capsule" friction="1.9 0.1 0.1" rgba="0.7 0.3 0.6 1"/>
          </body>
        </body>
      </body>
    </body>
  </worldbody>
  <actuator>
    <general joint="thigh_joint" ctrlrange="-1 1" gear="100 0 0 0 0 0" actdim="0"/>
    <general joint="leg_joint" ctrlrange="-1 1" gear="100 0 0 0 0 0" actdim="0"/>
    <general joint="foot_joint" ctrlrange="-1 1" gear="100 0 0 0 0 0" actdim="0"/>
    <general joint="thigh_left_joint" ctrlrange="-1 1" gear="100 0 0 0 0 0" actdim="0"/>
    <general joint="leg_left_joint" ctrlrange="-1 1" gear="100 0 0 0 0 0" actdim="0"/>
    <general joint="foot_left_joint" ctrlrange="-1 1" gear="100 0 0 0 0 0" actdim="0"/>
  </actuator>
</mujoco>
python reinforcement-learning robotics openai-gym mujoco
2个回答
4
投票

我是体育馆开发商

此问题将在 v29 上修复

pip install gymnasium>=0.29

如果您需要使用旧版本,我们建议安装兼容的 MuJoCo 版本:

pip install mujoco==2.3.3

注意:不要在OP中使用MuJoCo模型,它的行为与原始模型不同。


2
投票

请参阅此问题及其中的链接。

© www.soinside.com 2019 - 2024. All rights reserved.