gym_utils
GymObservable
Simple class interface for observable objects. These objects should implement a way to grab observations, (get_obs()), and should define an observation space that is created when load_observation_space() is called
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs
|
dict, does nothing, used to sink any extraneous arguments during initialization |
{}
|
Source code in omnigibson/utils/gym_utils.py
get_obs(**kwargs)
abstractmethod
Get observations for the object. Note that the shape / nested structure should match that of @self.observation_space!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs
|
dict
|
Any keyword args necessary for grabbing observations |
{}
|
Returns:
Type | Description |
---|---|
2 - tuple
|
dict: Keyword-mapped observations mapping observation names to nested observations dict: Additional information about the observations |
Source code in omnigibson/utils/gym_utils.py
load_observation_space()
Load the observation space internally, and also return this value
Returns:
Type | Description |
---|---|
Dict
|
Loaded observation space for this object |
Source code in omnigibson/utils/gym_utils.py
maxdim(space)
Helper function to get the maximum dimension of a gym space
Parameters:
Name | Type | Description | Default |
---|---|---|---|
space
|
Space
|
Gym space to get the maximum dimension of |
required |
Returns:
Type | Description |
---|---|
int
|
Maximum dimension of the gym space |
Source code in omnigibson/utils/gym_utils.py
recursively_generate_compatible_dict(dic)
Helper function to recursively iterate through dictionary and cast values to necessary types to be compatible with Gym spaces -- in particular, the Sequence and Tuple types for th.tensor values in @dic
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dic
|
dict or Dict
|
(Potentially nested) dictionary to convert into a flattened dictionary |
required |
Returns:
Type | Description |
---|---|
dict
|
Gym-compatible version of @dic |
Source code in omnigibson/utils/gym_utils.py
recursively_generate_flat_dict(dic, prefix=None)
Helper function to recursively iterate through dictionary / gym.spaces.Dict @dic and flatten any nested elements, such that the result is a flat dictionary mapping keys to values
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dic
|
dict or Dict
|
(Potentially nested) dictionary to convert into a flattened dictionary |
required |
prefix
|
None or str
|
Prefix to append to the beginning of all strings in the flattened dictionary. None results in no prefix being applied |
None
|
Returns:
Type | Description |
---|---|
dict
|
Flattened version of @dic |