Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecordEpisode() environment wrapper for 'TwoRobotPickCube-v1' task #776

Open
seungbinjoo opened this issue Dec 27, 2024 · 1 comment
Open

Comments

@seungbinjoo
Copy link

Hi, I'm a user looking to use ManiSkill for RL for bimanual manipulation. I'm just testing recording episodes when executing a random policy for the 'TwoRobotPickCube-v1' task like so (following the quickstart notebook):

# to make it look a little more realistic, we will enable shadows which make the default lighting cast shadows
env = gym.make("TwoRobotPickCube-v1", num_envs=4, render_mode="rgb_array", enable_shadow=True)
env = RecordEpisode(
    env,
    "./videos", # the directory to save replay videos and trajectories to
    # on GPU sim we record intervals, not by single episodes as there are multiple envs
    # each 100 steps a new video is saved
    max_steps_per_video=100
)

# step through the environment with random actions
obs, _ = env.reset()
for i in range(100):
    action = env.action_space.sample()
    obs, reward, terminated, truncated, info = env.step(action)
    # env.render_human() # will render with a window if possible
env.close()
from IPython.display import Video
Video("./videos/0.mp4", embed=True, width=640) # Watch the replay

But I run into the following issue:

Traceback (most recent call last):
  File "/athenahomes/joo/4yp/rma4rma/troubleshooting/test_mani_skill3.py", line 61, in <module>
    obs, _ = env.reset()
             ^^^^^^^^^^^
  File "/users/joo/miniconda3/envs/4YP/lib/python3.11/site-packages/mani_skill/utils/wrappers/record.py", line 367, in reset
    action=common.to_numpy(common.batch(action.repeat(self.num_envs, 0))),
                                        ^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'repeat'
@StoneT2000
Copy link
Member

hm this is due to the default dictionary action space.

I've seen multiple issues around the fact the action space typically needs to be flattened before use for most algorithms / workflows that I am considering making flat the default.

The dictionary action space was originally designed to support multi agent RL setups.

For a workaround for now you can first apply the FlattenActionSpace wrapper: https://maniskill.readthedocs.io/en/latest/user_guide/wrappers/flatten.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants