ASE icon indicating copy to clipboard operation
ASE copied to clipboard

Initial state distribution bug when resetting the environment

Open jacktheripper19 opened this issue 3 years ago • 4 comments

Hello, thank you for the amazing work. I noticed that when resetting the environment, the initial state is different each time even if stateinit is set to Default or Start. When looking deep into the code, it seems that the initial state is different because the positions of the rigid bodies are kept the same as before the reset. In the function _reset_env_tensors(self, env_ids) in humanoid.py, only root state and dof states are being reset. Appearently, the current version of IsaacGym does not allow for setting positions for rigid bodies according to the doc.

jacktheripper19 avatar Nov 20 '22 09:11 jacktheripper19

Hi Jack,

I figured out the same thing. I think this issue can be fixed by adding these lines in the reset.

player.env.task.gym.simulate(player.env.task.sim) player.env.task.gym.fetch_results(player.env.task.sim, True)

This way we are always getting the new rigid_body values.

idigitopia avatar Jan 10 '23 22:01 idigitopia

I think that this causes another issue since gym.simulate will step all the environments. So maybe it solves the problem for environments that are to be reset, but the other ones that are not done will skip the next state that results from the last action. So for undone environments, the transition will be like: instead of state_t, action_t => reset done environments => state_t+1 it becomes: state_t, action_t => reset done environments and step the simulation => state_t+2 This probably messes up with the dynamics.

anonymous-pusher avatar Jan 11 '23 07:01 anonymous-pusher

Yes, unfortunately this causes issues where sometimes the simulation will be advanced by two timesteps instead of one. This will probably hurt the training process by introducing some randomness into the dynamics. I'm not sure what a good solution is in this case with IsaacGym. I'm open to suggestions!

xbpeng avatar Jan 13 '23 05:01 xbpeng

Hi guys, I fixed this bug, plz see my PR!

liangpan99 avatar Aug 09 '23 15:08 liangpan99