elicassion / sugarl

Code for NeurIPS 2023 paper "Active Vision Reinforcement Learning with Limited Visual Observability"
https://elicassion.github.io/sugarl/sugarl.html
49 stars 2 forks source link

Some atttibute errors #4

Open zichunxx opened 1 week ago

zichunxx commented 1 week ago

Hi! @elicassion

I met some errors when running through the sanity check with robosuite_test.sh.

First, for the code snippet in active_gym, the mentioned lines should be replaced with

        self.init_fov_pos = env.unwrapped.activeview_camera_init_pos
        self.init_fov_quat = env.unwrapped.activeview_camera_init_quat

, otherwise attribute error will be triggered, like

AttributeError: 'RecordWrapper' object has no attribute 'activeview_camera_init_pos'

Second, there is no keyword final_observation when running to this line:

https://github.com/elicassion/sugarl/blob/77a7fb10c997e47b34e6802cea0501d2b87505f1/agent/drqv2_rs_sugarl_sv.py#L587

I'm not sure the above errors are triggered by unmatched gymnasium version. I found no specific version instruction in the .yaml file.

Besides, dmc_test.sh also can't run normally with some attribute errors.

Please remind me if I'm missing something.

Thanks for taking the time to check this issue.

elicassion commented 1 week ago

Hi @zichunxx

Thanks for catching the issue. I think the recent gymnasium change may cause both problems. I updated the requirement list for this repo https://github.com/elicassion/sugarl/commit/e94308aada4daedb43e0d36d1ff895908c48d880 and the active-gym repo https://github.com/elicassion/active-gym/commit/ba914bbb08e7abde2dbb155dbad67a3285751a5d. gymnasium>=0.28.1,<1.0.0 should work.

  1. The attributes are directly introduced to env. I think the magic is done by the base wrapper and the decorator. My understanding is that the base wrapper also inherits gym.Env so it does not need unwrapped. The change in gymnasium's environment registration may affect this.

  2. final_observation is unfortunately removed from gymnasium 1.0, please refer to their change log or the paragraphs I copied from the log. gymnasium>=0.28 should work.

To increase the efficiency of vector environments, autoreset is a common feature that allows sub-environments to reset without requiring all sub-environments to finish before resetting them all. Previously in Gym and Gymnasium, auto-resetting was done on the same step as the environment episode ends, such that the final observation and info would be stored in the step's info, i.e., info["final_observation"] and info[“final_info”] and standard obs and info containing the sub-environment's reset observation and info. Thus, accurately sampling observations from a vector environment required the following code (note the need to extract the infos["next_obs"][j] if the sub-environment was terminated or truncated). Additionally, for on-policy algorithms that use rollout would require an additional forward pass to compute the correct next observation (this is often not done as an optimization assuming that environments only terminate, not truncate).

However, over time, the development team has recognized the inefficiency of this approach (primarily due to the extensive use of a Python dictionary) and the annoyance of having to extract the final observation to train agents correctly, for example. Therefore, in v1.0.0, we are modifying autoreset to align with specialized vector-only projects like EnvPool and SampleFactory where the sub-environment's doesn't reset until the next step.

Let me know if it still does not work. Happy to help.

zichunxx commented 1 week ago

Thank you so much for your kind help!

Now, the sanity check can be finished successfully after downgrading the gymnasium version.

Besides, I found that the numpy version should also be declared to avoid minor errors. numpy 1.X fits this repo.