Skip to content

Rendering with render_mode="rgb_array" does not work properly when rendering multiple envs #448

Open
@ManfredStoiber

Description

@ManfredStoiber

When using multiple environments, a strange behavior occurs during rendering in mode "rgb_array":

  1. When calling the .render() function on one environment, it is displayed correctly
  2. When calling it on a second environment, it also works as intended
  3. When rendering the first env again, the objects have weird shapes (see output below)

Here is a minimum example for reproduction:

import metaworld
import random
import matplotlib.pyplot as plt

mt50 = metaworld.MT50() # Construct the benchmark, sampling tasks

training_envs = []
for name, env_cls in mt50.train_classes.items():
  env = env_cls(render_mode="rgb_array")
  task = random.choice([task for task in mt50.train_tasks
                        if task.env_name == name])
  env.set_task(task)
  env.camera_name="corner3"
  training_envs.append(env)

# 1. works (image 1)
plt.imshow(training_envs[34].render()) # pick-place-v2
plt.show()

# 2. works (image 2)
plt.imshow(training_envs[1].render()) # basketball-v2
plt.show()

# 3. does not work anymore (image 3)
plt.imshow(training_envs[34].render()) # pick-place-v2
plt.show()

Output:
image
image
image

Also the images are upside down when using different cameras than default, but that's also the case when using only one environment.

I noticed that the problem does not occur with every combination of environments, for example "pick-place-v2" and "reach-v2" work together, whereas "pick-place-v2" and "basketball-v2" don't. Maybe because the former combination use the same objects and the latter use different objects?

Thank you very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions