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

有关self._render_context_offscreen的问题 #37

Open
liaojiaxin97 opened this issue Nov 22, 2024 · 3 comments
Open

有关self._render_context_offscreen的问题 #37

liaojiaxin97 opened this issue Nov 22, 2024 · 3 comments

Comments

@liaojiaxin97
Copy link

当我正常安装依赖后,运行pipeline中的dp_robomimic.py,出现了几个问题:
1.yaml文件中的dataset_path:的路径使用相对路径会出现该问题OSError: Unable to synchronously open file,改为绝对路径后可以加载路径(有更好的解决办法吗?)
2.再次运行后出现以下错误
Error executing job with overrides: []
Traceback (most recent call last):
File "/home/pxw/QDU/Neo/Project/CleanDiffuser-main/CleanDiffuser-main/pipelines/dp_robomimic.py", line 272, in pipeline
metrics.update(inference(args, envs, dataset, agent, logger))
File "/home/pxw/QDU/Neo/Project/CleanDiffuser-main/CleanDiffuser-main/pipelines/dp_robomimic.py", line 134, in inference
obs, reward, done, info = envs.step(action)
File "/home/pxw/anaconda3/envs/cdiff_v3/lib/python3.9/site-packages/gym/vector/vector_env.py", line 112, in step
return self.step_wait()
File "/home/pxw/anaconda3/envs/cdiff_v3/lib/python3.9/site-packages/gym/vector/sync_vector_env.py", line 138, in step_wait
observation, self._rewards[i], self._dones[i], info = env.step(action)
File "/home/pxw/QDU/Neo/Project/CleanDiffuser-main/CleanDiffuser-main/cleandiffuser/env/wrapper.py", line 110, in step
observation, reward, done, info = super().step(act)
File "/home/pxw/anaconda3/envs/cdiff_v3/lib/python3.9/site-packages/gym/core.py", line 280, in step
return self.env.step(action)
File "/home/pxw/QDU/Neo/Project/CleanDiffuser-main/CleanDiffuser-main/cleandiffuser/env/wrapper.py", line 248, in step
frame = self.env.render(
File "/home/pxw/QDU/Neo/Project/CleanDiffuser-main/CleanDiffuser-main/cleandiffuser/env/robomimic/robomimic_lowdim_wrapper.py", line 93, in render
return self.env.render(mode=mode,
File "/home/pxw/QDU/Neo/Project/CleanDiffuser-main/robomimic-master/robomimic/envs/env_robosuite.py", line 196, in render
im = self.env.sim.render(height=height, width=width, camera_name=camera_name)
File "/home/pxw/QDU/Neo/Project/CleanDiffuser-main/robosuite/robosuite/utils/binding_utils.py", line 1126, in render
assert self._render_context_offscreen is not None
AssertionError

我找到该文件binding_utils.py,debug发现self._render_context_offscreen为None,并且没有发现能给self._render_context_offscreen赋值的地方,请问该如何修改才能正常运行?
……
if camera_name is None:
camera_id = None
else:
camera_id = self.model.camera_name2id(camera_name)

    assert mode == "offscreen", "only offscreen supported for now"
    assert **self._render_context_offscreen is not None**
    with _MjSim_render_lock:
        self._render_context_offscreen.render(
            width=width, height=height, camera_id=camera_id, segmentation=segmentation
        )
        return self._render_context_offscreen.read_pixels(width, height, depth=depth, segmentation=segmentation)

……

@pickxiguapi
Copy link
Contributor

Hi, unfortunately, the source of this problem is the robomimic environment, can you test your robomimic environment with an simple example?

@liaojiaxin97
Copy link
Author

liaojiaxin97 commented Nov 26, 2024

Thanks for your reply, I can run normally by setting save_video:false.
This is the simple solution, I try to find the root of the error, but do not know how to solve it.Strangely, I can normally use save_video in push_t,kitchen and mujoco env

Here is a test example I can provide.I can run the following code and render the diagram.
When the following code is run, self._render_context_offscreen is not empty and is an object type

import argparse
import os

import mujoco

import robosuite as suite
from robosuite.utils import OpenCVRenderer
from robosuite.utils.binding_utils import MjRenderContext, MjSim

if __name__ == "__main__":

    arena_file = os.path.join(suite.models.assets_root, "arenas/pegs_arena.xml")

    parser = argparse.ArgumentParser()
    parser.add_argument("--filepath", type=str, default=arena_file)
    args = parser.parse_args()

    model = mujoco.MjModel.from_xml_path(args.filepath)
    sim = MjSim(model)
    render_context = MjRenderContext(sim)
    sim.add_render_context(render_context)
    viewer = OpenCVRenderer(sim)

    print("Press ESC to exit...")
    while True:
        sim.step()
        viewer.render()

@pickxiguapi
Copy link
Contributor

Thanks for the simple solution, I think it's an important reference for subsequent users in the short term, I'll reproduce your bug report and find a solution as soon as possible.

@pickxiguapi pickxiguapi pinned this issue Nov 26, 2024
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