serl icon indicating copy to clipboard operation
serl copied to clipboard

Problem about visualizing mujoco simulation when running:test_gym_env_human.py

Open parzivar opened this issue 1 year ago • 11 comments

when i run: python franka_sim/franka_sim/test/test_gym_env_human.py image I am very interested in SERL, but i dont known how to solve this problem. ubuntu20.04, Nvidia 565, cuda12.6, I would be very grateful if you could reply me

parzivar avatar Nov 11 '24 12:11 parzivar

Uploading image.png…

parzivar avatar Nov 11 '24 13:11 parzivar

Hi @parzivar, I get the exact same Error running it with Ubuntu 22.04 and Cuda 12.1. Hope someone replies as i am looking forward to reproduce their Simulation.

claudio-dg avatar Nov 27 '24 13:11 claudio-dg

Also encountered the same problem with Ubuntu 22.04 + CUDA 12.6. Looking for the reply orz !!!

CeyaoZhang avatar Dec 10 '24 09:12 CeyaoZhang

Check if this issue is relevant to:

  • https://github.com/Farama-Foundation/Metaworld/issues/509
  • https://github.com/google-deepmind/mujoco/issues/991

Referred to here, on ubuntu setup, try adding multiprocessing.set_start_method('spawn') right after the import

youliangtan avatar Dec 10 '24 09:12 youliangtan

No, this error has nothing to do with operations like AsynVectorEnv or multiprocessing. The default code only concerns with one Env.


I also find that even run the following one line code

from franka_sim import envs
env = envs.PandaPickCubeGymEnv(action_scale=(0.1, 1))

will cause

Traceback (most recent call last): File "/home/admin01/Projects/serl/franka_sim/franka_sim/test/test_gym_env_human.py", line 9, in env = envs.PandaPickCubeGymEnv(action_scale=(0.1, 1)) File "/home/admin01/Projects/serl/franka_sim/franka_sim/envs/panda_pick_gym_env.py", line 148, in init self._viewer.render(self.render_mode) File "/home/admin01/anaconda3/envs/serl/lib/python3.10/site-packages/gymnasium/envs/mujoco/mujoco_rendering.py", line 706, in render viewer = self._get_viewer(render_mode=render_mode) File "/home/admin01/anaconda3/envs/serl/lib/python3.10/site-packages/gymnasium/envs/mujoco/mujoco_rendering.py", line 730, in _get_viewer self.viewer = OffScreenViewer( File "/home/admin01/anaconda3/envs/serl/lib/python3.10/site-packages/gymnasium/envs/mujoco/mujoco_rendering.py", line 155, in init super().init(model, data, width, height, max_geom, visual_options) File "/home/admin01/anaconda3/envs/serl/lib/python3.10/site-packages/gymnasium/envs/mujoco/mujoco_rendering.py", line 53, in init self.viewport = mujoco.MjrRect(0, 0, width, height) TypeError: init(): incompatible constructor arguments. The following argument types are supported: 1. mujoco._render.MjrRect(left: int, bottom: int, width: int, height: int)

Invoked with: 0, 0, None, None

After checking the code in panda_pick_gym_env.py, I doubt this result due to the missing inputs height and width in https://github.com/rail-berkeley/serl/blob/2f9f315b560790505b46a217c1653e7f2199566a/franka_sim/franka_sim/envs/panda_pick_gym_env.py#L144-L147


Looking forward your double check the sim code orz !!

CeyaoZhang avatar Dec 10 '24 10:12 CeyaoZhang

After setting

 self._viewer = MujocoRenderer(
            self.model,
            self.data,
            width=3,
            height=4
        )

the code works.

CeyaoZhang avatar Dec 10 '24 10:12 CeyaoZhang

Hi, @parzivar @claudio-dg , Can you check if this works for you too? And I do suggest @parzivar change this issus's title. I missed this issue several times because the original title was about "UserWarning", which was not a really problem.

CeyaoZhang avatar Dec 10 '24 11:12 CeyaoZhang

Thank you for your questions, and I sincerely thank @CeyaoZhang and @youliangtan for answering this question. I have solved this problem by modifying the dependent version of the simulation environment, refer to https://github.com/rail-berkeley/serl/pull/76/commits/8ab8541567c80ca69a4503db07866783b7a00e3a Finally, I made a fr3 robot teleoperation of an Xbox controller based on SERL. Interested friends can learn more about https://github.com/parzivar/Franka-Research-3-Robot-Simulation-with-Xbox-Controller-Integration-in-MuJoCo

parzivar avatar Dec 10 '24 12:12 parzivar

@parzivar I check your method and it works. I think this issue lies in the different gymnasium versions.

CeyaoZhang avatar Dec 10 '24 12:12 CeyaoZhang

@CeyaoZhang I have another question about SERL:https://github.com/rail-berkeley/serl/issues/47 If you have encountered and solved it, I hope you can give me some guidance, thank you

parzivar avatar Dec 10 '24 12:12 parzivar

I don't figure out your problem. You may give me more details and we can discuss in #47.

CeyaoZhang avatar Dec 12 '24 07:12 CeyaoZhang