Callbacks

This module introduces predefined callbacks for the GEM environment.

class gym_electric_motor.callbacks.RampingLimitMargin(initial_limit_margin=(-0.1, 0.1), maximum_limit_margin=(-1, 1), step_size=0.1, update_time='episode', update_freq=10)[source]

Callback used to adapt the limit margin of a reference generator during runtime.

Supports all SubepisodedReferenceGenerator and SwitchedReferenceGenerator with only SubepisodedReferenceGenerator as sub generators.

Parameters:
  • initial_limit_margin (tuple(floats)) – The initial limit margin which gets updated by AdaptiveLimitMargin until it reaches maximum_limit_margin

  • maximum_limit_margin (tuple(floats)) – The maximum limit margin. This will be the limit margin after AdaptiveLimitMargin’s last update

  • step_size (float) – The value by which each limit gets updated at each step

  • update_time (string) – When the update happens. “step” for the end of a step, “episode” for the end of an episode

  • update_freq (int) – After how many cumulative units of update_time an update occurs

Additional Notes:

All limit_margins should be between -1 and 1

on_reset_end(state, reference)[source]

Gets called at the end of each reset

on_step_end(k, state, reference, reward, terminated)[source]

Gets called at the end of each step

set_env(env)[source]

Sets the environment of the motor.