Generic Quantity Observer¶
Implementation of Mahony filter block compatible with gym_jiminy reinforcement learning pipeline environment design.
- gym_jiminy.common.blocks.quantity_observer.get_space(data)[source]¶
Infer space from a given value.
Warning
Beware that space inference is lossly. Firstly, one cannot discriminate between gym.spaces.Box and other non-container spaces, e.g. gym.spaces.Discrete or gym.spaces.MultiBinary. Because of this limitation, it is assumed that all np.ndarray data has been sampled by a gym.spaces.Box space. Secondly, it is impossible to determine the bounds of the space, so it is assumed to be unbounded.
- class gym_jiminy.common.blocks.quantity_observer.QuantityObserver(name, env, quantity, *, update_ratio=1, **kwargs)[source]¶
Bases:
BaseObserverBlock
[ValueT
,None
,BaseObs
,BaseAct
]Add a given pre-defined quantity to the observation of the environment.
Warning
The observation space of a quantity must be invariant. Yet, nothing prevent the shape of the quantity to change dynamically. As a result, it is up to user to make sure that does not occur in practice, otherwise it will raise an exception.
- Parameters:
name (str) – Name of the block.
env (InterfaceJiminyEnv[BaseObs, BaseAct]) – Environment to connect with.
quantity (Type[InterfaceQuantity[ValueT]]) – Type of the quantity.
update_ratio (int) – Ratio between the update period of the observer and the one of the subsequent observer. -1 to match the simulation timestep of the environment. Optional: 1 by default.
kwargs (Any) – Additional arguments that will be forwarded to the constructor of the quantity.