Metaworld
Metaworld copied to clipboard
Error when setting rand_init to False in some environments
In the V2 push-wall, pick-place-wall, push-back, and shelf-place environments, setting rand_init
to False and then resetting the environment would lead to the following error when calling step()
:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/beegfs/home/zchuning/metaworld/metaworld/envs/mujoco/mujoco_env.py", line 25, in inner
return func(*args, **kwargs)
File "/mnt/beegfs/home/zchuning/metaworld/metaworld/envs/mujoco/sawyer_xyz/v2/sawyer_push_wall_v2.py", line 79, in evaluate_state
) = self.compute_reward(action, obs)
File "/mnt/beegfs/home/zchuning/metaworld/metaworld/envs/mujoco/sawyer_xyz/v2/sawyer_push_wall_v2.py", line 157, in compute_reward
object_grasped = self._gripper_caging_reward(
File "/mnt/beegfs/home/zchuning/metaworld/metaworld/envs/mujoco/sawyer_xyz/sawyer_xyz_env.py", line 572, in _gripper_caging_reward
caging_xz_margin = np.linalg.norm(self.obj_init_pos[xz] - self.init_tcp[xz])
TypeError: list indices must be integers or slices, not list
This is because the reset()
function of these environments sets self.obj_init_pos
to self.adjust_initObjPos(self.init_config['obj_init_pos'])
when self.random_init
is False (e.g. line 112 in sawyer_push_wall_v2.py
). However, self.adjust_initObjPos()
returns a python list instead of a numpy array. So line 572 of swyer_xyz_env.py
triggers an error by accessing a python list with a list of indices.
A simple fix is to wrap a np.array()
around self.adjust_initObjPos(self.init_config['obj_init_pos'])
, similar to how some other environments (e.g. Push V2) handle calls to fix_extreme_obs_pos()
. But there might be a more systematic way to fix this, hence the github issue instead of a pull request.