google-deepmind / google-deepmind/rgb_stacking
Setting environment seed
- Dominant language
- Python
- Stars
- 132
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I was just wondering if I am missing an obvious way to set an environment seed so that the arm and rgb objects are initialised in a set position and with the same rgb object combinations / deformations for a given seed?
If not, I ve modified a local version of the code in the following ways that seems to have the desired effect - does this look about right or might this not replicate something?:
1. To set the seed for the arm position I pass an np.random.RandomState(seed) object instance as an additional argument (i.e random_state=) when initialising the _base_env Environment object in subtask_env_builder.py in the lines [here](https://github.com/deepmind/dm_robotics/blob/cfc1653336a44ff3407dd28d4cb770cb3017458e/py/moma/subtask_env_builder.py#L83-L84). This seems to work to get the arm to always start in the same place for a given seed.
2. To fix the position of the rgb objects and the type / deformation of the rgb objects I needed to make two changes:
- I needed to add a sort (RGB_OBJECTS_TRAIN_SET.sort()) below these [lines](https://github.com/deepmind/dm_robotics/blob/cfc1653336a44ff3407dd28d4cb770cb3017458e/py/manipulation/props/rgb_objects/rgb_object.py#L116-L118) where I think the valid object combinations are initialised. Without this the order of the valid object deformations seems to be somewhat random (I think I m probably missing setting another seed somewhere - but this seems to work as a patch).
- Then I set np.random.seed(seed) (using the same random state as used in 1.) at some point before these [lines](https://github.com/deepmind/dm_robotics/blob/cfc1653336a44ff3407dd28d4cb770cb3017458e/py/manipulation/props/rgb_objects/rgb_object.py#L200-L204) where the specific objects seem to be chosen.
3. One thing that is still slightly confusing me is how the above seeds when the environment is initialised feed through to the env.reset()?
Any thoughts on whether this should work / makes sense / if there is an easier way to do it would be really appreciated!
Contributor guide
Assessment
This issue has not been assessed yet.