SensorNoise

class fluidgym.wrappers.sensor_noise.SensorNoise(env: FluidEnvLike, sigma: float, seed: int)[source]

Bases: FluidWrapper

A wrapper that adds Gaussian noise to the actions.

It adds Gaussian noise with standard deviation sigma to the actions.

Parameters:
  • env (FluidEnvLike) – The environment to wrap.

  • sigma (float) – The standard deviation of the Gaussian noise.

  • seed (int) – The random seed for the noise generator.

reset(seed: int | None = None, randomize: bool | None = None) tuple[dict[str, Tensor], dict[str, Tensor]][source]

Resets the environment to an initial internal state, returning an initial observation and info.

Parameters:
  • seed (int | None) – The seed to use for random number generation. If None, the current seed is used.

  • randomize (bool | None) – Whether to randomize the initial state. If None, the default behavior is used.

Returns:

A tuple containing the initial observation and an info dictionary.

Return type:

tuple[dict[str, torch.Tensor], dict[str, torch.Tensor]]

step(action: Tensor) tuple[dict[str, Tensor], Tensor, bool, bool, dict[str, Tensor]][source]

Run one timestep of the environment’s dynamics using the agent actions.

When the end of an episode is reached (terminated or truncated), it is necessary to call reset() to reset this environment’s state for the next episode.

Parameters:

action (torch.Tensor) – The action to take.

Returns:

  • tuple[

  • dict[str, torch.Tensor], torch.Tensor, bool, bool, dict[str, torch.Tensor]] – A tuple containing the observation, reward, terminated flag, truncated flag, and info dictionary.