Observation Frame Stacking

TODO: Write documentation.

class gym_jiminy.common.wrappers.observation_stack.StackedJiminyEnv(env, *, num_stack, nested_filter_keys=None, skip_frames_ratio=-1)[source]

Bases: BasePipelineWrapper[NestedObsT, ActT, NestedObsT, ActT], Generic[NestedObsT, ActT]

Partially stack observations in a rolling manner.

This wrapper combines and extends OpenAI Gym wrappers FrameStack and FilteredJiminyEnv to support nested filter keys.

It adds one extra dimension to all the leaves of the original observation spaces that must be stacked. In such a case, the first dimension corresponds to the individual timesteps (from oldest 0 to latest -1).

Note

The standard container spaces gym.spaces.Dict and gym.spaces.Tuple are both supported. All the stacked leaf spaces must have type gym.spaces.Box.

Note

The latest frame of the stacked leaf observations corresponds to their latest respective values no matter what. It will frozen when shifted to the left.

Parameters:
  • env (InterfaceJiminyEnv[NestedObsT, ActT]) – Environment to wrap.

  • num_stack (int) – Number of observation frames to keep stacked.

  • nested_filter_keys (Sequence[Sequence[str | int] | str | int] | None) – List of nested observation paths to stack. If a nested path is not associated with a leaf, then every leaves starting from this root path will be stacked. Optional: All leaves will be stacked by default.

  • skip_frames_ratio (int) – Number of observation refresh to skip between each update of the stacked leaf values. -1 to update only once per environment step. Optional: -1 by default.

refresh_observation(measurement)[source]

Compute observed features based on the current simulation state and lower-level measure.

Parameters:

measurement (EngineObsType) – Low-level measure from the environment to process to get higher-level observation.

Return type:

None

compute_command(action, command)[source]

Compute the motors efforts to apply on the robot.

It simply forwards the command computed by the wrapped environment without any processing.

Parameters:
  • action (ActT) – High-level target to achieve by means of the command.

  • command (ndarray) – Lower-level command to updated in-place.

Return type:

None