Closed yeshenpy closed 3 months ago
What do you mean if only the robot arm moves, not the gripper? When I run the code I see the whole robot moving. Note that if yhou have parallel environments there isn't a recommended way to visualize it other than to record videos using the RecordEpisode wrapper (which will record videos in parallel, e.g. if you run the baseline PPO code the evaluation videos are always multiple videos together).
For environment parallelization you should not use any wrappers/async vector envs from gymnasium or other libraries if you want to use GPU simulation. (We still support asyncvectorenv for CPU simulation). To use GPU simulation setting num_envs > 1 will automatically turn it on when using gym.make. To make it look like AsyncVectorEnv, you should use the ManiSkillVectorEnv wrapper which wraps the env created by gym.make into a object that is an instance of gymnasium VectorEnv.
Relevant imports:
from mani_skill.utils.wrappers.record import RecordEpisode
from mani_skill.vector.wrappers.gymnasium import ManiSkillVectorEnv
I highly recommend looking at the PPO code https://github.com/haosulab/ManiSkill/blob/main/examples/baselines/ppo/ppo.py to see how it is used for RL workflows. I will be adding documentation about how to do certain types of ML workflows with ManiSkill soon.
Oh and regarding environment reset, by default the environment created by gym.make does not come with auto reset, so it only resets if you call env.reset. If you wrap ManiSkillVectorEnv around the environment, then you get auto reset (you can also turn it off). There is also an argument for ignoring terminations (terminated = True if environment is success or fail state). If you ignore terminations then resets always happen whenever the environment is truncated (e.g. reaching the max episode steps). If you don't ignore terminations then there is partial resets, where at each step not all environments reset at the same time (which can sometimes speed up RL training).
See https://github.com/haosulab/ManiSkill/blob/main/mani_skill/vector/wrappers/gymnasium.py for the code.
Hi @yeshenpy is this still an issue?
Amazing work! However, I encountered some problems while using it.
The first problem is, if I open more than one environment, i.e. num_env > 1, is it unreasonable for visualization? The code below can reproduce this issue; the robotic arm does not move in the visualization window, only the gripper moves.
The second problem is that Maniskill3 directly supports multi-environment parallelization, but how does it handle resets in this context? If I open multiple environments and one of them ends (succeeds early), will it reset immediately, or will it continue executing actions after success? Both approaches can ensure that the lengths of the collected trajectories are equal. Is there still a need to use
gym.vector.AsyncVectorEnv
for re-encapsulation? Since I am training RL, the details of parallelization are very important.Thanks for your valuable time.