Class AddRenderObservation<TObs, TAct>
Puts the rendered frame into every observation, as Gymnasium's AddRenderObservation does: with
render_only the frame replaces the observation, otherwise it joins it in a dict (beside a Dict's keys,
or as {obs_key: obs, render_key: frame}).
public class AddRenderObservation<TObs, TAct> : TransformObservation<object?, TObs, TAct>, IDynamicAttributes, IWrapper, IEnv, IDisposable, IRecordConstructorArgs
Type Parameters
TObsThe env's observation type.
TActThe action type, passed through.
- Inheritance
-
ObservationWrapper<object, TObs, TAct>TransformObservation<object, TObs, TAct>AddRenderObservation<TObs, TAct>
- Implements
- Inherited Members
- Extension Methods
Remarks
The constructor resets the env and renders once to learn the frame's shape, as Gymnasium's does: the reset draws
from the env's generator (seeding it from entropy if it was never seeded), so seed the next reset to reproduce a
run. Each observation renders again; the env's render mode must give arrays (rgb_array, depth_array).
The observation type depends on render_only at run time (an array, or a dict), so observations are
objects.
Reference: gymnasium/wrappers/transform_observation.py.
Constructors
AddRenderObservation(Env<TObs, TAct>, AddRenderObservationOptions)
Builds the instance from its options record: the properties set, the constructor's defaults for the rest.
public AddRenderObservation(Env<TObs, TAct> env, AddRenderObservationOptions options)
Parameters
envEnv<TObs, TAct>The env to wrap.
optionsAddRenderObservationOptionsThe options.
Exceptions
- ArgumentNullException
Thrown when
optionsis null.
AddRenderObservation(Env<TObs, TAct>, bool, string, string)
Wraps env.
public AddRenderObservation(Env<TObs, TAct> env, bool renderOnly = true, string renderKey = "pixels", string obsKey = "state")
Parameters
envEnv<TObs, TAct>The env; its render mode must be set and not
human.renderOnlyboolWhether the frame replaces the observation (the default) instead of joining it in a dict.
renderKeystringThe frame's key in the dict.
obsKeystringThe observation's key when the env's space is no
Dict.
Exceptions
- ValueError
Thrown when the render mode is unset or
human, orrenderKeyalready is a key of the env'sDictspace, with Gymnasium's messages.- TypeError
Thrown when rendering gives no array (Gymnasium's message), or
envis null.
Properties
ObsKey
The observation's key beside the frame (obs_key).
public string ObsKey { get; }
Property Value
RenderKey
The frame's key (render_key).
public string RenderKey { get; }
Property Value
RenderOnly
Whether the frame replaces the observation (render_only).
public bool RenderOnly { get; }