From ace4dc84f21e28b86382b43a2892699486dfdc03 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Sat, 6 May 2023 11:47:16 +0200 Subject: [PATCH 01/37] first changes for migration to gymnasium, set all imports to gymnasium --- .../classic_controllers/classic_controllers.py | 2 +- .../classic_controllers_dc_motor_example.py | 2 +- .../controllers/cascaded_controller.py | 2 +- .../controllers/cascaded_foc_controller.py | 2 +- .../controllers/continuous_action_controller.py | 2 +- .../controllers/dicrete_action_controller.py | 2 +- .../controllers/discrete_controller.py | 2 +- .../controllers/foc_controller.py | 2 +- .../controllers/induction_motor_cascaded_foc.py | 2 +- .../controllers/induction_motor_foc.py | 2 +- examples/environment_features/GEM_cookbook.ipynb | 2 +- .../ddpg_pmsm_dq_current_control.py | 6 +++--- .../ddpg_series_omega_control.py | 2 +- .../dqn_series_current_control.py | 2 +- .../keras_rl2_dqn_disc_pmsm_example.ipynb | 6 +++--- ...stable_baselines3_dqn_disc_pmsm_example.ipynb | 6 +++--- gym_electric_motor/__init__.py | 8 ++++---- gym_electric_motor/core.py | 16 ++++++++-------- .../envs/gym_srm/srm_continuous_control_env.py | 4 ++-- .../envs/gym_srm/srm_finite_control_env.py | 4 ++-- .../cos_sin_processor.py | 4 ++-- .../current_sum_processor.py | 4 ++-- .../dead_time_processor.py | 8 ++++---- .../dq_to_abc_action_processor.py | 6 +++--- .../physical_system_wrappers/flux_observer.py | 4 ++-- .../physical_systems/converters.py | 8 ++++---- .../electric_motors/electric_motor.py | 4 ++-- .../mechanical_loads/mechanical_load.py | 4 ++-- .../physical_systems/physical_systems.py | 2 +- .../const_reference_generator.py | 2 +- .../multiple_reference_generator.py | 2 +- .../subepisoded_reference_generator.py | 2 +- .../switched_reference_generator.py | 2 +- .../zero_reference_generator.py | 2 +- gym_electric_motor/utils.py | 6 +++--- .../visualization/motor_dashboard.py | 8 ++++---- .../motor_dashboard_plots/action_plot.py | 2 +- tests/conf.py | 2 +- tests/test_core.py | 8 ++++---- .../test_cos_sin_processor.py | 4 ++-- .../test_dead_time_processor.py | 12 ++++++------ .../test_dq_to_abc_action_processor.py | 4 ++-- .../test_flux_observer.py | 4 ++-- tests/test_physical_systems/test_converters.py | 2 +- .../test_mechanical_loads.py | 8 ++++---- .../test_physical_systems.py | 2 +- .../test_reference_generators.py | 6 +++--- tests/testing_utils.py | 2 +- 48 files changed, 100 insertions(+), 100 deletions(-) diff --git a/examples/classic_controllers/classic_controllers.py b/examples/classic_controllers/classic_controllers.py index 9a0e234a..f9db1347 100644 --- a/examples/classic_controllers/classic_controllers.py +++ b/examples/classic_controllers/classic_controllers.py @@ -1,4 +1,4 @@ -from gym.spaces import Discrete, Box, MultiDiscrete +from gymnasium.spaces import Discrete, Box, MultiDiscrete from gym_electric_motor.physical_systems import SynchronousMotorSystem, DcMotorSystem, DcSeriesMotor, \ DcExternallyExcitedMotor, DoublyFedInductionMotorSystem, SquirrelCageInductionMotorSystem from gym_electric_motor.reference_generators import MultipleReferenceGenerator, SwitchedReferenceGenerator diff --git a/examples/classic_controllers/classic_controllers_dc_motor_example.py b/examples/classic_controllers/classic_controllers_dc_motor_example.py index d8767cc5..ea0232b3 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_example.py @@ -53,7 +53,7 @@ """ controller = Controller.make(env, external_ref_plots=external_ref_plots) - state, reference = env.reset() + state, reference = env.reset(seed = 0, options ={}) # simulate the environment for i in range(10001): diff --git a/examples/classic_controllers/controllers/cascaded_controller.py b/examples/classic_controllers/controllers/cascaded_controller.py index 680c47ab..3b60f8d0 100644 --- a/examples/classic_controllers/controllers/cascaded_controller.py +++ b/examples/classic_controllers/controllers/cascaded_controller.py @@ -1,5 +1,5 @@ from .continuous_controller import ContinuousController -from gym.spaces import Box, Discrete, MultiDiscrete +from gymnasium.spaces import Box, Discrete, MultiDiscrete from gym_electric_motor.physical_systems import DcExternallyExcitedMotor from .plot_external_data import plot diff --git a/examples/classic_controllers/controllers/cascaded_foc_controller.py b/examples/classic_controllers/controllers/cascaded_foc_controller.py index 4a525e86..e3675313 100644 --- a/examples/classic_controllers/controllers/cascaded_foc_controller.py +++ b/examples/classic_controllers/controllers/cascaded_foc_controller.py @@ -1,7 +1,7 @@ from .continuous_controller import ContinuousController from .torque_to_current_conversion import TorqueToCurrentConversion from .plot_external_data import plot -from gym.spaces import Box +from gymnasium.spaces import Box import numpy as np diff --git a/examples/classic_controllers/controllers/continuous_action_controller.py b/examples/classic_controllers/controllers/continuous_action_controller.py index 4412bbfb..25be55ac 100644 --- a/examples/classic_controllers/controllers/continuous_action_controller.py +++ b/examples/classic_controllers/controllers/continuous_action_controller.py @@ -1,4 +1,4 @@ -from gym.spaces import Box +from gymnasium.spaces import Box from gym_electric_motor.physical_systems import DcMotorSystem, DcExternallyExcitedMotor from .plot_external_data import plot import numpy as np diff --git a/examples/classic_controllers/controllers/dicrete_action_controller.py b/examples/classic_controllers/controllers/dicrete_action_controller.py index a7629b54..4785a192 100644 --- a/examples/classic_controllers/controllers/dicrete_action_controller.py +++ b/examples/classic_controllers/controllers/dicrete_action_controller.py @@ -1,5 +1,5 @@ from .plot_external_data import plot -from gym.spaces import Discrete, MultiDiscrete +from gymnasium.spaces import Discrete, MultiDiscrete from gym_electric_motor.physical_systems import DcMotorSystem, DcExternallyExcitedMotor import numpy as np diff --git a/examples/classic_controllers/controllers/discrete_controller.py b/examples/classic_controllers/controllers/discrete_controller.py index fcf44ce9..d17fbfdb 100644 --- a/examples/classic_controllers/controllers/discrete_controller.py +++ b/examples/classic_controllers/controllers/discrete_controller.py @@ -1,4 +1,4 @@ -from gym.spaces import Discrete, MultiDiscrete +from gymnasium.spaces import Discrete, MultiDiscrete class DiscreteController: diff --git a/examples/classic_controllers/controllers/foc_controller.py b/examples/classic_controllers/controllers/foc_controller.py index 3c0541fe..f0918c85 100644 --- a/examples/classic_controllers/controllers/foc_controller.py +++ b/examples/classic_controllers/controllers/foc_controller.py @@ -1,6 +1,6 @@ from .plot_external_data import plot from gym_electric_motor.physical_systems import SynchronousMotorSystem -from gym.spaces import Box +from gymnasium.spaces import Box import numpy as np diff --git a/examples/classic_controllers/controllers/induction_motor_cascaded_foc.py b/examples/classic_controllers/controllers/induction_motor_cascaded_foc.py index 48cfb1a8..b6ee8229 100644 --- a/examples/classic_controllers/controllers/induction_motor_cascaded_foc.py +++ b/examples/classic_controllers/controllers/induction_motor_cascaded_foc.py @@ -2,7 +2,7 @@ from .induction_motor_torque_to_current_conversion import InductionMotorTorqueToCurrentConversion from .flux_observer import FluxObserver from .plot_external_data import plot -from gym.spaces import Box +from gymnasium.spaces import Box import numpy as np diff --git a/examples/classic_controllers/controllers/induction_motor_foc.py b/examples/classic_controllers/controllers/induction_motor_foc.py index 53f7de56..699cd06e 100644 --- a/examples/classic_controllers/controllers/induction_motor_foc.py +++ b/examples/classic_controllers/controllers/induction_motor_foc.py @@ -1,6 +1,6 @@ from .flux_observer import FluxObserver from .plot_external_data import plot -from gym.spaces import Box +from gymnasium.spaces import Box import numpy as np diff --git a/examples/environment_features/GEM_cookbook.ipynb b/examples/environment_features/GEM_cookbook.ipynb index 05ee8cd5..62e04a83 100644 --- a/examples/environment_features/GEM_cookbook.ipynb +++ b/examples/environment_features/GEM_cookbook.ipynb @@ -738,7 +738,7 @@ "metadata": {}, "outputs": [], "source": [ - "import gym\n", + "import gymnasium as gym\n", "import numpy as np\n", "\n", "from gym_electric_motor.physical_system_wrappers import PhysicalSystemWrapper\n", diff --git a/examples/reinforcement_learning_controllers/ddpg_pmsm_dq_current_control.py b/examples/reinforcement_learning_controllers/ddpg_pmsm_dq_current_control.py index 7fc41442..d72110e0 100644 --- a/examples/reinforcement_learning_controllers/ddpg_pmsm_dq_current_control.py +++ b/examples/reinforcement_learning_controllers/ddpg_pmsm_dq_current_control.py @@ -6,7 +6,7 @@ from rl.agents import DDPGAgent from rl.memory import SequentialMemory from rl.random import OrnsteinUhlenbeckProcess -from gym.wrappers import FlattenObservation +from gymnasium.wrappers import FlattenObservation import numpy as np import sys import os @@ -17,8 +17,8 @@ from gym_electric_motor.visualization import MotorDashboard from gym_electric_motor.visualization.motor_dashboard_plots import MeanEpisodeRewardPlot from gym_electric_motor.physical_systems.mechanical_loads import ConstantSpeedLoad -from gym.core import Wrapper -from gym.spaces import Box, Tuple +from gymnasium.core import Wrapper +from gymnasium.spaces import Box, Tuple from gym_electric_motor.constraints import SquaredConstraint from gym_electric_motor.physical_system_wrappers import DqToAbcActionProcessor, DeadTimeProcessor diff --git a/examples/reinforcement_learning_controllers/ddpg_series_omega_control.py b/examples/reinforcement_learning_controllers/ddpg_series_omega_control.py index 83782434..0faa4738 100644 --- a/examples/reinforcement_learning_controllers/ddpg_series_omega_control.py +++ b/examples/reinforcement_learning_controllers/ddpg_series_omega_control.py @@ -10,7 +10,7 @@ from rl.agents import DDPGAgent from rl.memory import SequentialMemory from rl.random import OrnsteinUhlenbeckProcess -from gym.wrappers import FlattenObservation +from gymnasium.wrappers import FlattenObservation import sys import os sys.path.append(os.path.abspath(os.path.join('..'))) diff --git a/examples/reinforcement_learning_controllers/dqn_series_current_control.py b/examples/reinforcement_learning_controllers/dqn_series_current_control.py index d1939d2a..ac3bae2a 100644 --- a/examples/reinforcement_learning_controllers/dqn_series_current_control.py +++ b/examples/reinforcement_learning_controllers/dqn_series_current_control.py @@ -8,7 +8,7 @@ from rl.agents.dqn import DQNAgent from rl.policy import LinearAnnealedPolicy, EpsGreedyQPolicy from rl.memory import SequentialMemory -from gym.wrappers import FlattenObservation +from gymnasium.wrappers import FlattenObservation import sys import os sys.path.append(os.path.abspath(os.path.join('..'))) diff --git a/examples/reinforcement_learning_controllers/keras_rl2_dqn_disc_pmsm_example.ipynb b/examples/reinforcement_learning_controllers/keras_rl2_dqn_disc_pmsm_example.ipynb index 590b32bb..cfb86a82 100644 --- a/examples/reinforcement_learning_controllers/keras_rl2_dqn_disc_pmsm_example.ipynb +++ b/examples/reinforcement_learning_controllers/keras_rl2_dqn_disc_pmsm_example.ipynb @@ -119,9 +119,9 @@ " MultipleReferenceGenerator,\\\n", " WienerProcessReferenceGenerator\n", "from gym_electric_motor.visualization import MotorDashboard\n", - "from gym.spaces import Discrete, Box\n", - "from gym.wrappers import FlattenObservation, TimeLimit\n", - "from gym import ObservationWrapper" + "from gymnasium.spaces import Discrete, Box\n", + "from gymnasium.wrappers import FlattenObservation, TimeLimit\n", + "from gymnasium import ObservationWrapper" ] }, { diff --git a/examples/reinforcement_learning_controllers/stable_baselines3_dqn_disc_pmsm_example.ipynb b/examples/reinforcement_learning_controllers/stable_baselines3_dqn_disc_pmsm_example.ipynb index 745cf3bf..470f9dd1 100644 --- a/examples/reinforcement_learning_controllers/stable_baselines3_dqn_disc_pmsm_example.ipynb +++ b/examples/reinforcement_learning_controllers/stable_baselines3_dqn_disc_pmsm_example.ipynb @@ -111,9 +111,9 @@ " WienerProcessReferenceGenerator\n", "from gym_electric_motor.visualization import MotorDashboard\n", "from gym_electric_motor.core import Callback\n", - "from gym.spaces import Discrete, Box\n", - "from gym.wrappers import FlattenObservation, TimeLimit\n", - "from gym import ObservationWrapper" + "from gymnasium.spaces import Discrete, Box\n", + "from gymnasium.wrappers import FlattenObservation, TimeLimit\n", + "from gymnasium import ObservationWrapper" ] }, { diff --git a/gym_electric_motor/__init__.py b/gym_electric_motor/__init__.py index 0f9e3b70..c97b3987 100644 --- a/gym_electric_motor/__init__.py +++ b/gym_electric_motor/__init__.py @@ -19,13 +19,13 @@ import gym_electric_motor.envs import gym_electric_motor.physical_system_wrappers -from gym.envs.registration import register -import gym +from gymnasium.envs.registration import register +import gymnasium from packaging import version # Add all superclasses of the modules to the registry. -# Deactivate the order enforce wrapper that is put around a created env per default from gym-version 0.21.0 onwards -registration_kwargs = dict(order_enforce=False) if version.parse(gym.__version__) >= version.parse('0.21.0') else dict() +# Deactivate the order enforce wrapper that is put around a created env per default from gymnasium-version 0.21.0 onwards +registration_kwargs = dict(order_enforce=False) if version.parse(gymnasium.__version__) >= version.parse('0.21.0') else dict() envs_path = 'gym_electric_motor.envs:' diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index bf0752ad..10607f72 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -17,9 +17,9 @@ - Visualization of the PhysicalSystems state, reference and reward for the user. """ -import gym +import gymnasium import numpy as np -from gym.spaces import Box +from gymnasium.spaces import Box from .utils import instantiate from .random_component import RandomComponent @@ -27,7 +27,7 @@ import gym_electric_motor as gem -class ElectricMotorEnvironment(gym.core.Env): +class ElectricMotorEnvironment(gymnasium.core.Env): """ Description: The main class connecting all modules of the gym-electric-motor environments. @@ -219,7 +219,7 @@ def __init__(self, physical_system, reference_generator, reward_function, visual states_low = self._physical_system.state_space.low[self.state_filter] states_high = self._physical_system.state_space.high[self.state_filter] state_space = Box(states_low, states_high, dtype=np.float64) - self.observation_space = gym.spaces.Tuple(( + self.observation_space = gymnasium.spaces.Tuple(( state_space, self._reference_generator.reference_space )) @@ -546,7 +546,7 @@ def state_positions(self): def action_space(self): """ Returns: - gym.Space: An OpenAI Gym Space that describes the possible actions on the system. + gymnasium.Space: An OpenAI Gym Space that describes the possible actions on the system. """ return self._action_space @@ -554,7 +554,7 @@ def action_space(self): def state_space(self): """ Returns: - gym.Space: An OpenAI Gym Space that describes the possible states of the system. + gymnasium.Space: An OpenAI Gym Space that describes the possible states of the system. """ return self._state_space @@ -577,8 +577,8 @@ def nominal_state(self): def __init__(self, action_space, state_space, state_names, tau): """ Args: - action_space(gym.Space): The set of allowed actions on the system. - state_space(gym.Space): The set of possible systems states. + action_space(gymnasium.Space): The set of allowed actions on the system. + state_space(gymnasium.Space): The set of possible systems states. state_names(ndarray(str)): The names of the systems states tau(float): The systems simulation time interval. """ diff --git a/gym_electric_motor/envs/gym_srm/srm_continuous_control_env.py b/gym_electric_motor/envs/gym_srm/srm_continuous_control_env.py index da2ccb12..5a012949 100644 --- a/gym_electric_motor/envs/gym_srm/srm_continuous_control_env.py +++ b/gym_electric_motor/envs/gym_srm/srm_continuous_control_env.py @@ -1,7 +1,7 @@ -import gym +import gymnasium -class SRMContinuousControlEnv(gym.Env): +class SRMContinuousControlEnv(gymnasium.Env): metadata = {'render.modes': ['human']} def __init__(self): diff --git a/gym_electric_motor/envs/gym_srm/srm_finite_control_env.py b/gym_electric_motor/envs/gym_srm/srm_finite_control_env.py index 133a1cf3..cdbacd52 100644 --- a/gym_electric_motor/envs/gym_srm/srm_finite_control_env.py +++ b/gym_electric_motor/envs/gym_srm/srm_finite_control_env.py @@ -1,7 +1,7 @@ -import gym +import gymnasium -class SRMFiniteControlEnv(gym.Env): +class SRMFiniteControlEnv(gymnasium.Env): metadata = {'render.modes': ['human']} def __init__(self): diff --git a/gym_electric_motor/physical_system_wrappers/cos_sin_processor.py b/gym_electric_motor/physical_system_wrappers/cos_sin_processor.py index 690dee4c..bf2415cf 100644 --- a/gym_electric_motor/physical_system_wrappers/cos_sin_processor.py +++ b/gym_electric_motor/physical_system_wrappers/cos_sin_processor.py @@ -1,4 +1,4 @@ -import gym +import gymnasium import numpy as np from gym_electric_motor.physical_system_wrappers import PhysicalSystemWrapper @@ -38,7 +38,7 @@ def set_physical_system(self, physical_system): self._remove_idx = self._angle_index if self._remove_angle else [] low = np.concatenate((np.delete(physical_system.state_space.low, self._remove_idx), [-1., -1.])) high = np.concatenate((np.delete(physical_system.state_space.high, self._remove_idx), [1., 1.])) - self.state_space = gym.spaces.Box(low, high, dtype=np.float64) + self.state_space = gymnasium.spaces.Box(low, high, dtype=np.float64) self._limits = np.concatenate((np.delete(physical_system.limits, self._remove_idx), [1., 1.])) self._nominal_state = np.concatenate((np.delete(physical_system.nominal_state, self._remove_idx), [1., 1.])) diff --git a/gym_electric_motor/physical_system_wrappers/current_sum_processor.py b/gym_electric_motor/physical_system_wrappers/current_sum_processor.py index e3f25224..08816ac4 100644 --- a/gym_electric_motor/physical_system_wrappers/current_sum_processor.py +++ b/gym_electric_motor/physical_system_wrappers/current_sum_processor.py @@ -1,4 +1,4 @@ -import gym +import gymnasium import numpy as np from gym_electric_motor.physical_system_wrappers import PhysicalSystemWrapper @@ -29,7 +29,7 @@ def set_physical_system(self, physical_system): # Define the new state space as concatenation of the old state space and [-1,1] for i_sum low = np.concatenate((physical_system.state_space.low, [-1.])) high = np.concatenate((physical_system.state_space.high, [1.])) - self.state_space = gym.spaces.Box(low, high, dtype=np.float64) + self.state_space = gymnasium.spaces.Box(low, high, dtype=np.float64) # Set the new limits / nominal values of the state vector current_limit = self._limit(physical_system.limits[self._current_indices]) diff --git a/gym_electric_motor/physical_system_wrappers/dead_time_processor.py b/gym_electric_motor/physical_system_wrappers/dead_time_processor.py index 39b6a213..f447cc48 100644 --- a/gym_electric_motor/physical_system_wrappers/dead_time_processor.py +++ b/gym_electric_motor/physical_system_wrappers/dead_time_processor.py @@ -1,7 +1,7 @@ from collections import deque import numpy as np -import gym.spaces +import gymnasium.spaces from gym_electric_motor.physical_system_wrappers import PhysicalSystemWrapper @@ -45,11 +45,11 @@ def set_physical_system(self, physical_system): super().set_physical_system(physical_system) if self._reset_actions is None: action_space = physical_system.action_space - if isinstance(action_space, gym.spaces.Discrete): + if isinstance(action_space, gymnasium.spaces.Discrete): reset_action = 0 - elif isinstance(action_space, gym.spaces.MultiDiscrete): + elif isinstance(action_space, gymnasium.spaces.MultiDiscrete): reset_action = [np.zeros_like(action_space.nvec)] - elif isinstance(action_space, gym.spaces.Box): + elif isinstance(action_space, gymnasium.spaces.Box): reset_action = np.zeros(action_space.shape, dtype=np.float64) else: raise AssertionError( diff --git a/gym_electric_motor/physical_system_wrappers/dq_to_abc_action_processor.py b/gym_electric_motor/physical_system_wrappers/dq_to_abc_action_processor.py index 9946f2bf..042af41a 100644 --- a/gym_electric_motor/physical_system_wrappers/dq_to_abc_action_processor.py +++ b/gym_electric_motor/physical_system_wrappers/dq_to_abc_action_processor.py @@ -1,4 +1,4 @@ -import gym +import gymnasium import numpy as np import gym_electric_motor.physical_systems as ps @@ -91,7 +91,7 @@ class _ClassicDqToAbcActionProcessor(DqToAbcActionProcessor): @property def action_space(self): - return gym.spaces.Box(-1, 1, shape=(2,), dtype=np.float64) + return gymnasium.spaces.Box(-1, 1, shape=(2,), dtype=np.float64) def simulate(self, action): # Docstring of superclass @@ -116,7 +116,7 @@ class _DFIMDqToAbcActionProcessor(DqToAbcActionProcessor): @property def action_space(self): - return gym.spaces.Box(-1, 1, shape=(4,)) + return gymnasium.spaces.Box(-1, 1, shape=(4,)) def __init__(self, physical_system=None): super().__init__('epsilon', physical_system=physical_system) diff --git a/gym_electric_motor/physical_system_wrappers/flux_observer.py b/gym_electric_motor/physical_system_wrappers/flux_observer.py index 41ce0d8c..c3f176b0 100644 --- a/gym_electric_motor/physical_system_wrappers/flux_observer.py +++ b/gym_electric_motor/physical_system_wrappers/flux_observer.py @@ -1,4 +1,4 @@ -import gym +import gymnasium import numpy as np import gym_electric_motor as gem @@ -62,7 +62,7 @@ def set_physical_system(self, physical_system): psi_limit = self._l_m * physical_system.limits[physical_system.state_names.index('i_sd')] low = np.concatenate((physical_system.state_space.low, [-psi_limit, -np.pi])) high = np.concatenate((physical_system.state_space.high, [psi_limit, np.pi])) - self.state_space = gym.spaces.Box(low, high, dtype=np.float64) + self.state_space = gymnasium.spaces.Box(low, high, dtype=np.float64) self._current_indices = [physical_system.state_positions[name] for name in self._current_names] self._limits = np.concatenate((physical_system.limits, [psi_limit, np.pi])) self._nominal_state = np.concatenate((physical_system.nominal_state, [psi_limit, np.pi])) diff --git a/gym_electric_motor/physical_systems/converters.py b/gym_electric_motor/physical_systems/converters.py index d33b9959..3ccd4e0e 100644 --- a/gym_electric_motor/physical_systems/converters.py +++ b/gym_electric_motor/physical_systems/converters.py @@ -1,5 +1,5 @@ import numpy as np -from gym.spaces import Discrete, Box, MultiDiscrete +from gymnasium.spaces import Discrete, Box, MultiDiscrete from ..utils import instantiate @@ -16,11 +16,11 @@ class PowerElectronicConverter: | E.g. (0, 1) - Only positive currents / (-1, 1) Positive and negative currents """ - #: gym.Space that defines Minimum, Maximum and Dimension of possible output voltage of the converter + #: gymnasium.Space that defines Minimum, Maximum and Dimension of possible output voltage of the converter voltages = None - #: gym.Space that defines Minimum, Maximum and Dimension of possible output current of the converter + #: gymnasium.Space that defines Minimum, Maximum and Dimension of possible output current of the converter currents = None - #: gym.Space that defines the set of all possible actions for the converter + #: gymnasium.Space that defines the set of all possible actions for the converter action_space = None #: Default action that is taken after a reset. _reset_action = None diff --git a/gym_electric_motor/physical_systems/electric_motors/electric_motor.py b/gym_electric_motor/physical_systems/electric_motors/electric_motor.py index fc2563a5..91cba614 100644 --- a/gym_electric_motor/physical_systems/electric_motors/electric_motor.py +++ b/gym_electric_motor/physical_systems/electric_motors/electric_motor.py @@ -183,7 +183,7 @@ def initialize(self, state_space, state_positions, **__): initial_states attribute Args: - state_space(gym.Box): normalized state space boundaries (given by physical system) + state_space(gymnasium.Box): normalized state space boundaries (given by physical system) state_positions(dict): indices of system states (given by physical system) """ # for organization purposes @@ -285,7 +285,7 @@ def reset(self, state_space, state_positions, **__): """Reset the motors state to a new initial state. (Default 0) Args: - state_space(gym.Box): normalized state space boundaries + state_space(gymnasium.Box): normalized state space boundaries state_positions(dict): indexes of system states Returns: numpy.ndarray(float): The initial motor states. diff --git a/gym_electric_motor/physical_systems/mechanical_loads/mechanical_load.py b/gym_electric_motor/physical_systems/mechanical_loads/mechanical_load.py index bf16438b..841110c1 100644 --- a/gym_electric_motor/physical_systems/mechanical_loads/mechanical_load.py +++ b/gym_electric_motor/physical_systems/mechanical_loads/mechanical_load.py @@ -104,7 +104,7 @@ def initialize(self, state_space, state_positions, nominal_state, **__): Args: nominal_state(list): nominal values for each state given from physical system - state_space(gym.spaces.Box): normalized state space boundaries + state_space(gymnasium.spaces.Box): normalized state space boundaries state_positions(dict): indexes of system states """ # for order and organization purposes @@ -175,7 +175,7 @@ def reset(self, state_space, state_positions, nominal_state, **__): Args: nominal_state(list): nominal values for each state given from physical system - state_space(gym.Box): normalized state space boundaries + state_space(gymnasium.Box): normalized state space boundaries state_positions(dict): indexes of system states Returns: numpy.ndarray(float): The initial motor states. diff --git a/gym_electric_motor/physical_systems/physical_systems.py b/gym_electric_motor/physical_systems/physical_systems.py index 9cdc29a9..5ce61805 100644 --- a/gym_electric_motor/physical_systems/physical_systems.py +++ b/gym_electric_motor/physical_systems/physical_systems.py @@ -1,5 +1,5 @@ import numpy as np -from gym.spaces import Box +from gymnasium.spaces import Box import warnings import gym_electric_motor as gem diff --git a/gym_electric_motor/reference_generators/const_reference_generator.py b/gym_electric_motor/reference_generators/const_reference_generator.py index 16279311..f8001ee4 100644 --- a/gym_electric_motor/reference_generators/const_reference_generator.py +++ b/gym_electric_motor/reference_generators/const_reference_generator.py @@ -1,7 +1,7 @@ import numpy as np from gym_electric_motor.core import ReferenceGenerator from gym_electric_motor.utils import set_state_array -from gym.spaces import Box +from gymnasium.spaces import Box class ConstReferenceGenerator(ReferenceGenerator): diff --git a/gym_electric_motor/reference_generators/multiple_reference_generator.py b/gym_electric_motor/reference_generators/multiple_reference_generator.py index 12b40ad5..e6342ff3 100644 --- a/gym_electric_motor/reference_generators/multiple_reference_generator.py +++ b/gym_electric_motor/reference_generators/multiple_reference_generator.py @@ -1,5 +1,5 @@ import numpy as np -from gym.spaces import Box +from gymnasium.spaces import Box from ..core import ReferenceGenerator from ..utils import instantiate diff --git a/gym_electric_motor/reference_generators/subepisoded_reference_generator.py b/gym_electric_motor/reference_generators/subepisoded_reference_generator.py index 266abf65..c8742e5f 100644 --- a/gym_electric_motor/reference_generators/subepisoded_reference_generator.py +++ b/gym_electric_motor/reference_generators/subepisoded_reference_generator.py @@ -1,5 +1,5 @@ import numpy as np -from gym.spaces import Box +from gymnasium.spaces import Box from ..random_component import RandomComponent from ..core import ReferenceGenerator diff --git a/gym_electric_motor/reference_generators/switched_reference_generator.py b/gym_electric_motor/reference_generators/switched_reference_generator.py index 17d82026..403a52de 100644 --- a/gym_electric_motor/reference_generators/switched_reference_generator.py +++ b/gym_electric_motor/reference_generators/switched_reference_generator.py @@ -1,5 +1,5 @@ import numpy as np -from gym.spaces import Box +from gymnasium.spaces import Box from ..random_component import RandomComponent from ..core import ReferenceGenerator diff --git a/gym_electric_motor/reference_generators/zero_reference_generator.py b/gym_electric_motor/reference_generators/zero_reference_generator.py index 2a0fa698..fe10190b 100644 --- a/gym_electric_motor/reference_generators/zero_reference_generator.py +++ b/gym_electric_motor/reference_generators/zero_reference_generator.py @@ -1,5 +1,5 @@ import numpy as np -from gym.spaces import Box +from gymnasium.spaces import Box from ..core import ReferenceGenerator diff --git a/gym_electric_motor/utils.py b/gym_electric_motor/utils.py index b71f88c8..3ca0dcee 100644 --- a/gym_electric_motor/utils.py +++ b/gym_electric_motor/utils.py @@ -1,5 +1,5 @@ import numpy as np -import gym +import gymnasium def state_dict_to_state_array(state_dict, state_array, state_names): @@ -158,5 +158,5 @@ def update_parameter_dict(source_dict, update_dict, copy=True): return new_dict -#: Short notation for the gym.make call to avoid the necessary import of gym when making environments. -make = gym.make +#: Short notation for the gymnasium.make call to avoid the necessary import of gym when making environments. +make = gymnasium.make diff --git a/gym_electric_motor/visualization/motor_dashboard.py b/gym_electric_motor/visualization/motor_dashboard.py index e98c495c..fce7b833 100644 --- a/gym_electric_motor/visualization/motor_dashboard.py +++ b/gym_electric_motor/visualization/motor_dashboard.py @@ -1,7 +1,7 @@ from gym_electric_motor.core import ElectricMotorVisualization from .motor_dashboard_plots import StatePlot, ActionPlot, RewardPlot, TimePlot, EpisodePlot, StepPlot import matplotlib.pyplot as plt -import gym +import gymnasium class MotorDashboard(ElectricMotorVisualization): @@ -152,9 +152,9 @@ def set_env(self, env): if self._state_plots == 'all': self._state_plots = state_names if self._action_plots == 'all': - if type(env.action_space) is gym.spaces.Discrete: + if type(env.action_space) is gymnasium.spaces.Discrete: self._action_plots = [0] - elif type(env.action_space) in (gym.spaces.Box, gym.spaces.MultiDiscrete): + elif type(env.action_space) in (gymnasium.spaces.Box, gymnasium.spaces.MultiDiscrete): self._action_plots = list(range(env.action_space.shape[0])) self._time_plots = [] @@ -165,7 +165,7 @@ def set_env(self, env): self._time_plots.append(StatePlot(state)) if len(self._action_plots) > 0: - assert type(env.action_space) in (gym.spaces.Box, gym.spaces.Discrete, gym.spaces.MultiDiscrete), \ + assert type(env.action_space) in (gymnasium.spaces.Box, gymnasium.spaces.Discrete, gymnasium.spaces.MultiDiscrete), \ f'Action space of type {type(env.action_space)} not supported for plotting.' for action in self._action_plots: ap = ActionPlot(action) diff --git a/gym_electric_motor/visualization/motor_dashboard_plots/action_plot.py b/gym_electric_motor/visualization/motor_dashboard_plots/action_plot.py index 99431998..c47a9a19 100644 --- a/gym_electric_motor/visualization/motor_dashboard_plots/action_plot.py +++ b/gym_electric_motor/visualization/motor_dashboard_plots/action_plot.py @@ -1,4 +1,4 @@ -from gym.spaces import Box, Discrete, MultiDiscrete +from gymnasium.spaces import Box, Discrete, MultiDiscrete import numpy as np from .base_plots import TimePlot diff --git a/tests/conf.py b/tests/conf.py index 830ee6c3..d50214e0 100644 --- a/tests/conf.py +++ b/tests/conf.py @@ -2,7 +2,7 @@ from matplotlib import pyplot as plt import matplotlib from gym_electric_motor.core import * -from gym.spaces import Box +from gymnasium.spaces import Box import pytest # region parameter definition diff --git a/tests/test_core.py b/tests/test_core.py index 00f57bd7..c497ce2e 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2,12 +2,12 @@ import numpy as np from tests.testing_utils import DummyPhysicalSystem, DummyReferenceGenerator, DummyRewardFunction, DummyVisualization,\ DummyCallback, DummyConstraintMonitor, DummyConstraint, mock_instantiate, instantiate_dict -from gym.spaces import Tuple, Box +from gymnasium.spaces import Tuple, Box import gym_electric_motor from gym_electric_motor.core import ElectricMotorEnvironment, RewardFunction, \ ReferenceGenerator, PhysicalSystem, ConstraintMonitor, Constraint from gym_electric_motor.constraints import LimitConstraint -import gym +import gymnasium import gym_electric_motor as gem @@ -254,8 +254,8 @@ def test_referenced_states(self, reference_generator): class TestPhysicalSystem: def test_initialization(self): - action_space = gym.spaces.Discrete(3) - state_space = gym.spaces.Box(-1, 1, shape=(3,)) + action_space = gymnasium.spaces.Discrete(3) + state_space = gymnasium.spaces.Box(-1, 1, shape=(3,)) state_names = [f'dummy_state_{i}' for i in range(3)] tau = 1 ps = PhysicalSystem(action_space, state_space, state_names, tau) diff --git a/tests/test_physical_system_wrappers/test_cos_sin_processor.py b/tests/test_physical_system_wrappers/test_cos_sin_processor.py index 279bbabc..5572125a 100644 --- a/tests/test_physical_system_wrappers/test_cos_sin_processor.py +++ b/tests/test_physical_system_wrappers/test_cos_sin_processor.py @@ -1,4 +1,4 @@ -import gym +import gymnasium import pytest import numpy as np import gym_electric_motor as gem @@ -22,7 +22,7 @@ def test_nominal_state(self, processor, physical_system): def test_state_space(self, processor, physical_system): low = np.concatenate((physical_system.state_space.low, [-1, -1])) high = np.concatenate((physical_system.state_space.high, [1, 1])) - space = gym.spaces.Box(low, high) + space = gymnasium.spaces.Box(low, high) assert processor.state_space == space def test_reset(self, processor, physical_system): diff --git a/tests/test_physical_system_wrappers/test_dead_time_processor.py b/tests/test_physical_system_wrappers/test_dead_time_processor.py index d325ee78..89e05fba 100644 --- a/tests/test_physical_system_wrappers/test_dead_time_processor.py +++ b/tests/test_physical_system_wrappers/test_dead_time_processor.py @@ -1,4 +1,4 @@ -import gym +import gymnasium import pytest import numpy as np import gym_electric_motor as gem @@ -32,22 +32,22 @@ def test_simulate(self, reset_processor, physical_system, action): ['action_space', 'actions', 'reset_action'], [ [ - gym.spaces.Box(-100, 100, shape=(3,)), + gymnasium.spaces.Box(-100, 100, shape=(3,)), [np.array([1., 2., 3.]), np.array([0., 1., 2.]), np.array([-1, 2, 3])], np.array([0., 0., 0.]) ], [ - gym.spaces.Box(-100, 100, shape=(1,)), + gymnasium.spaces.Box(-100, 100, shape=(1,)), [np.array([-1.]), np.array([0.]), np.array([-5.]), np.array([-6.]), np.array([-7.])], np.array([0.]) ], [ - gym.spaces.MultiDiscrete([10, 20, 30]), + gymnasium.spaces.MultiDiscrete([10, 20, 30]), [[5, 8, 7], [3, 4, 5], [0, 0, 1], [0, 1, 1], [0, 0, 1]], [0, 0, 0] ], [ - gym.spaces.Discrete(12), + gymnasium.spaces.Discrete(12), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0 ] @@ -67,7 +67,7 @@ def test_execution(self, unset_processor, physical_system, action_space, actions @pytest.mark.parametrize('processor', [gem.physical_system_wrappers.DeadTimeProcessor()]) def test_false_action_space(self, processor, physical_system): - physical_system._action_space = gym.spaces.MultiBinary(5) + physical_system._action_space = gymnasium.spaces.MultiBinary(5) with pytest.raises(AssertionError): assert processor.set_physical_system(physical_system) diff --git a/tests/test_physical_system_wrappers/test_dq_to_abc_action_processor.py b/tests/test_physical_system_wrappers/test_dq_to_abc_action_processor.py index 84de3efc..14deaca1 100644 --- a/tests/test_physical_system_wrappers/test_dq_to_abc_action_processor.py +++ b/tests/test_physical_system_wrappers/test_dq_to_abc_action_processor.py @@ -1,4 +1,4 @@ -import gym +import gymnasium import pytest import numpy as np import gym_electric_motor as gem @@ -20,7 +20,7 @@ def processor(self, physical_system): return gem.physical_system_wrappers.DqToAbcActionProcessor.make('PMSM', physical_system=physical_system) def test_action_space(self, processor, physical_system): - space = gym.spaces.Box(-1, 1, shape=(2,), dtype=np.float64) + space = gymnasium.spaces.Box(-1, 1, shape=(2,), dtype=np.float64) assert processor.action_space == space @pytest.mark.parametrize( diff --git a/tests/test_physical_system_wrappers/test_flux_observer.py b/tests/test_physical_system_wrappers/test_flux_observer.py index ab562a97..2a8826fe 100644 --- a/tests/test_physical_system_wrappers/test_flux_observer.py +++ b/tests/test_physical_system_wrappers/test_flux_observer.py @@ -1,4 +1,4 @@ -import gym +import gymnasium import pytest import numpy as np import gym_electric_motor as gem @@ -44,7 +44,7 @@ def test_state_space(self, processor, physical_system): psi_abs_max = 200.0 low = np.concatenate((physical_system.state_space.low, [-psi_abs_max, -np.pi])) high = np.concatenate((physical_system.state_space.high, [psi_abs_max, np.pi])) - space = gym.spaces.Box(low, high, dtype=np.float64) + space = gymnasium.spaces.Box(low, high, dtype=np.float64) assert processor.state_space == space def test_reset(self, processor, physical_system): diff --git a/tests/test_physical_systems/test_converters.py b/tests/test_physical_systems/test_converters.py index 10695061..4096a82c 100644 --- a/tests/test_physical_systems/test_converters.py +++ b/tests/test_physical_systems/test_converters.py @@ -7,7 +7,7 @@ import tests.conf as cf from gym_electric_motor.utils import make_module from random import seed, uniform, randint -from gym.spaces import Discrete, Box +from gymnasium.spaces import Discrete, Box # region first version tests diff --git a/tests/test_physical_systems/test_mechanical_loads.py b/tests/test_physical_systems/test_mechanical_loads.py index 2805163e..d7dfc849 100644 --- a/tests/test_physical_systems/test_mechanical_loads.py +++ b/tests/test_physical_systems/test_mechanical_loads.py @@ -1,7 +1,7 @@ import pytest import gym_electric_motor as gem from gym_electric_motor.physical_systems import PolynomialStaticLoad, MechanicalLoad, ConstantSpeedLoad, ExternalSpeedLoad -from gym.spaces import Box +from gymnasium.spaces import Box import numpy as np from scipy import signal import math @@ -118,7 +118,7 @@ def test_MechanicalLoad_reset(concreteMechanicalLoad): # random testcase for the necessary parameters needed for initialization test_positions = {'omega': 0} test_nominal = np.array([80]) - # gym.Box state space with random size + # gymnasium.Box state space with random size test_space = Box(low=-1.0, high=1.0, shape=(3,)) # set additional random kwargs resetVal = concreteMechanicalLoad.reset(a=7, b=9, @@ -216,7 +216,7 @@ def test_mechanical_ode(self, const_speed_load): def test_reset(self, const_speed_load): test_positions = {'omega': 0} test_nominal = np.array([80]) - # gym.Box state space with random size + # gymnasium.Box state space with random size test_space = Box(low=-1.0, high=1.0, shape=(3,)) reset_val = const_speed_load.reset(state_positions=test_positions, nominal_state=test_nominal, @@ -286,7 +286,7 @@ def test_mechanical_ode(self, ext_speed_load, omega, expected_result): def test_reset(self, ext_speed_load): test_positions = {'omega': 0} test_nominal = np.array([80]) - # gym.Box state space with random size + # gymnasium.Box state space with random size test_space = Box(low=-1.0, high=1.0, shape=(3,)) reset_var = ext_speed_load.reset(state_positions=test_positions, nominal_state=test_nominal, diff --git a/tests/test_physical_systems/test_physical_systems.py b/tests/test_physical_systems/test_physical_systems.py index 264ea64d..d306a093 100644 --- a/tests/test_physical_systems/test_physical_systems.py +++ b/tests/test_physical_systems/test_physical_systems.py @@ -3,7 +3,7 @@ mock_instantiate, instantiate_dict from gym_electric_motor.physical_systems import physical_systems as ps, converters as cv, electric_motors as em,\ mechanical_loads as ml, voltage_supplies as vs, solvers as sv -from gym.spaces import Box +from gymnasium.spaces import Box import pytest diff --git a/tests/test_reference_generators/test_reference_generators.py b/tests/test_reference_generators/test_reference_generators.py index 1ea86769..3cc7b699 100644 --- a/tests/test_reference_generators/test_reference_generators.py +++ b/tests/test_reference_generators/test_reference_generators.py @@ -1,4 +1,4 @@ -import gym +import gymnasium from numpy.random import seed import numpy.random as rd import pytest @@ -196,12 +196,12 @@ def test_set_modules(self, monkeypatch, setup): sub_generator[0]._limit_margin = (1, 0) sub_generator[1]._limit_margin = (0, 0.5) - expected_space = gym.spaces.Box(-1, 0.5, shape=(1,)) + expected_space = gymnasium.spaces.Box(-1, 0.5, shape=(1,)) self._sub_generator = sub_generator test_object = SwitchedReferenceGenerator(sub_generator) self._physical_system = DummyPhysicalSystem(7) - self._physical_system._state_space = gym.spaces.Box(-1, 1, shape=self._physical_system.state_space.shape) + self._physical_system._state_space = gymnasium.spaces.Box(-1, 1, shape=self._physical_system.state_space.shape) # call function to test test_object.set_modules(self._physical_system) # verify the expected results diff --git a/tests/testing_utils.py b/tests/testing_utils.py index ff49b8bd..03cb14db 100644 --- a/tests/testing_utils.py +++ b/tests/testing_utils.py @@ -8,7 +8,7 @@ import gym_electric_motor.physical_systems.converters as cv from gym_electric_motor.physical_systems.physical_systems import SCMLSystem import numpy as np -from gym.spaces import Box, Discrete +from gymnasium.spaces import Box, Discrete from scipy.integrate import ode from tests.conf import system, jacobian, permex_motor_parameter from gym_electric_motor.utils import instantiate From 76472cfc1931f154455f1479ee0852c1dd74869e Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Sat, 6 May 2023 15:35:59 +0200 Subject: [PATCH 02/37] Working DC example Co-authored-by: KoehlerM173 --- .../classic_controllers_dc_motor_example.py | 3 +-- gym_electric_motor/core.py | 15 +++++++++++++-- gym_electric_motor/utils.py | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_example.py b/examples/classic_controllers/classic_controllers_dc_motor_example.py index ea0232b3..f64d5f68 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_example.py @@ -53,8 +53,7 @@ """ controller = Controller.make(env, external_ref_plots=external_ref_plots) - state, reference = env.reset(seed = 0, options ={}) - + state, reference = env.reset_with_next_reference() # simulate the environment for i in range(10001): action = controller.control(state, reference) diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 10607f72..2a27cd49 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -246,10 +246,21 @@ def reset(self, *_, **__): self._call_callbacks('on_reset_begin') self._done = False state = self._physical_system.reset() - reference, next_ref, trajectories = self.reference_generator.reset(state) + reference, _, _ = self.reference_generator.reset(state) self._reward_function.reset(state, reference) self._call_callbacks('on_reset_end', state, reference) - return state[self.state_filter], next_ref + return state[self.state_filter] #, next_ref + + def reset_with_next_reference(self, *_, **__): + """ + Reset of the environment and all its modules to an initial state. + + Returns: + The initial observation consisting of the initial state and initial reference. + """ + state = self.reset() + _, next_ref, _ = self.reference_generator.reset(state) + return state[self.state_filter] , next_ref def render(self, *_, **__): """ diff --git a/gym_electric_motor/utils.py b/gym_electric_motor/utils.py index 3ca0dcee..7c060908 100644 --- a/gym_electric_motor/utils.py +++ b/gym_electric_motor/utils.py @@ -19,7 +19,7 @@ def state_dict_to_state_array(state_dict, state_array, state_names): for ind, key in enumerate(state_names): try: state_array[ind] = state_dict[key] - except KeyError: + except KeyError: # TODO pass From 015d2a9345740f2448a9c95cc25fdf67a174b8af Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Sat, 6 May 2023 16:06:05 +0200 Subject: [PATCH 03/37] fixed synch motor. _dead_time doesn't exist --- .../classic_controllers_synch_motor_example.py | 2 +- .../classic_controllers/controllers/cascaded_foc_controller.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_synch_motor_example.py b/examples/classic_controllers/classic_controllers_synch_motor_example.py index 3af8f8c8..426bf477 100644 --- a/examples/classic_controllers/classic_controllers_synch_motor_example.py +++ b/examples/classic_controllers/classic_controllers_synch_motor_example.py @@ -50,7 +50,7 @@ controller = Controller.make(env, external_ref_plots=external_ref_plots, torque_control='analytical') - state, reference = env.reset() + state, reference = env.reset_with_next_reference() # simulate the environment for i in range(10001): diff --git a/examples/classic_controllers/controllers/cascaded_foc_controller.py b/examples/classic_controllers/controllers/cascaded_foc_controller.py index e3675313..80c78013 100644 --- a/examples/classic_controllers/controllers/cascaded_foc_controller.py +++ b/examples/classic_controllers/controllers/cascaded_foc_controller.py @@ -53,7 +53,7 @@ def __init__(self, environment, stages, _controllers, ref_states, external_ref_ self.mp = environment.physical_system.electrical_motor.motor_parameter self.psi_p = self.mp.get('psi_p', 0) - self.dead_time = 1.5 if environment.physical_system.converter._dead_time else 0.5 + self.dead_time = 0.5 self.decoupling = controller_kwargs.get('decoupling', True) self.ref_state_idx = [self.i_sq_idx, self.i_sd_idx] From 6b174d3aa67f56a21290b670ba81ae60ed1e4304 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Sat, 6 May 2023 16:46:10 +0200 Subject: [PATCH 04/37] fixed external plot --- examples/classic_controllers/external_plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/classic_controllers/external_plot.py b/examples/classic_controllers/external_plot.py index b28da770..850b0d61 100644 --- a/examples/classic_controllers/external_plot.py +++ b/examples/classic_controllers/external_plot.py @@ -111,7 +111,7 @@ def initialize(self, axis): # If the state is referenced plot also the reference line if self._referenced: self._reference_line, = self._axis.plot(self._x_data, self._reference_data, **self._ref_line_config, zorder=self.add_lines+1) - axis.lines = axis.lines[::-1] + #axis.lines = axis.lines[::-1] self._lines.append(self._reference_line) self._y_data = [self._state_data, self._reference_data] From c694250e36a1e63e10b35548502a0dc56cf38420 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Sat, 6 May 2023 17:06:33 +0200 Subject: [PATCH 05/37] updated all examples with new reset func --- .../classic_controllers_ind_motor_example.py | 2 +- .../custom_classic_controllers_dc_motor_example.py | 2 +- .../custom_classic_controllers_ind_motor_example.py | 2 +- .../custom_classic_controllers_synch_motor_example.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_ind_motor_example.py b/examples/classic_controllers/classic_controllers_ind_motor_example.py index 3908f10d..6d8179c1 100644 --- a/examples/classic_controllers/classic_controllers_ind_motor_example.py +++ b/examples/classic_controllers/classic_controllers_ind_motor_example.py @@ -46,7 +46,7 @@ """ controller = Controller.make(env) - state, reference = env.reset() + state, reference = env.reset_with_next_reference() # simulate the environment for i in range(10001): diff --git a/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py b/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py index 9805c669..048a7883 100644 --- a/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py @@ -69,7 +69,7 @@ controller = Controller.make(env, external_ref_plots=external_ref_plots, stages=stages) - state, reference = env.reset() + state, reference = env.reset_with_next_reference() # simulate the environment for i in range(10001): diff --git a/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py b/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py index a09b6835..125a2349 100644 --- a/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py @@ -49,7 +49,7 @@ controller = Controller.make(env, stages=stages, external_plot=external_ref_plots) - state, reference = env.reset() + state, reference = env.reset_with_next_reference() # simulate the environment for i in range(10001): diff --git a/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py b/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py index d9881a94..7c9f62eb 100644 --- a/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py @@ -100,7 +100,7 @@ controller = Controller.make(env, stages=stages, external_ref_plots=external_ref_plots, torque_control='analytical') - state, reference = env.reset() + state, reference = env.reset_with_next_reference() # simulate the environment for i in range(10001): From f5f5d2bd06347001e5bd1582bb1a3444dc334514 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Fri, 12 May 2023 11:17:13 +0200 Subject: [PATCH 06/37] fixed classic_controllers.py, custom_classic_controllers_dc_motor_example.py now runs --- .../classic_controllers/classic_controllers.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/classic_controllers/classic_controllers.py b/examples/classic_controllers/classic_controllers.py index f9db1347..425d234c 100644 --- a/examples/classic_controllers/classic_controllers.py +++ b/examples/classic_controllers/classic_controllers.py @@ -347,27 +347,27 @@ def automated_gain(environment, stages, controller_type, _controllers, **control elif _controllers[controller_type][0] == CascadedController: for i in range(len(stages)): - if _controllers[stages_a[i]['controller_type']][1] == ContinuousController: + if _controllers[stages_a[i][0]['controller_type']][1] == ContinuousController: #had to add [0] to make dict in list acessable if i == 0: p_gain = mp['l'] / (environment.physical_system.tau * a) / u_a_lim * i_a_lim i_gain = p_gain / (environment.physical_system.tau * a ** 2) - if _controllers[stages_a[i]['controller_type']][2] == PIDController: + if _controllers[stages_a[i][0]['controller_type']][2] == PIDController: d_gain = p_gain * environment.physical_system.tau - stages_a[i]['d_gain'] = stages_a[i].get('d_gain', d_gain) + stages_a[i][0]['d_gain'] = stages_a[i].get('d_gain', d_gain) elif i == 1: t_n = environment.physical_system.tau * a ** 2 p_gain = environment.physical_system.mechanical_load.j_total / ( a * t_n) / i_a_lim * omega_lim i_gain = p_gain / (a * t_n) - if _controllers[stages_a[i]['controller_type']][2] == PIDController: + if _controllers[stages_a[i][0]['controller_type']][2] == PIDController: d_gain = p_gain * environment.physical_system.tau - stages_a[i]['d_gain'] = stages_a[i].get('d_gain', d_gain) + stages_a[i][0]['d_gain'] = stages_a[i].get('d_gain', d_gain) - stages_a[i]['p_gain'] = stages_a[i].get('p_gain', p_gain) - stages_a[i]['i_gain'] = stages_a[i].get('i_gain', i_gain) + stages_a[i][0]['p_gain'] = stages_a[i][0].get('p_gain', p_gain)#? + stages_a[i][0]['i_gain'] = stages_a[i][0].get('i_gain', i_gain)#? stages = stages_a if not stages_e else [stages_a, stages_e] From 308eacb24e0ae6f7269429ac75243a6775547740 Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Fri, 12 May 2023 15:06:08 +0200 Subject: [PATCH 07/37] Needs to be evaluated later --- examples/classic_controllers/classic_controllers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/classic_controllers/classic_controllers.py b/examples/classic_controllers/classic_controllers.py index 425d234c..c4401f4c 100644 --- a/examples/classic_controllers/classic_controllers.py +++ b/examples/classic_controllers/classic_controllers.py @@ -366,8 +366,11 @@ def automated_gain(environment, stages, controller_type, _controllers, **control d_gain = p_gain * environment.physical_system.tau stages_a[i][0]['d_gain'] = stages_a[i].get('d_gain', d_gain) - stages_a[i][0]['p_gain'] = stages_a[i][0].get('p_gain', p_gain)#? - stages_a[i][0]['i_gain'] = stages_a[i][0].get('i_gain', i_gain)#? + # TODO: Remove this check after test and examples are running. Why is this here? + assert 'p_gain' in stages_a[i][0] + assert 'i_gain' in stages_a[i][0] + # stages_a[i][0]['p_gain'] = stages_a[i][0].get('p_gain', p_gain)#? + # stages_a[i][0]['i_gain'] = stages_a[i][0].get('i_gain', i_gain)#? stages = stages_a if not stages_e else [stages_a, stages_e] From ae611c682eaf45752026bdb939847dfcd3831aa0 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Sat, 13 May 2023 22:35:08 +0200 Subject: [PATCH 08/37] fixed faulty indexing in classic_controllers.py --- .../classic_controllers.py | 67 +++++++++++++------ 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/examples/classic_controllers/classic_controllers.py b/examples/classic_controllers/classic_controllers.py index 425d234c..e18b3f4b 100644 --- a/examples/classic_controllers/classic_controllers.py +++ b/examples/classic_controllers/classic_controllers.py @@ -347,27 +347,52 @@ def automated_gain(environment, stages, controller_type, _controllers, **control elif _controllers[controller_type][0] == CascadedController: for i in range(len(stages)): - if _controllers[stages_a[i][0]['controller_type']][1] == ContinuousController: #had to add [0] to make dict in list acessable - - if i == 0: - p_gain = mp['l'] / (environment.physical_system.tau * a) / u_a_lim * i_a_lim - i_gain = p_gain / (environment.physical_system.tau * a ** 2) - - if _controllers[stages_a[i][0]['controller_type']][2] == PIDController: - d_gain = p_gain * environment.physical_system.tau - stages_a[i][0]['d_gain'] = stages_a[i].get('d_gain', d_gain) - - elif i == 1: - t_n = environment.physical_system.tau * a ** 2 - p_gain = environment.physical_system.mechanical_load.j_total / ( - a * t_n) / i_a_lim * omega_lim - i_gain = p_gain / (a * t_n) - if _controllers[stages_a[i][0]['controller_type']][2] == PIDController: - d_gain = p_gain * environment.physical_system.tau - stages_a[i][0]['d_gain'] = stages_a[i].get('d_gain', d_gain) - - stages_a[i][0]['p_gain'] = stages_a[i][0].get('p_gain', p_gain)#? - stages_a[i][0]['i_gain'] = stages_a[i][0].get('i_gain', i_gain)#? + if type(stages_a[i]) is list: + if _controllers[stages_a[i][0]['controller_type']][1] == ContinuousController: #had to add [0] to make dict in list acessable + + if i == 0: + p_gain = mp['l'] / (environment.physical_system.tau * a) / u_a_lim * i_a_lim + i_gain = p_gain / (environment.physical_system.tau * a ** 2) + + if _controllers[stages_a[i][0]['controller_type']][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages_a[i][0]['d_gain'] = stages_a[i][0].get('d_gain', d_gain) + + elif i == 1: + t_n = environment.physical_system.tau * a ** 2 + p_gain = environment.physical_system.mechanical_load.j_total / ( + a * t_n) / i_a_lim * omega_lim + i_gain = p_gain / (a * t_n) + if _controllers[stages_a[i][0]['controller_type']][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages_a[i][0]['d_gain'] = stages_a[i][0].get('d_gain', d_gain) + + stages_a[i][0]['p_gain'] = stages_a[i][0].get('p_gain', p_gain)#? + stages_a[i][0]['i_gain'] = stages_a[i][0].get('i_gain', i_gain)#? + + elif type(stages_a[i]) is dict: + if _controllers[stages_a[i]['controller_type']][1] == ContinuousController: #had to add [0] to make dict in list acessable + + if i == 0: + p_gain = mp['l'] / (environment.physical_system.tau * a) / u_a_lim * i_a_lim + i_gain = p_gain / (environment.physical_system.tau * a ** 2) + + if _controllers[stages_a[i]['controller_type']][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages_a[i]['d_gain'] = stages_a[i].get('d_gain', d_gain) + + elif i == 1: + t_n = environment.physical_system.tau * a ** 2 + p_gain = environment.physical_system.mechanical_load.j_total / ( + a * t_n) / i_a_lim * omega_lim + i_gain = p_gain / (a * t_n) + if _controllers[stages_a[i]['controller_type']][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages_a[i]['d_gain'] = stages_a[i].get('d_gain', d_gain) + + stages_a[i]['p_gain'] = stages_a[i].get('p_gain', p_gain)#? + stages_a[i]['i_gain'] = stages_a[i].get('i_gain', i_gain)#? + stages = stages_a if not stages_e else [stages_a, stages_e] From 9300b9e1b17a778f8cbd0964b2ddaa0a8e2f1e73 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Fri, 26 May 2023 14:38:17 +0200 Subject: [PATCH 09/37] reverted unwanted changes --- .../classic_controllers.py | 553 ------------------ 1 file changed, 553 deletions(-) diff --git a/examples/classic_controllers/classic_controllers.py b/examples/classic_controllers/classic_controllers.py index a1af5589..e69de29b 100644 --- a/examples/classic_controllers/classic_controllers.py +++ b/examples/classic_controllers/classic_controllers.py @@ -1,553 +0,0 @@ -from gymnasium.spaces import Discrete, Box, MultiDiscrete -from gym_electric_motor.physical_systems import SynchronousMotorSystem, DcMotorSystem, DcSeriesMotor, \ - DcExternallyExcitedMotor, DoublyFedInductionMotorSystem, SquirrelCageInductionMotorSystem -from gym_electric_motor.reference_generators import MultipleReferenceGenerator, SwitchedReferenceGenerator -from gym_electric_motor.visualization import MotorDashboard -from gym_electric_motor import envs - -from controllers.continuous_controller import ContinuousController -from controllers.pi_controller import PIController -from controllers.pid_controller import PIDController - -from controllers.discrete_controller import DiscreteController -from controllers.on_off_controller import OnOffController -from controllers.three_point_controller import ThreePointController - -from controllers.continuous_action_controller import ContinuousActionController -from controllers.dicrete_action_controller import DiscreteActionController -from controllers.cascaded_controller import CascadedController -from controllers.foc_controller import FieldOrientedController -from controllers.cascaded_foc_controller import CascadedFieldOrientedController -from controllers.induction_motor_foc import InductionMotorFieldOrientedController -from controllers.induction_motor_cascaded_foc import InductionMotorCascadedFieldOrientedController - -from externally_referenced_state_plot import ExternallyReferencedStatePlot -from external_plot import ExternalPlot - -import numpy as np - -class Controller: - """This is the base class for every controller along with the motor environments.""" - - @classmethod - def make(cls, environment, stages=None, **controller_kwargs): - """ - This function creates the controller structure and optionally tunes the controller. - - Args: - environment: gym-electric-motor environment to be controlled - stages: stages of the controller, if no stages are passed, the controller is automatically designed und tuned - **controller_kwargs: setting parameters for the controller and visualization - - Returns: - fully designed controller for the control of the gym-electric-motor environment, which is called using the - control function - the inputs of the control function are the state and the reference, both are given by the environment - - """ - - _controllers = { - 'pi_controller': [ContinuousActionController, ContinuousController, PIController], - 'pid_controller': [ContinuousActionController, ContinuousController, PIDController], - 'on_off': [DiscreteActionController, DiscreteController, OnOffController], - 'three_point': [DiscreteActionController, DiscreteController, ThreePointController], - 'cascaded_controller': [CascadedController], - 'foc_controller': [FieldOrientedController], - 'cascaded_foc_controller': [CascadedFieldOrientedController], - 'foc_rotor_flux_observer': [InductionMotorFieldOrientedController], - 'cascaded_foc_rotor_flux_observer': [InductionMotorCascadedFieldOrientedController], - } - controller_kwargs = cls.reference_states(environment, **controller_kwargs) - controller_kwargs = cls.get_visualization(environment, **controller_kwargs) - - if stages is not None: - controller_type, stages = cls.find_controller_type(environment, stages, **controller_kwargs) - assert controller_type in _controllers.keys(), f'Controller {controller_type} unknown' - stages = cls.automated_gain(environment, stages, controller_type, _controllers, **controller_kwargs) - controller = _controllers[controller_type][0](environment, stages, _controllers, **controller_kwargs) - - else: - controller_type, stages = cls.automated_controller_design(environment, **controller_kwargs) - stages = cls.automated_gain(environment, stages, controller_type, _controllers, **controller_kwargs) - controller = _controllers[controller_type][0](environment, stages, _controllers, **controller_kwargs) - return controller - - @staticmethod - def get_visualization(environment, **controller_kwargs): - """This method separates external_plots and external_ref_plots. It also checks if a MotorDashboard is used.""" - if 'external_plot' in controller_kwargs.keys(): - ext_plot = [] - ref_plot = [] - for external_plots in controller_kwargs['external_plot']: - if isinstance(external_plots, ExternalPlot): - ext_plot.append(external_plots) - elif isinstance(external_plots, ExternallyReferencedStatePlot): - ref_plot.append(external_plots) - controller_kwargs['external_plot'] = ext_plot - controller_kwargs['external_ref_plots'] = ref_plot - - for visualization in environment.visualizations: - if isinstance(visualization, MotorDashboard): - controller_kwargs['update_interval'] = visualization.update_interval - controller_kwargs['visualization'] = True - return controller_kwargs - controller_kwargs['visualization'] = False - return controller_kwargs - - @staticmethod - def reference_states(environment, **controller_kwargs): - """This method searches the environment for all referenced states and writes them to an array.""" - ref_states = [] - if isinstance(environment.reference_generator, MultipleReferenceGenerator): - - for rg in environment.reference_generator._sub_generators: - if isinstance(rg, SwitchedReferenceGenerator): - ref_states.append(rg._sub_generators[0]._reference_state) - else: - ref_states.append(rg._reference_state) - - elif isinstance(environment.reference_generator, SwitchedReferenceGenerator): - ref_states.append(environment.reference_generator._sub_generators[0]._reference_state) - else: - ref_states.append(environment.reference_generator._reference_state) - controller_kwargs['ref_states'] = np.array(ref_states) - return controller_kwargs - - @staticmethod - def find_controller_type(environment, stages, **controller_kwargs): - _stages = stages - - if isinstance(environment.physical_system.unwrapped, DcMotorSystem): - if type(stages) is list: - if len(stages) > 1: - if type(stages[0]) is list: - stages = stages[0] - if len(stages) > 1: - controller_type = 'cascaded_controller' - else: - controller_type = stages[0]['controller_type'] - else: - controller_type = stages[0]['controller_type'] - else: - if type(stages) is dict: - controller_type = stages['controller_type'] - _stages = [stages] - else: - controller_type = stages - _stages = [{'controller_type': stages}] - elif isinstance(environment.physical_system.unwrapped, SynchronousMotorSystem): - if len(stages) == 2: - if len(stages[1]) == 1 and 'i_sq' in controller_kwargs['ref_states']: - controller_type = 'foc_controller' - else: - controller_type = 'cascaded_foc_controller' - else: - controller_type = 'cascaded_foc_controller' - - elif isinstance(environment.physical_system.unwrapped, SquirrelCageInductionMotorSystem): - if len(stages) == 2: - if len(stages[1]) == 1 and 'i_sq' in controller_kwargs['ref_states']: - controller_type = 'foc_rotor_flux_observer' - else: - controller_type = 'cascaded_foc_rotor_flux_observer' - else: - controller_type = 'cascaded_foc_rotor_flux_observer' - - elif isinstance(environment.physical_system.unwrapped, DoublyFedInductionMotorSystem): - if len(stages) == 2: - if len(stages[1]) == 1 and 'i_sq' in controller_kwargs['ref_states']: - controller_type = 'foc_rotor_flux_observer' - else: - controller_type = 'cascaded_foc_rotor_flux_observer' - else: - controller_type = 'cascaded_foc_rotor_flux_observer' - - return controller_type, _stages - - @staticmethod - def automated_controller_design(environment, **controller_kwargs): - """This method automatically designs the controller based on the given motor environment and control task.""" - - action_space_type = type(environment.action_space) - ref_states = controller_kwargs['ref_states'] - stages = [] - if isinstance(environment.physical_system.unwrapped, DcMotorSystem): # Checking type of motor - - if 'omega' in ref_states or 'torque' in ref_states: # Checking control task - controller_type = 'cascaded_controller' - - for i in range(len(stages), 2): - if i == 0: - if action_space_type is Box: # Checking type of output stage (finite / cont) - stages.append({'controller_type': 'pi_controller'}) - else: - stages.append({'controller_type': 'three_point'}) - else: - stages.append({'controller_type': 'pi_controller'}) # Adding PI-Controller for overlaid stages - - elif 'i' in ref_states or 'i_a' in ref_states: - # Checking type of output stage (finite / cont) - if action_space_type is Discrete or action_space_type is MultiDiscrete: - stages.append({'controller_type': 'three_point'}) - elif action_space_type is Box: - stages.append({'controller_type': 'pi_controller'}) - controller_type = stages[0]['controller_type'] - - # Add stage for i_e current of the ExtExDC - if isinstance(environment.physical_system.electrical_motor, DcExternallyExcitedMotor): - if action_space_type is Box: - stages = [stages, [{'controller_type': 'pi_controller'}]] - else: - stages = [stages, [{'controller_type': 'three_point'}]] - - elif isinstance(environment.physical_system.unwrapped, SynchronousMotorSystem): - if 'i_sq' in ref_states or 'torque' in ref_states: # Checking control task - controller_type = 'foc_controller' if 'i_sq' in ref_states else 'cascaded_foc_controller' - if action_space_type is Discrete: - stages = [[{'controller_type': 'on_off'}], [{'controller_type': 'on_off'}], - [{'controller_type': 'on_off'}]] - else: - stages = [[{'controller_type': 'pi_controller'}, {'controller_type': 'pi_controller'}]] - elif 'omega' in ref_states: - controller_type = 'cascaded_foc_controller' - if action_space_type is Discrete: - stages = [[{'controller_type': 'on_off'}], [{'controller_type': 'on_off'}], - [{'controller_type': 'on_off'}], [{'controller_type': 'pi_controller'}]] - else: - stages = [[{'controller_type': 'pi_controller'}, - {'controller_type': 'pi_controller'}], [{'controller_type': 'pi_controller'}]] - - elif isinstance(environment.physical_system.unwrapped, (SquirrelCageInductionMotorSystem, DoublyFedInductionMotorSystem)): - if 'i_sq' in ref_states or 'torque' in ref_states: - controller_type = 'foc_rotor_flux_observer' if 'i_sq' in ref_states else 'cascaded_foc_rotor_flux_observer' - if action_space_type is Discrete: - stages = [[{'controller_type': 'on_off'}], [{'controller_type': 'on_off'}], - [{'controller_type': 'on_off'}]] - else: - stages = [[{'controller_type': 'pi_controller'}, {'controller_type': 'pi_controller'}]] - elif 'omega' in ref_states: - controller_type = 'cascaded_foc_rotor_flux_observer' - if action_space_type is Discrete: - stages = [[{'controller_type': 'on_off'}], [{'controller_type': 'on_off'}], - [{'controller_type': 'on_off'}], [{'controller_type': 'pi_controller'}]] - else: - stages = [[{'controller_type': 'pi_controller'}, - {'controller_type': 'pi_controller'}], [{'controller_type': 'pi_controller'}]] - else: - controller_type = 'foc_controller' - - return controller_type, stages - - @staticmethod - def automated_gain(environment, stages, controller_type, _controllers, **controller_kwargs): - """ - This method automatically parameterizes a given controller design if the parameter automated_gain is True - (default True), based on the design according to the symmetric optimum (SO). Further information about the - design according to the SO can be found in the following paper (https://ieeexplore.ieee.org/document/55967). - - Args: - environment: gym-electric-motor environment - stages: list of the stages of the controller - controller_type: string of the used controller type from the dictionary _controllers - _controllers: dictionary of all possible controllers and controller stages - controller_kwargs: further arguments of the controller - - Returns: - list of stages, which are completely parameterized - """ - - ref_states = controller_kwargs['ref_states'] - mp = environment.physical_system.electrical_motor.motor_parameter - limits = environment.physical_system.limits - omega_lim = limits[environment.state_names.index('omega')] - if isinstance(environment.physical_system.unwrapped, DcMotorSystem): - i_a_lim = limits[environment.physical_system.CURRENTS_IDX[0]] - i_e_lim = limits[environment.physical_system.CURRENTS_IDX[-1]] - u_a_lim = limits[environment.physical_system.VOLTAGES_IDX[0]] - u_e_lim = limits[environment.physical_system.VOLTAGES_IDX[-1]] - - elif isinstance(environment.physical_system.unwrapped, SynchronousMotorSystem): - i_sd_lim = limits[environment.state_names.index('i_sd')] - i_sq_lim = limits[environment.state_names.index('i_sq')] - u_sd_lim = limits[environment.state_names.index('u_sd')] - u_sq_lim = limits[environment.state_names.index('u_sq')] - torque_lim = limits[environment.state_names.index('torque')] - - else: - i_sd_lim = limits[environment.state_names.index('i_sd')] - i_sq_lim = limits[environment.state_names.index('i_sq')] - u_sd_lim = limits[environment.state_names.index('u_sd')] - u_sq_lim = limits[environment.state_names.index('u_sq')] - torque_lim = limits[environment.state_names.index('torque')] - - # The parameter a is a design parameter when designing a controller according to the SO - a = controller_kwargs.get('a', 4) - automated_gain = controller_kwargs.get('automated_gain', True) - - if isinstance(environment.physical_system.electrical_motor, DcSeriesMotor): - mp['l'] = mp['l_a'] + mp['l_e'] - elif isinstance(environment.physical_system.unwrapped, DcMotorSystem): - mp['l'] = mp['l_a'] - - if 'automated_gain' not in controller_kwargs.keys() or automated_gain: - cont_extex_envs = ( - envs.ContSpeedControlDcExternallyExcitedMotorEnv, - envs.ContCurrentControlDcExternallyExcitedMotorEnv, - envs.ContTorqueControlDcExternallyExcitedMotorEnv - ) - finite_extex_envs = ( - envs.FiniteTorqueControlDcExternallyExcitedMotorEnv, - envs.FiniteSpeedControlDcExternallyExcitedMotorEnv, - envs.FiniteCurrentControlDcExternallyExcitedMotorEnv - ) - if type(environment) in cont_extex_envs: - stages_a = stages[0] - stages_e = stages[1] - - p_gain = mp['l_e'] / (environment.physical_system.tau * a) / u_e_lim * i_e_lim - i_gain = p_gain / (environment.physical_system.tau * a ** 2) - - stages_e[0]['p_gain'] = stages_e[0].get('p_gain', p_gain) - stages_e[0]['i_gain'] = stages_e[0].get('i_gain', i_gain) - - if stages_e[0]['controller_type'] == PIDController: - d_gain = p_gain * environment.physical_system.tau - stages_e[0]['d_gain'] = stages_e[0].get('d_gain', d_gain) - elif type(environment) in finite_extex_envs: - stages_a = stages[0] - stages_e = stages[1] - else: - stages_a = stages - stages_e = False - - if _controllers[controller_type][0] == ContinuousActionController: - if 'i' in ref_states or 'i_a' in ref_states or 'torque' in ref_states: - p_gain = mp['l'] / (environment.physical_system.tau * a) / u_a_lim * i_a_lim - i_gain = p_gain / (environment.physical_system.tau * a ** 2) - - stages_a[0]['p_gain'] = stages_a[0].get('p_gain', p_gain) - stages_a[0]['i_gain'] = stages_a[0].get('i_gain', i_gain) - - if _controllers[controller_type][2] == PIDController: - d_gain = p_gain * environment.physical_system.tau - stages_a[0]['d_gain'] = stages_a[0].get('d_gain', d_gain) - - elif 'omega' in ref_states: - p_gain = environment.physical_system.mechanical_load.j_total * mp['r_a'] ** 2 / ( - a * mp['l']) / u_a_lim * omega_lim - i_gain = p_gain / (a * mp['l']) - - stages_a[0]['p_gain'] = stages_a[0].get('p_gain', p_gain) - stages_a[0]['i_gain'] = stages_a[0].get('i_gain', i_gain) - - if _controllers[controller_type][2] == PIDController: - d_gain = p_gain * environment.physical_system.tau - stages_a[0]['d_gain'] = stages_a[0].get('d_gain', d_gain) - - elif _controllers[controller_type][0] == CascadedController: - - for i in range(len(stages)): - if type(stages_a[i]) is list: - if _controllers[stages_a[i][0]['controller_type']][1] == ContinuousController: #had to add [0] to make dict in list acessable - - if i == 0: - p_gain = mp['l'] / (environment.physical_system.tau * a) / u_a_lim * i_a_lim - i_gain = p_gain / (environment.physical_system.tau * a ** 2) - - if _controllers[stages_a[i][0]['controller_type']][2] == PIDController: - d_gain = p_gain * environment.physical_system.tau - stages_a[i][0]['d_gain'] = stages_a[i][0].get('d_gain', d_gain) - - elif i == 1: - t_n = environment.physical_system.tau * a ** 2 - p_gain = environment.physical_system.mechanical_load.j_total / ( - a * t_n) / i_a_lim * omega_lim - i_gain = p_gain / (a * t_n) - if _controllers[stages_a[i][0]['controller_type']][2] == PIDController: - d_gain = p_gain * environment.physical_system.tau - stages_a[i][0]['d_gain'] = stages_a[i][0].get('d_gain', d_gain) - - # TODO: Remove this check after test and examples are running. Why is this here? - assert 'p_gain' in stages_a[i][0] - assert 'i_gain' in stages_a[i][0] - # stages_a[i][0]['p_gain'] = stages_a[i][0].get('p_gain', p_gain)#? - # stages_a[i][0]['i_gain'] = stages_a[i][0].get('i_gain', i_gain)#? - - elif type(stages_a[i]) is dict: - if _controllers[stages_a[i]['controller_type']][1] == ContinuousController: #had to add [0] to make dict in list acessable - - if i == 0: - p_gain = mp['l'] / (environment.physical_system.tau * a) / u_a_lim * i_a_lim - i_gain = p_gain / (environment.physical_system.tau * a ** 2) - - if _controllers[stages_a[i]['controller_type']][2] == PIDController: - d_gain = p_gain * environment.physical_system.tau - stages_a[i]['d_gain'] = stages_a[i].get('d_gain', d_gain) - - elif i == 1: - t_n = environment.physical_system.tau * a ** 2 - p_gain = environment.physical_system.mechanical_load.j_total / ( - a * t_n) / i_a_lim * omega_lim - i_gain = p_gain / (a * t_n) - if _controllers[stages_a[i]['controller_type']][2] == PIDController: - d_gain = p_gain * environment.physical_system.tau - stages_a[i]['d_gain'] = stages_a[i].get('d_gain', d_gain) - - stages_a[i]['p_gain'] = stages_a[i].get('p_gain', p_gain)#? - stages_a[i]['i_gain'] = stages_a[i].get('i_gain', i_gain)#? - - - stages = stages_a if not stages_e else [stages_a, stages_e] - - elif _controllers[controller_type][0] == FieldOrientedController: - if type(environment.action_space) == Box: - stage_d = stages[0][0] - stage_q = stages[0][1] - if 'i_sq' in ref_states and _controllers[stage_q['controller_type']][1] == ContinuousController: - p_gain_d = mp['l_d'] / (1.5 * environment.physical_system.tau * a) / u_sd_lim * i_sd_lim - i_gain_d = p_gain_d / (1.5 * environment.physical_system.tau * a ** 2) - - p_gain_q = mp['l_q'] / (1.5 * environment.physical_system.tau * a) / u_sq_lim * i_sq_lim - i_gain_q = p_gain_q / (1.5 * environment.physical_system.tau * a ** 2) - - stage_d['p_gain'] = stage_d.get('p_gain', p_gain_d) - stage_d['i_gain'] = stage_d.get('i_gain', i_gain_d) - - stage_q['p_gain'] = stage_q.get('p_gain', p_gain_q) - stage_q['i_gain'] = stage_q.get('i_gain', i_gain_q) - - if _controllers[stage_d['controller_type']][2] == PIDController: - d_gain_d = p_gain_d * environment.physical_system.tau - stage_d['d_gain'] = stage_d.get('d_gain', d_gain_d) - - if _controllers[stage_q['controller_type']][2] == PIDController: - d_gain_q = p_gain_q * environment.physical_system.tau - stage_q['d_gain'] = stage_q.get('d_gain', d_gain_q) - stages = [[stage_d, stage_q]] - - elif _controllers[controller_type][0] == CascadedFieldOrientedController: - if type(environment.action_space) is Box: - stage_d = stages[0][0] - stage_q = stages[0][1] - if 'torque' not in controller_kwargs['ref_states']: - overlaid = stages[1] - - p_gain_d = mp['l_d'] / (1.5 * environment.physical_system.tau * a) / u_sd_lim * i_sd_lim - i_gain_d = p_gain_d / (1.5 * environment.physical_system.tau * a ** 2) - - p_gain_q = mp['l_q'] / (1.5 * environment.physical_system.tau * a) / u_sq_lim * i_sq_lim - i_gain_q = p_gain_q / (1.5 * environment.physical_system.tau * a ** 2) - - stage_d['p_gain'] = stage_d.get('p_gain', p_gain_d) - stage_d['i_gain'] = stage_d.get('i_gain', i_gain_d) - - stage_q['p_gain'] = stage_q.get('p_gain', p_gain_q) - stage_q['i_gain'] = stage_q.get('i_gain', i_gain_q) - - if _controllers[stage_d['controller_type']][2] == PIDController: - d_gain_d = p_gain_d * environment.physical_system.tau - stage_d['d_gain'] = stage_d.get('d_gain', d_gain_d) - - if _controllers[stage_q['controller_type']][2] == PIDController: - d_gain_q = p_gain_q * environment.physical_system.tau - stage_q['d_gain'] = stage_q.get('d_gain', d_gain_q) - - if 'torque' not in controller_kwargs['ref_states'] and \ - _controllers[overlaid[0]['controller_type']][1] == ContinuousController: - t_n = p_gain_d / i_gain_d - j_total = environment.physical_system.mechanical_load.j_total - p_gain = j_total / (a ** 2 * t_n) / torque_lim * omega_lim - i_gain = p_gain / (a * t_n) - - overlaid[0]['p_gain'] = overlaid[0].get('p_gain', p_gain) - overlaid[0]['i_gain'] = overlaid[0].get('i_gain', i_gain) - - if _controllers[overlaid[0]['controller_type']][2] == PIDController: - d_gain = p_gain * environment.physical_system.tau - overlaid[0]['d_gain'] = overlaid[0].get('d_gain', d_gain) - - stages = [[stage_d, stage_q], overlaid] - - else: - stages = [[stage_d, stage_q]] - - else: - if 'omega' in ref_states and _controllers[stages[3][0]['controller_type']][1] == ContinuousController: - - p_gain = environment.physical_system.mechanical_load.j_total / ( - 1.5 * a ** 2 * mp['p'] * np.abs(mp['l_d'] - mp['l_q'])) / i_sq_lim * omega_lim - i_gain = p_gain / (1.5 * environment.physical_system.tau * a) - - stages[3][0]['p_gain'] = stages[3][0].get('p_gain', p_gain) - stages[3][0]['i_gain'] = stages[3][0].get('i_gain', i_gain) - - if _controllers[stages[3][0]['controller_type']][2] == PIDController: - d_gain = p_gain * environment.physical_system.tau - stages[3][0]['d_gain'] = stages[3][0].get('d_gain', d_gain) - - elif _controllers[controller_type][0] == InductionMotorFieldOrientedController: - - mp['l_s'] = mp['l_m'] + mp['l_sigs'] - mp['l_r'] = mp['l_m'] + mp['l_sigr'] - sigma = (mp['l_s'] * mp['l_r'] - mp['l_m'] ** 2) / (mp['l_s'] * mp['l_r']) - tau_sigma = (sigma * mp['l_s']) / (mp['r_s'] + mp['r_r'] * mp['l_m'] ** 2 / mp['l_r'] ** 2) - tau_r = mp['l_r'] / mp['r_r'] - p_gain = tau_r / tau_sigma - i_gain = p_gain / tau_sigma - - stages[0][0]['p_gain'] = stages[0][0].get('p_gain', p_gain) - stages[0][0]['i_gain'] = stages[0][0].get('i_gain', i_gain) - stages[0][1]['p_gain'] = stages[0][1].get('p_gain', p_gain) - stages[0][1]['i_gain'] = stages[0][1].get('i_gain', i_gain) - - if _controllers[stages[0][0]['controller_type']][2] == PIDController: - d_gain = p_gain * tau_sigma - stages[0][0]['d_gain'] = stages[0][0].get('d_gain', d_gain) - - if _controllers[stages[0][1]['controller_type']][2] == PIDController: - d_gain = p_gain * tau_sigma - stages[0][1]['d_gain'] = stages[0][1].get('d_gain', d_gain) - - elif _controllers[controller_type][0] == InductionMotorCascadedFieldOrientedController: - - if 'torque' not in controller_kwargs['ref_states']: - overlaid = stages[1] - - mp['l_s'] = mp['l_m'] + mp['l_sigs'] - mp['l_r'] = mp['l_m'] + mp['l_sigr'] - sigma = (mp['l_s'] * mp['l_r'] - mp['l_m'] ** 2) / (mp['l_s'] * mp['l_r']) - tau_sigma = (sigma * mp['l_s']) / (mp['r_s'] + mp['r_r'] * mp['l_m'] ** 2 / mp['l_r'] ** 2) - tau_r = mp['l_r'] / mp['r_r'] - p_gain = tau_r / tau_sigma - i_gain = p_gain / tau_sigma - - stages[0][0]['p_gain'] = stages[0][0].get('p_gain', p_gain) - stages[0][0]['i_gain'] = stages[0][0].get('i_gain', i_gain) - stages[0][1]['p_gain'] = stages[0][1].get('p_gain', p_gain) - stages[0][1]['i_gain'] = stages[0][1].get('i_gain', i_gain) - - if _controllers[stages[0][0]['controller_type']][2] == PIDController: - d_gain = p_gain * tau_sigma - stages[0][0]['d_gain'] = stages[0][0].get('d_gain', d_gain) - - if _controllers[stages[0][1]['controller_type']][2] == PIDController: - d_gain = p_gain * tau_sigma - stages[0][1]['d_gain'] = stages[0][1].get('d_gain', d_gain) - - if 'torque' not in controller_kwargs['ref_states'] and \ - _controllers[overlaid[0]['controller_type']][1] == ContinuousController: - t_n = p_gain / i_gain - j_total = environment.physical_system.mechanical_load.j_total - p_gain = j_total / (a ** 2 * t_n) / torque_lim * omega_lim - i_gain = p_gain / (a * t_n) - - overlaid[0]['p_gain'] = overlaid[0].get('p_gain', p_gain) - overlaid[0]['i_gain'] = overlaid[0].get('i_gain', i_gain) - - if _controllers[overlaid[0]['controller_type']][2] == PIDController: - d_gain = p_gain * environment.physical_system.tau - overlaid[0]['d_gain'] = overlaid[0].get('d_gain', d_gain) - - stages = [stages[0], overlaid] - - return stages From 78dcadcdabbb70d8d821c6e57fdf43ea879c9ebb Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Fri, 26 May 2023 14:49:58 +0200 Subject: [PATCH 10/37] realy reverted unwanted changes --- .../classic_controllers.py | 550 ++++++++++++++++++ 1 file changed, 550 insertions(+) diff --git a/examples/classic_controllers/classic_controllers.py b/examples/classic_controllers/classic_controllers.py index e69de29b..e18b3f4b 100644 --- a/examples/classic_controllers/classic_controllers.py +++ b/examples/classic_controllers/classic_controllers.py @@ -0,0 +1,550 @@ +from gymnasium.spaces import Discrete, Box, MultiDiscrete +from gym_electric_motor.physical_systems import SynchronousMotorSystem, DcMotorSystem, DcSeriesMotor, \ + DcExternallyExcitedMotor, DoublyFedInductionMotorSystem, SquirrelCageInductionMotorSystem +from gym_electric_motor.reference_generators import MultipleReferenceGenerator, SwitchedReferenceGenerator +from gym_electric_motor.visualization import MotorDashboard +from gym_electric_motor import envs + +from controllers.continuous_controller import ContinuousController +from controllers.pi_controller import PIController +from controllers.pid_controller import PIDController + +from controllers.discrete_controller import DiscreteController +from controllers.on_off_controller import OnOffController +from controllers.three_point_controller import ThreePointController + +from controllers.continuous_action_controller import ContinuousActionController +from controllers.dicrete_action_controller import DiscreteActionController +from controllers.cascaded_controller import CascadedController +from controllers.foc_controller import FieldOrientedController +from controllers.cascaded_foc_controller import CascadedFieldOrientedController +from controllers.induction_motor_foc import InductionMotorFieldOrientedController +from controllers.induction_motor_cascaded_foc import InductionMotorCascadedFieldOrientedController + +from externally_referenced_state_plot import ExternallyReferencedStatePlot +from external_plot import ExternalPlot + +import numpy as np + +class Controller: + """This is the base class for every controller along with the motor environments.""" + + @classmethod + def make(cls, environment, stages=None, **controller_kwargs): + """ + This function creates the controller structure and optionally tunes the controller. + + Args: + environment: gym-electric-motor environment to be controlled + stages: stages of the controller, if no stages are passed, the controller is automatically designed und tuned + **controller_kwargs: setting parameters for the controller and visualization + + Returns: + fully designed controller for the control of the gym-electric-motor environment, which is called using the + control function + the inputs of the control function are the state and the reference, both are given by the environment + + """ + + _controllers = { + 'pi_controller': [ContinuousActionController, ContinuousController, PIController], + 'pid_controller': [ContinuousActionController, ContinuousController, PIDController], + 'on_off': [DiscreteActionController, DiscreteController, OnOffController], + 'three_point': [DiscreteActionController, DiscreteController, ThreePointController], + 'cascaded_controller': [CascadedController], + 'foc_controller': [FieldOrientedController], + 'cascaded_foc_controller': [CascadedFieldOrientedController], + 'foc_rotor_flux_observer': [InductionMotorFieldOrientedController], + 'cascaded_foc_rotor_flux_observer': [InductionMotorCascadedFieldOrientedController], + } + controller_kwargs = cls.reference_states(environment, **controller_kwargs) + controller_kwargs = cls.get_visualization(environment, **controller_kwargs) + + if stages is not None: + controller_type, stages = cls.find_controller_type(environment, stages, **controller_kwargs) + assert controller_type in _controllers.keys(), f'Controller {controller_type} unknown' + stages = cls.automated_gain(environment, stages, controller_type, _controllers, **controller_kwargs) + controller = _controllers[controller_type][0](environment, stages, _controllers, **controller_kwargs) + + else: + controller_type, stages = cls.automated_controller_design(environment, **controller_kwargs) + stages = cls.automated_gain(environment, stages, controller_type, _controllers, **controller_kwargs) + controller = _controllers[controller_type][0](environment, stages, _controllers, **controller_kwargs) + return controller + + @staticmethod + def get_visualization(environment, **controller_kwargs): + """This method separates external_plots and external_ref_plots. It also checks if a MotorDashboard is used.""" + if 'external_plot' in controller_kwargs.keys(): + ext_plot = [] + ref_plot = [] + for external_plots in controller_kwargs['external_plot']: + if isinstance(external_plots, ExternalPlot): + ext_plot.append(external_plots) + elif isinstance(external_plots, ExternallyReferencedStatePlot): + ref_plot.append(external_plots) + controller_kwargs['external_plot'] = ext_plot + controller_kwargs['external_ref_plots'] = ref_plot + + for visualization in environment.visualizations: + if isinstance(visualization, MotorDashboard): + controller_kwargs['update_interval'] = visualization.update_interval + controller_kwargs['visualization'] = True + return controller_kwargs + controller_kwargs['visualization'] = False + return controller_kwargs + + @staticmethod + def reference_states(environment, **controller_kwargs): + """This method searches the environment for all referenced states and writes them to an array.""" + ref_states = [] + if isinstance(environment.reference_generator, MultipleReferenceGenerator): + + for rg in environment.reference_generator._sub_generators: + if isinstance(rg, SwitchedReferenceGenerator): + ref_states.append(rg._sub_generators[0]._reference_state) + else: + ref_states.append(rg._reference_state) + + elif isinstance(environment.reference_generator, SwitchedReferenceGenerator): + ref_states.append(environment.reference_generator._sub_generators[0]._reference_state) + else: + ref_states.append(environment.reference_generator._reference_state) + controller_kwargs['ref_states'] = np.array(ref_states) + return controller_kwargs + + @staticmethod + def find_controller_type(environment, stages, **controller_kwargs): + _stages = stages + + if isinstance(environment.physical_system.unwrapped, DcMotorSystem): + if type(stages) is list: + if len(stages) > 1: + if type(stages[0]) is list: + stages = stages[0] + if len(stages) > 1: + controller_type = 'cascaded_controller' + else: + controller_type = stages[0]['controller_type'] + else: + controller_type = stages[0]['controller_type'] + else: + if type(stages) is dict: + controller_type = stages['controller_type'] + _stages = [stages] + else: + controller_type = stages + _stages = [{'controller_type': stages}] + elif isinstance(environment.physical_system.unwrapped, SynchronousMotorSystem): + if len(stages) == 2: + if len(stages[1]) == 1 and 'i_sq' in controller_kwargs['ref_states']: + controller_type = 'foc_controller' + else: + controller_type = 'cascaded_foc_controller' + else: + controller_type = 'cascaded_foc_controller' + + elif isinstance(environment.physical_system.unwrapped, SquirrelCageInductionMotorSystem): + if len(stages) == 2: + if len(stages[1]) == 1 and 'i_sq' in controller_kwargs['ref_states']: + controller_type = 'foc_rotor_flux_observer' + else: + controller_type = 'cascaded_foc_rotor_flux_observer' + else: + controller_type = 'cascaded_foc_rotor_flux_observer' + + elif isinstance(environment.physical_system.unwrapped, DoublyFedInductionMotorSystem): + if len(stages) == 2: + if len(stages[1]) == 1 and 'i_sq' in controller_kwargs['ref_states']: + controller_type = 'foc_rotor_flux_observer' + else: + controller_type = 'cascaded_foc_rotor_flux_observer' + else: + controller_type = 'cascaded_foc_rotor_flux_observer' + + return controller_type, _stages + + @staticmethod + def automated_controller_design(environment, **controller_kwargs): + """This method automatically designs the controller based on the given motor environment and control task.""" + + action_space_type = type(environment.action_space) + ref_states = controller_kwargs['ref_states'] + stages = [] + if isinstance(environment.physical_system.unwrapped, DcMotorSystem): # Checking type of motor + + if 'omega' in ref_states or 'torque' in ref_states: # Checking control task + controller_type = 'cascaded_controller' + + for i in range(len(stages), 2): + if i == 0: + if action_space_type is Box: # Checking type of output stage (finite / cont) + stages.append({'controller_type': 'pi_controller'}) + else: + stages.append({'controller_type': 'three_point'}) + else: + stages.append({'controller_type': 'pi_controller'}) # Adding PI-Controller for overlaid stages + + elif 'i' in ref_states or 'i_a' in ref_states: + # Checking type of output stage (finite / cont) + if action_space_type is Discrete or action_space_type is MultiDiscrete: + stages.append({'controller_type': 'three_point'}) + elif action_space_type is Box: + stages.append({'controller_type': 'pi_controller'}) + controller_type = stages[0]['controller_type'] + + # Add stage for i_e current of the ExtExDC + if isinstance(environment.physical_system.electrical_motor, DcExternallyExcitedMotor): + if action_space_type is Box: + stages = [stages, [{'controller_type': 'pi_controller'}]] + else: + stages = [stages, [{'controller_type': 'three_point'}]] + + elif isinstance(environment.physical_system.unwrapped, SynchronousMotorSystem): + if 'i_sq' in ref_states or 'torque' in ref_states: # Checking control task + controller_type = 'foc_controller' if 'i_sq' in ref_states else 'cascaded_foc_controller' + if action_space_type is Discrete: + stages = [[{'controller_type': 'on_off'}], [{'controller_type': 'on_off'}], + [{'controller_type': 'on_off'}]] + else: + stages = [[{'controller_type': 'pi_controller'}, {'controller_type': 'pi_controller'}]] + elif 'omega' in ref_states: + controller_type = 'cascaded_foc_controller' + if action_space_type is Discrete: + stages = [[{'controller_type': 'on_off'}], [{'controller_type': 'on_off'}], + [{'controller_type': 'on_off'}], [{'controller_type': 'pi_controller'}]] + else: + stages = [[{'controller_type': 'pi_controller'}, + {'controller_type': 'pi_controller'}], [{'controller_type': 'pi_controller'}]] + + elif isinstance(environment.physical_system.unwrapped, (SquirrelCageInductionMotorSystem, DoublyFedInductionMotorSystem)): + if 'i_sq' in ref_states or 'torque' in ref_states: + controller_type = 'foc_rotor_flux_observer' if 'i_sq' in ref_states else 'cascaded_foc_rotor_flux_observer' + if action_space_type is Discrete: + stages = [[{'controller_type': 'on_off'}], [{'controller_type': 'on_off'}], + [{'controller_type': 'on_off'}]] + else: + stages = [[{'controller_type': 'pi_controller'}, {'controller_type': 'pi_controller'}]] + elif 'omega' in ref_states: + controller_type = 'cascaded_foc_rotor_flux_observer' + if action_space_type is Discrete: + stages = [[{'controller_type': 'on_off'}], [{'controller_type': 'on_off'}], + [{'controller_type': 'on_off'}], [{'controller_type': 'pi_controller'}]] + else: + stages = [[{'controller_type': 'pi_controller'}, + {'controller_type': 'pi_controller'}], [{'controller_type': 'pi_controller'}]] + else: + controller_type = 'foc_controller' + + return controller_type, stages + + @staticmethod + def automated_gain(environment, stages, controller_type, _controllers, **controller_kwargs): + """ + This method automatically parameterizes a given controller design if the parameter automated_gain is True + (default True), based on the design according to the symmetric optimum (SO). Further information about the + design according to the SO can be found in the following paper (https://ieeexplore.ieee.org/document/55967). + + Args: + environment: gym-electric-motor environment + stages: list of the stages of the controller + controller_type: string of the used controller type from the dictionary _controllers + _controllers: dictionary of all possible controllers and controller stages + controller_kwargs: further arguments of the controller + + Returns: + list of stages, which are completely parameterized + """ + + ref_states = controller_kwargs['ref_states'] + mp = environment.physical_system.electrical_motor.motor_parameter + limits = environment.physical_system.limits + omega_lim = limits[environment.state_names.index('omega')] + if isinstance(environment.physical_system.unwrapped, DcMotorSystem): + i_a_lim = limits[environment.physical_system.CURRENTS_IDX[0]] + i_e_lim = limits[environment.physical_system.CURRENTS_IDX[-1]] + u_a_lim = limits[environment.physical_system.VOLTAGES_IDX[0]] + u_e_lim = limits[environment.physical_system.VOLTAGES_IDX[-1]] + + elif isinstance(environment.physical_system.unwrapped, SynchronousMotorSystem): + i_sd_lim = limits[environment.state_names.index('i_sd')] + i_sq_lim = limits[environment.state_names.index('i_sq')] + u_sd_lim = limits[environment.state_names.index('u_sd')] + u_sq_lim = limits[environment.state_names.index('u_sq')] + torque_lim = limits[environment.state_names.index('torque')] + + else: + i_sd_lim = limits[environment.state_names.index('i_sd')] + i_sq_lim = limits[environment.state_names.index('i_sq')] + u_sd_lim = limits[environment.state_names.index('u_sd')] + u_sq_lim = limits[environment.state_names.index('u_sq')] + torque_lim = limits[environment.state_names.index('torque')] + + # The parameter a is a design parameter when designing a controller according to the SO + a = controller_kwargs.get('a', 4) + automated_gain = controller_kwargs.get('automated_gain', True) + + if isinstance(environment.physical_system.electrical_motor, DcSeriesMotor): + mp['l'] = mp['l_a'] + mp['l_e'] + elif isinstance(environment.physical_system.unwrapped, DcMotorSystem): + mp['l'] = mp['l_a'] + + if 'automated_gain' not in controller_kwargs.keys() or automated_gain: + cont_extex_envs = ( + envs.ContSpeedControlDcExternallyExcitedMotorEnv, + envs.ContCurrentControlDcExternallyExcitedMotorEnv, + envs.ContTorqueControlDcExternallyExcitedMotorEnv + ) + finite_extex_envs = ( + envs.FiniteTorqueControlDcExternallyExcitedMotorEnv, + envs.FiniteSpeedControlDcExternallyExcitedMotorEnv, + envs.FiniteCurrentControlDcExternallyExcitedMotorEnv + ) + if type(environment) in cont_extex_envs: + stages_a = stages[0] + stages_e = stages[1] + + p_gain = mp['l_e'] / (environment.physical_system.tau * a) / u_e_lim * i_e_lim + i_gain = p_gain / (environment.physical_system.tau * a ** 2) + + stages_e[0]['p_gain'] = stages_e[0].get('p_gain', p_gain) + stages_e[0]['i_gain'] = stages_e[0].get('i_gain', i_gain) + + if stages_e[0]['controller_type'] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages_e[0]['d_gain'] = stages_e[0].get('d_gain', d_gain) + elif type(environment) in finite_extex_envs: + stages_a = stages[0] + stages_e = stages[1] + else: + stages_a = stages + stages_e = False + + if _controllers[controller_type][0] == ContinuousActionController: + if 'i' in ref_states or 'i_a' in ref_states or 'torque' in ref_states: + p_gain = mp['l'] / (environment.physical_system.tau * a) / u_a_lim * i_a_lim + i_gain = p_gain / (environment.physical_system.tau * a ** 2) + + stages_a[0]['p_gain'] = stages_a[0].get('p_gain', p_gain) + stages_a[0]['i_gain'] = stages_a[0].get('i_gain', i_gain) + + if _controllers[controller_type][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages_a[0]['d_gain'] = stages_a[0].get('d_gain', d_gain) + + elif 'omega' in ref_states: + p_gain = environment.physical_system.mechanical_load.j_total * mp['r_a'] ** 2 / ( + a * mp['l']) / u_a_lim * omega_lim + i_gain = p_gain / (a * mp['l']) + + stages_a[0]['p_gain'] = stages_a[0].get('p_gain', p_gain) + stages_a[0]['i_gain'] = stages_a[0].get('i_gain', i_gain) + + if _controllers[controller_type][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages_a[0]['d_gain'] = stages_a[0].get('d_gain', d_gain) + + elif _controllers[controller_type][0] == CascadedController: + + for i in range(len(stages)): + if type(stages_a[i]) is list: + if _controllers[stages_a[i][0]['controller_type']][1] == ContinuousController: #had to add [0] to make dict in list acessable + + if i == 0: + p_gain = mp['l'] / (environment.physical_system.tau * a) / u_a_lim * i_a_lim + i_gain = p_gain / (environment.physical_system.tau * a ** 2) + + if _controllers[stages_a[i][0]['controller_type']][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages_a[i][0]['d_gain'] = stages_a[i][0].get('d_gain', d_gain) + + elif i == 1: + t_n = environment.physical_system.tau * a ** 2 + p_gain = environment.physical_system.mechanical_load.j_total / ( + a * t_n) / i_a_lim * omega_lim + i_gain = p_gain / (a * t_n) + if _controllers[stages_a[i][0]['controller_type']][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages_a[i][0]['d_gain'] = stages_a[i][0].get('d_gain', d_gain) + + stages_a[i][0]['p_gain'] = stages_a[i][0].get('p_gain', p_gain)#? + stages_a[i][0]['i_gain'] = stages_a[i][0].get('i_gain', i_gain)#? + + elif type(stages_a[i]) is dict: + if _controllers[stages_a[i]['controller_type']][1] == ContinuousController: #had to add [0] to make dict in list acessable + + if i == 0: + p_gain = mp['l'] / (environment.physical_system.tau * a) / u_a_lim * i_a_lim + i_gain = p_gain / (environment.physical_system.tau * a ** 2) + + if _controllers[stages_a[i]['controller_type']][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages_a[i]['d_gain'] = stages_a[i].get('d_gain', d_gain) + + elif i == 1: + t_n = environment.physical_system.tau * a ** 2 + p_gain = environment.physical_system.mechanical_load.j_total / ( + a * t_n) / i_a_lim * omega_lim + i_gain = p_gain / (a * t_n) + if _controllers[stages_a[i]['controller_type']][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages_a[i]['d_gain'] = stages_a[i].get('d_gain', d_gain) + + stages_a[i]['p_gain'] = stages_a[i].get('p_gain', p_gain)#? + stages_a[i]['i_gain'] = stages_a[i].get('i_gain', i_gain)#? + + + stages = stages_a if not stages_e else [stages_a, stages_e] + + elif _controllers[controller_type][0] == FieldOrientedController: + if type(environment.action_space) == Box: + stage_d = stages[0][0] + stage_q = stages[0][1] + if 'i_sq' in ref_states and _controllers[stage_q['controller_type']][1] == ContinuousController: + p_gain_d = mp['l_d'] / (1.5 * environment.physical_system.tau * a) / u_sd_lim * i_sd_lim + i_gain_d = p_gain_d / (1.5 * environment.physical_system.tau * a ** 2) + + p_gain_q = mp['l_q'] / (1.5 * environment.physical_system.tau * a) / u_sq_lim * i_sq_lim + i_gain_q = p_gain_q / (1.5 * environment.physical_system.tau * a ** 2) + + stage_d['p_gain'] = stage_d.get('p_gain', p_gain_d) + stage_d['i_gain'] = stage_d.get('i_gain', i_gain_d) + + stage_q['p_gain'] = stage_q.get('p_gain', p_gain_q) + stage_q['i_gain'] = stage_q.get('i_gain', i_gain_q) + + if _controllers[stage_d['controller_type']][2] == PIDController: + d_gain_d = p_gain_d * environment.physical_system.tau + stage_d['d_gain'] = stage_d.get('d_gain', d_gain_d) + + if _controllers[stage_q['controller_type']][2] == PIDController: + d_gain_q = p_gain_q * environment.physical_system.tau + stage_q['d_gain'] = stage_q.get('d_gain', d_gain_q) + stages = [[stage_d, stage_q]] + + elif _controllers[controller_type][0] == CascadedFieldOrientedController: + if type(environment.action_space) is Box: + stage_d = stages[0][0] + stage_q = stages[0][1] + if 'torque' not in controller_kwargs['ref_states']: + overlaid = stages[1] + + p_gain_d = mp['l_d'] / (1.5 * environment.physical_system.tau * a) / u_sd_lim * i_sd_lim + i_gain_d = p_gain_d / (1.5 * environment.physical_system.tau * a ** 2) + + p_gain_q = mp['l_q'] / (1.5 * environment.physical_system.tau * a) / u_sq_lim * i_sq_lim + i_gain_q = p_gain_q / (1.5 * environment.physical_system.tau * a ** 2) + + stage_d['p_gain'] = stage_d.get('p_gain', p_gain_d) + stage_d['i_gain'] = stage_d.get('i_gain', i_gain_d) + + stage_q['p_gain'] = stage_q.get('p_gain', p_gain_q) + stage_q['i_gain'] = stage_q.get('i_gain', i_gain_q) + + if _controllers[stage_d['controller_type']][2] == PIDController: + d_gain_d = p_gain_d * environment.physical_system.tau + stage_d['d_gain'] = stage_d.get('d_gain', d_gain_d) + + if _controllers[stage_q['controller_type']][2] == PIDController: + d_gain_q = p_gain_q * environment.physical_system.tau + stage_q['d_gain'] = stage_q.get('d_gain', d_gain_q) + + if 'torque' not in controller_kwargs['ref_states'] and \ + _controllers[overlaid[0]['controller_type']][1] == ContinuousController: + t_n = p_gain_d / i_gain_d + j_total = environment.physical_system.mechanical_load.j_total + p_gain = j_total / (a ** 2 * t_n) / torque_lim * omega_lim + i_gain = p_gain / (a * t_n) + + overlaid[0]['p_gain'] = overlaid[0].get('p_gain', p_gain) + overlaid[0]['i_gain'] = overlaid[0].get('i_gain', i_gain) + + if _controllers[overlaid[0]['controller_type']][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + overlaid[0]['d_gain'] = overlaid[0].get('d_gain', d_gain) + + stages = [[stage_d, stage_q], overlaid] + + else: + stages = [[stage_d, stage_q]] + + else: + if 'omega' in ref_states and _controllers[stages[3][0]['controller_type']][1] == ContinuousController: + + p_gain = environment.physical_system.mechanical_load.j_total / ( + 1.5 * a ** 2 * mp['p'] * np.abs(mp['l_d'] - mp['l_q'])) / i_sq_lim * omega_lim + i_gain = p_gain / (1.5 * environment.physical_system.tau * a) + + stages[3][0]['p_gain'] = stages[3][0].get('p_gain', p_gain) + stages[3][0]['i_gain'] = stages[3][0].get('i_gain', i_gain) + + if _controllers[stages[3][0]['controller_type']][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + stages[3][0]['d_gain'] = stages[3][0].get('d_gain', d_gain) + + elif _controllers[controller_type][0] == InductionMotorFieldOrientedController: + + mp['l_s'] = mp['l_m'] + mp['l_sigs'] + mp['l_r'] = mp['l_m'] + mp['l_sigr'] + sigma = (mp['l_s'] * mp['l_r'] - mp['l_m'] ** 2) / (mp['l_s'] * mp['l_r']) + tau_sigma = (sigma * mp['l_s']) / (mp['r_s'] + mp['r_r'] * mp['l_m'] ** 2 / mp['l_r'] ** 2) + tau_r = mp['l_r'] / mp['r_r'] + p_gain = tau_r / tau_sigma + i_gain = p_gain / tau_sigma + + stages[0][0]['p_gain'] = stages[0][0].get('p_gain', p_gain) + stages[0][0]['i_gain'] = stages[0][0].get('i_gain', i_gain) + stages[0][1]['p_gain'] = stages[0][1].get('p_gain', p_gain) + stages[0][1]['i_gain'] = stages[0][1].get('i_gain', i_gain) + + if _controllers[stages[0][0]['controller_type']][2] == PIDController: + d_gain = p_gain * tau_sigma + stages[0][0]['d_gain'] = stages[0][0].get('d_gain', d_gain) + + if _controllers[stages[0][1]['controller_type']][2] == PIDController: + d_gain = p_gain * tau_sigma + stages[0][1]['d_gain'] = stages[0][1].get('d_gain', d_gain) + + elif _controllers[controller_type][0] == InductionMotorCascadedFieldOrientedController: + + if 'torque' not in controller_kwargs['ref_states']: + overlaid = stages[1] + + mp['l_s'] = mp['l_m'] + mp['l_sigs'] + mp['l_r'] = mp['l_m'] + mp['l_sigr'] + sigma = (mp['l_s'] * mp['l_r'] - mp['l_m'] ** 2) / (mp['l_s'] * mp['l_r']) + tau_sigma = (sigma * mp['l_s']) / (mp['r_s'] + mp['r_r'] * mp['l_m'] ** 2 / mp['l_r'] ** 2) + tau_r = mp['l_r'] / mp['r_r'] + p_gain = tau_r / tau_sigma + i_gain = p_gain / tau_sigma + + stages[0][0]['p_gain'] = stages[0][0].get('p_gain', p_gain) + stages[0][0]['i_gain'] = stages[0][0].get('i_gain', i_gain) + stages[0][1]['p_gain'] = stages[0][1].get('p_gain', p_gain) + stages[0][1]['i_gain'] = stages[0][1].get('i_gain', i_gain) + + if _controllers[stages[0][0]['controller_type']][2] == PIDController: + d_gain = p_gain * tau_sigma + stages[0][0]['d_gain'] = stages[0][0].get('d_gain', d_gain) + + if _controllers[stages[0][1]['controller_type']][2] == PIDController: + d_gain = p_gain * tau_sigma + stages[0][1]['d_gain'] = stages[0][1].get('d_gain', d_gain) + + if 'torque' not in controller_kwargs['ref_states'] and \ + _controllers[overlaid[0]['controller_type']][1] == ContinuousController: + t_n = p_gain / i_gain + j_total = environment.physical_system.mechanical_load.j_total + p_gain = j_total / (a ** 2 * t_n) / torque_lim * omega_lim + i_gain = p_gain / (a * t_n) + + overlaid[0]['p_gain'] = overlaid[0].get('p_gain', p_gain) + overlaid[0]['i_gain'] = overlaid[0].get('i_gain', i_gain) + + if _controllers[overlaid[0]['controller_type']][2] == PIDController: + d_gain = p_gain * environment.physical_system.tau + overlaid[0]['d_gain'] = overlaid[0].get('d_gain', d_gain) + + stages = [stages[0], overlaid] + + return stages From 8465e609f0383d5c13d6fd98b9fe86cd160d67c4 Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Mon, 29 May 2023 14:41:50 +0200 Subject: [PATCH 11/37] Working tests and examples: - removed reset_with_next_reference - disable gymnasium env checker --- .../classic_controllers_dc_motor_example.py | 2 +- .../classic_controllers_ind_motor_example.py | 2 +- .../classic_controllers_synch_motor_example.py | 2 +- ...custom_classic_controllers_dc_motor_example.py | 2 +- ...ustom_classic_controllers_ind_motor_example.py | 2 +- ...tom_classic_controllers_synch_motor_example.py | 2 +- gym_electric_motor/__init__.py | 1 + gym_electric_motor/core.py | 15 ++------------- 8 files changed, 9 insertions(+), 19 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_example.py b/examples/classic_controllers/classic_controllers_dc_motor_example.py index f64d5f68..de141d83 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_example.py @@ -53,7 +53,7 @@ """ controller = Controller.make(env, external_ref_plots=external_ref_plots) - state, reference = env.reset_with_next_reference() + state, reference = env.reset() # simulate the environment for i in range(10001): action = controller.control(state, reference) diff --git a/examples/classic_controllers/classic_controllers_ind_motor_example.py b/examples/classic_controllers/classic_controllers_ind_motor_example.py index 6d8179c1..3908f10d 100644 --- a/examples/classic_controllers/classic_controllers_ind_motor_example.py +++ b/examples/classic_controllers/classic_controllers_ind_motor_example.py @@ -46,7 +46,7 @@ """ controller = Controller.make(env) - state, reference = env.reset_with_next_reference() + state, reference = env.reset() # simulate the environment for i in range(10001): diff --git a/examples/classic_controllers/classic_controllers_synch_motor_example.py b/examples/classic_controllers/classic_controllers_synch_motor_example.py index 426bf477..3af8f8c8 100644 --- a/examples/classic_controllers/classic_controllers_synch_motor_example.py +++ b/examples/classic_controllers/classic_controllers_synch_motor_example.py @@ -50,7 +50,7 @@ controller = Controller.make(env, external_ref_plots=external_ref_plots, torque_control='analytical') - state, reference = env.reset_with_next_reference() + state, reference = env.reset() # simulate the environment for i in range(10001): diff --git a/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py b/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py index 048a7883..9805c669 100644 --- a/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py @@ -69,7 +69,7 @@ controller = Controller.make(env, external_ref_plots=external_ref_plots, stages=stages) - state, reference = env.reset_with_next_reference() + state, reference = env.reset() # simulate the environment for i in range(10001): diff --git a/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py b/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py index 125a2349..a09b6835 100644 --- a/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py @@ -49,7 +49,7 @@ controller = Controller.make(env, stages=stages, external_plot=external_ref_plots) - state, reference = env.reset_with_next_reference() + state, reference = env.reset() # simulate the environment for i in range(10001): diff --git a/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py b/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py index 7c9f62eb..d9881a94 100644 --- a/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py @@ -100,7 +100,7 @@ controller = Controller.make(env, stages=stages, external_ref_plots=external_ref_plots, torque_control='analytical') - state, reference = env.reset_with_next_reference() + state, reference = env.reset() # simulate the environment for i in range(10001): diff --git a/gym_electric_motor/__init__.py b/gym_electric_motor/__init__.py index c97b3987..4070c032 100644 --- a/gym_electric_motor/__init__.py +++ b/gym_electric_motor/__init__.py @@ -26,6 +26,7 @@ # Deactivate the order enforce wrapper that is put around a created env per default from gymnasium-version 0.21.0 onwards registration_kwargs = dict(order_enforce=False) if version.parse(gymnasium.__version__) >= version.parse('0.21.0') else dict() +registration_kwargs['disable_env_checker'] = True envs_path = 'gym_electric_motor.envs:' diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 2a27cd49..0105e0b1 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -246,21 +246,10 @@ def reset(self, *_, **__): self._call_callbacks('on_reset_begin') self._done = False state = self._physical_system.reset() - reference, _, _ = self.reference_generator.reset(state) + reference, next_ref, _ = self.reference_generator.reset(state) self._reward_function.reset(state, reference) self._call_callbacks('on_reset_end', state, reference) - return state[self.state_filter] #, next_ref - - def reset_with_next_reference(self, *_, **__): - """ - Reset of the environment and all its modules to an initial state. - - Returns: - The initial observation consisting of the initial state and initial reference. - """ - state = self.reset() - _, next_ref, _ = self.reference_generator.reset(state) - return state[self.state_filter] , next_ref + return state[self.state_filter], next_ref def render(self, *_, **__): """ From 75572bda088fe566c293c711f6268b98b9f54a19 Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Mon, 29 May 2023 14:54:54 +0200 Subject: [PATCH 12/37] fixed precision warning in tests --- .../reference_generators/switched_reference_generator.py | 2 +- tests/test_core.py | 1 + tests/test_physical_system_wrappers/test_cos_sin_processor.py | 2 +- tests/test_physical_systems/test_physical_systems.py | 3 ++- tests/test_reference_generators/test_reference_generators.py | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gym_electric_motor/reference_generators/switched_reference_generator.py b/gym_electric_motor/reference_generators/switched_reference_generator.py index 403a52de..48f3e9e1 100644 --- a/gym_electric_motor/reference_generators/switched_reference_generator.py +++ b/gym_electric_motor/reference_generators/switched_reference_generator.py @@ -47,7 +47,7 @@ def set_modules(self, physical_system): sub_generator.set_modules(physical_system) ref_space_low = np.min([sub_generator.reference_space.low for sub_generator in self._sub_generators], axis=0) ref_space_high = np.max([sub_generator.reference_space.high for sub_generator in self._sub_generators], axis=0) - self.reference_space = Box(ref_space_low, ref_space_high) + self.reference_space = Box(ref_space_low, ref_space_high, dtype=float) self._referenced_states = self._sub_generators[0].referenced_states for sub_generator in self._sub_generators: assert np.all(sub_generator.referenced_states == self._referenced_states), \ diff --git a/tests/test_core.py b/tests/test_core.py index c497ce2e..25b7068d 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -86,6 +86,7 @@ def test_initialization( state_space = Box( physical_system.state_space.low[state_idxs], physical_system.state_space.high[state_idxs], + dtype=float ) assert Tuple( (state_space, reference_generator.reference_space) diff --git a/tests/test_physical_system_wrappers/test_cos_sin_processor.py b/tests/test_physical_system_wrappers/test_cos_sin_processor.py index 5572125a..bffa3cc6 100644 --- a/tests/test_physical_system_wrappers/test_cos_sin_processor.py +++ b/tests/test_physical_system_wrappers/test_cos_sin_processor.py @@ -22,7 +22,7 @@ def test_nominal_state(self, processor, physical_system): def test_state_space(self, processor, physical_system): low = np.concatenate((physical_system.state_space.low, [-1, -1])) high = np.concatenate((physical_system.state_space.high, [1, 1])) - space = gymnasium.spaces.Box(low, high) + space = gymnasium.spaces.Box(low, high, dtype=float) assert processor.state_space == space def test_reset(self, processor, physical_system): diff --git a/tests/test_physical_systems/test_physical_systems.py b/tests/test_physical_systems/test_physical_systems.py index d306a093..1c12f42f 100644 --- a/tests/test_physical_systems/test_physical_systems.py +++ b/tests/test_physical_systems/test_physical_systems.py @@ -41,7 +41,8 @@ def scml_system(self, monkeypatch): '_build_state_space', lambda _, state_names: Box( low=np.zeros_like(state_names, dtype=float), - high=np.zeros_like(state_names, dtype=float) + high=np.zeros_like(state_names, dtype=float), + dtype=float ) ) return self.class_to_test( diff --git a/tests/test_reference_generators/test_reference_generators.py b/tests/test_reference_generators/test_reference_generators.py index 3cc7b699..94fa46ca 100644 --- a/tests/test_reference_generators/test_reference_generators.py +++ b/tests/test_reference_generators/test_reference_generators.py @@ -705,14 +705,14 @@ def physical_system(self): @pytest.fixture def reference_generator(self, physical_system): - rg = ConstReferenceGenerator(reference_state=physical_system.state_names[1], reference_value=1) + rg = ConstReferenceGenerator(reference_state=physical_system.state_names[1], reference_value=1.0) rg.set_modules(physical_system) return rg @pytest.mark.parametrize('reference_value, reference_state', [(0.8, 'abc')]) def test_initialization(self, reference_value, reference_state): rg = ConstReferenceGenerator(reference_value=reference_value, reference_state=reference_state) - assert rg.reference_space == Box(np.array([reference_value]), np.array([reference_value])) + assert rg.reference_space == Box(np.array([reference_value]), np.array([reference_value]), dtype=np.float64) assert rg._reference_value == reference_value assert rg._reference_state == reference_state From 095767f3abe636a3d5fa015dc07d089b6023ec1c Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Fri, 16 Jun 2023 11:22:40 +0200 Subject: [PATCH 13/37] get_figure() and save it to png file based on *dc_motor_example.py --- ...c_controllers_dc_motor_integration_test.py | 69 +++++++++++++++++++ gym_electric_motor/core.py | 7 ++ 2 files changed, 76 insertions(+) create mode 100644 examples/classic_controllers/classic_controllers_dc_motor_integration_test.py diff --git a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py new file mode 100644 index 00000000..bde8fd84 --- /dev/null +++ b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py @@ -0,0 +1,69 @@ +from classic_controllers import Controller +from externally_referenced_state_plot import ExternallyReferencedStatePlot +import gym_electric_motor as gem +from gym_electric_motor.visualization import MotorDashboard + +if __name__ == '__main__': + + """ + motor type: 'PermExDc' Permanently Excited DC Motor + 'ExtExDc' Externally Excited MC Motor + 'SeriesDc' DC Series Motor + 'ShuntDc' DC Shunt Motor + + control type: 'SC' Speed Control + 'TC' Torque Control + 'CC' Current Control + + action_type: 'Cont' Continuous Action Space + 'Finite' Discrete Action Space + """ + + motor_type = 'PermExDc' + control_type = 'TC' + action_type = 'Cont' + + motor = action_type + '-' + control_type + '-' + motor_type + '-v0' + + if motor_type in ['PermExDc', 'SeriesDc']: + states = ['omega', 'torque', 'i', 'u'] + elif motor_type == 'ShuntDc': + states = ['omega', 'torque', 'i_a', 'i_e', 'u'] + elif motor_type == 'ExtExDc': + states = ['omega', 'torque', 'i_a', 'i_e', 'u_a', 'u_e'] + else: + raise KeyError(motor_type + ' is not available') + + # definition of the plotted variables + external_ref_plots = [ExternallyReferencedStatePlot(state) for state in states] + + # initialize the gym-electric-motor environment + env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots)) + env.seed(1337) + + """ + initialize the controller + + Args: + environment gym-electric-motor environment + external_ref_plots (optional) plots of the environment, to plot all reference values + stages (optional) structure of the controller + automated_gain (optional) if True (default), the controller will be tune automatically + a (optional) tuning parameter of the symmetrical optimum (default: 4) + + """ + controller = Controller.make(env, external_ref_plots=external_ref_plots) + + state, reference = env.reset() + # simulate the environment + for i in range(10001): + action = controller.control(state, reference) + env.render() + (state, reference), reward, done, _ = env.step(action) + if done: + env.reset() + controller.reset() + + fig = env.get_figure() + fig.savefig("test3.png", dpi=300) + env.close() diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 0105e0b1..25c5e7fa 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -243,6 +243,7 @@ def reset(self, *_, **__): Returns: The initial observation consisting of the initial state and initial reference. """ + super().reset() self._call_callbacks('on_reset_begin') self._done = False state = self._physical_system.reset() @@ -307,6 +308,12 @@ def close(self): self._physical_system.close() self._reference_generator.close() + def get_figure(self): + """ Get main figure (MotorDashboard) """ + assert len(self._visualizations) == 1 + motor_dashboard = self._visualizations[0] + assert len(motor_dashboard._figures) == 1 + return motor_dashboard._figures[0] class ReferenceGenerator: """The abstract base class for reference generators in gym electric motor environments. From 9a164350700e2bce70a25e91f780090937b089fd Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Fri, 16 Jun 2023 11:25:05 +0200 Subject: [PATCH 14/37] super.reset() was not in previous code --- gym_electric_motor/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 25c5e7fa..86222339 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -243,7 +243,6 @@ def reset(self, *_, **__): Returns: The initial observation consisting of the initial state and initial reference. """ - super().reset() self._call_callbacks('on_reset_begin') self._done = False state = self._physical_system.reset() From a4f360aa5df59f49903c201764b221791d6bf261 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Fri, 16 Jun 2023 12:58:55 +0200 Subject: [PATCH 15/37] alignment of seeding with gymnasium --- .../classic_controllers_dc_motor_example.py | 2 +- gym_electric_motor/core.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_example.py b/examples/classic_controllers/classic_controllers_dc_motor_example.py index de141d83..862a05e9 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_example.py @@ -53,7 +53,7 @@ """ controller = Controller.make(env, external_ref_plots=external_ref_plots) - state, reference = env.reset() + state, reference = env.reset(seed = None) # simulate the environment for i in range(10001): action = controller.control(state, reference) diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 86222339..b5c839af 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -236,13 +236,15 @@ def _call_callbacks(self, func_name, *args): func = getattr(callback, func_name) func(*args) - def reset(self, *_, **__): + def reset(self, seed,*_, **__): """ Reset of the environment and all its modules to an initial state. Returns: The initial observation consisting of the initial state and initial reference. """ + + self.seed(seed) self._call_callbacks('on_reset_begin') self._done = False state = self._physical_system.reset() From 63dbe834e2463c91979796a8e97ae1825fbb9553 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Fri, 16 Jun 2023 13:02:53 +0200 Subject: [PATCH 16/37] added default None to seeding in reset --- gym_electric_motor/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index b5c839af..92015453 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -236,7 +236,7 @@ def _call_callbacks(self, func_name, *args): func = getattr(callback, func_name) func(*args) - def reset(self, seed,*_, **__): + def reset(self, seed = None,*_, **__): """ Reset of the environment and all its modules to an initial state. From 5fdb095b67c53d7061d43c8a2e49674a7aebb362 Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Sun, 18 Jun 2023 13:38:48 +0200 Subject: [PATCH 17/37] Using the new seeding API --- gym_electric_motor/core.py | 4 ++-- .../integration_tests/test_environment_seeding.py | 14 ++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 92015453..e5123bda 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -244,7 +244,7 @@ def reset(self, seed = None,*_, **__): The initial observation consisting of the initial state and initial reference. """ - self.seed(seed) + self._seed(seed) self._call_callbacks('on_reset_begin') self._done = False state = self._physical_system.reset() @@ -288,7 +288,7 @@ def step(self, action): ) return (state[self.state_filter], ref_next), reward, self._done, {} - def seed(self, seed=None): + def _seed(self, seed=None): sg = np.random.SeedSequence(seed) components = [ self._physical_system, diff --git a/tests/integration_tests/test_environment_seeding.py b/tests/integration_tests/test_environment_seeding.py index db5c6cfb..7b26275f 100644 --- a/tests/integration_tests/test_environment_seeding.py +++ b/tests/integration_tests/test_environment_seeding.py @@ -19,8 +19,6 @@ def test_seeding_same_env(dc_motor, control_task, action_type, version, no_of_st """This test assures that an environment that is seeded two times with the same seed generates the same episodes.""" env_id = f'{action_type}-{control_task}-{dc_motor}-{version}' env = gem.make(env_id) - # Seed the environment initially - env.seed(seed) # Sample actions that are used in both executions actions = [env.action_space.sample() for _ in range(no_of_steps)] done = True @@ -31,15 +29,13 @@ def test_seeding_same_env(dc_motor, control_task, action_type, version, no_of_st # Execute the env for i in range(no_of_steps): if done: - state, reference = env.reset() + state, reference = env.reset(seed) (state, reference), reward, done, info = env.step(actions[i]) rewards1.append(reward) states1.append(state) references1.append(reference) done1.append(done) - # Seed the environment again with the same seed - env.seed(seed) done = True states2 = [] references2 = [] @@ -48,7 +44,7 @@ def test_seeding_same_env(dc_motor, control_task, action_type, version, no_of_st # Execute the environment again for i in range(no_of_steps): if done: - state, reference = env.reset() + state, reference = env.reset(seed) (state, reference), reward, done, info = env.step(actions[i]) rewards2.append(reward) states2.append(state) @@ -74,7 +70,6 @@ def test_seeding_new_env(dc_motor, control_task, action_type, version, no_of_ste """This test assures that two equal environments that are seeded with the same seed generate the same episodes.""" env_id = f'{action_type}-{control_task}-{dc_motor}-{version}' env = gem.make(env_id) - env.seed(seed) actions = [env.action_space.sample() for _ in range(no_of_steps)] done = True @@ -85,7 +80,7 @@ def test_seeding_new_env(dc_motor, control_task, action_type, version, no_of_ste for i in range(no_of_steps): if done: - state, reference = env.reset() + state, reference = env.reset(seed) (state, reference), reward, done, info = env.step(actions[i]) rewards1.append(reward) states1.append(state) @@ -93,7 +88,6 @@ def test_seeding_new_env(dc_motor, control_task, action_type, version, no_of_ste done1.append(done) env = gem.make(env_id) - env.seed(seed) done = True states2 = [] references2 = [] @@ -102,7 +96,7 @@ def test_seeding_new_env(dc_motor, control_task, action_type, version, no_of_ste for i in range(no_of_steps): if done: - state, reference = env.reset() + state, reference = env.reset(seed) action = env.action_space.sample() assert action in env.action_space (state, reference), reward, done, info = env.step(actions[i]) From eef7a8cdfe274fab7f83efc086ffd26089387100 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Sun, 18 Jun 2023 14:18:16 +0200 Subject: [PATCH 18/37] changed done to terminated and truncated --- .../classic_controllers_dc_motor_example.py | 4 ++-- ...c_controllers_dc_motor_integration_test.py | 4 ++-- .../classic_controllers_ind_motor_example.py | 4 ++-- ...classic_controllers_synch_motor_example.py | 4 ++-- .../torque_to_current_conversion.py | 6 +++--- ...om_classic_controllers_dc_motor_example.py | 4 ++-- ...m_classic_controllers_ind_motor_example.py | 4 ++-- ...classic_controllers_synch_motor_example.py | 4 ++-- examples/classic_controllers/external_plot.py | 10 ++++----- .../externally_referenced_state_plot.py | 6 +++--- .../external_speed_profile.py | 4 ++-- .../scim_ideal_grid_simulation.py | 2 +- .../userdefined_initialization.py | 4 ++-- gym_electric_motor/callbacks.py | 2 +- gym_electric_motor/core.py | 21 ++++++++++--------- .../cont_cc_extex_dc_env.py | 6 +++--- .../cont_sc_extex_dc_env.py | 6 +++--- .../cont_tc_extex_dc_env.py | 6 +++--- .../finite_cc_extex_dc_env.py | 6 +++--- .../finite_sc_extex_dc_env.py | 6 +++--- .../finite_tc_extex_dc_env.py | 6 +++--- .../cont_cc_permex_dc_env.py | 6 +++--- .../cont_sc_permex_dc_env.py | 6 +++--- .../cont_tc_permex_dc_env.py | 6 +++--- .../finite_cc_permex_dc_env.py | 6 +++--- .../finite_sc_permex_dc_env.py | 6 +++--- .../finite_tc_permex_dc_env.py | 6 +++--- .../cont_cc_series_dc_env.py | 6 +++--- .../cont_sc_series_dc_env.py | 6 +++--- .../cont_tc_series_dc_env.py | 6 +++--- .../finite_cc_series_dc_env.py | 6 +++--- .../finite_sc_series_dc_env.py | 6 +++--- .../finite_tc_series_dc_env.py | 6 +++--- .../cont_cc_shunt_dc_env.py | 6 +++--- .../cont_sc_shunt_dc_env.py | 6 +++--- .../cont_tc_shunt_dc_env.py | 6 +++--- .../finite_cc_shunt_dc_env.py | 6 +++--- .../finite_sc_shunt_dc_env.py | 6 +++--- .../finite_tc_shunt_dc_env.py | 6 +++--- .../envs/gym_eesm/cont_cc_eesm_env.py | 6 +++--- .../envs/gym_eesm/cont_sc_eesm_env.py | 6 +++--- .../envs/gym_eesm/cont_tc_eesm_env.py | 6 +++--- .../envs/gym_eesm/finite_cc_eesm_env.py | 6 +++--- .../envs/gym_eesm/finite_sc_eesm_env.py | 6 +++--- .../envs/gym_eesm/finite_tc_eesm_env.py | 6 +++--- .../cont_cc_dfim_env.py | 6 +++--- .../cont_sc_dfim_env.py | 6 +++--- .../cont_tc_dfim_env.py | 6 +++--- .../finite_cc_dfim_env.py | 6 +++--- .../finite_sc_dfim_env.py | 6 +++--- .../finite_tc_dfim_env.py | 6 +++--- .../cont_cc_scim_env.py | 6 +++--- .../cont_sc_scim_env.py | 6 +++--- .../cont_tc_scim_env.py | 6 +++--- .../finite_cc_scim_env.py | 6 +++--- .../finite_sc_scim_env.py | 6 +++--- .../finite_tc_scim_env.py | 6 +++--- .../envs/gym_pmsm/cont_cc_pmsm_env.py | 6 +++--- .../envs/gym_pmsm/cont_sc_pmsm_env.py | 6 +++--- .../envs/gym_pmsm/cont_tc_pmsm_env.py | 6 +++--- .../envs/gym_pmsm/finite_cc_pmsm_env.py | 6 +++--- .../envs/gym_pmsm/finite_sc_pmsm_env.py | 6 +++--- .../envs/gym_pmsm/finite_tc_pmsm_env.py | 6 +++--- .../envs/gym_synrm/cont_cc_synrm_env.py | 6 +++--- .../envs/gym_synrm/cont_sc_synrm_env.py | 6 +++--- .../envs/gym_synrm/cont_tc_synrm_env.py | 6 +++--- .../envs/gym_synrm/finite_cc_synrm_env.py | 6 +++--- .../envs/gym_synrm/finite_sc_synrm_env.py | 6 +++--- .../envs/gym_synrm/finite_tc_synrm_env.py | 6 +++--- .../polynomial_static_load.py | 6 +++--- .../visualization/console_printer.py | 4 ++-- .../visualization/motor_dashboard.py | 6 +++--- .../motor_dashboard_plots/base_plots.py | 4 ++-- .../cumulative_constraint_violation_plot.py | 6 +++--- .../episode_length_plot.py | 2 +- .../mean_episode_reward_plot.py | 4 ++-- .../motor_dashboard_plots/reward_plot.py | 4 ++-- .../motor_dashboard_plots/state_plot.py | 4 ++-- .../test_environment_execution.py | 6 +++--- .../test_environment_seeding.py | 14 ++++++------- tests/test_core.py | 4 ++-- tests/testing_utils.py | 2 +- 82 files changed, 237 insertions(+), 236 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_example.py b/examples/classic_controllers/classic_controllers_dc_motor_example.py index 862a05e9..50422999 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_example.py @@ -58,8 +58,8 @@ for i in range(10001): action = controller.control(state, reference) env.render() - (state, reference), reward, done, _ = env.step(action) - if done: + (state, reference), reward, terminated, truncated, _ = env.step(action) + if terminated: env.reset() controller.reset() diff --git a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py index bde8fd84..a7f20e37 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py @@ -59,8 +59,8 @@ for i in range(10001): action = controller.control(state, reference) env.render() - (state, reference), reward, done, _ = env.step(action) - if done: + (state, reference), reward, terminated, truncated, _ = env.step(action) + if terminated: env.reset() controller.reset() diff --git a/examples/classic_controllers/classic_controllers_ind_motor_example.py b/examples/classic_controllers/classic_controllers_ind_motor_example.py index 3908f10d..0eceb6fe 100644 --- a/examples/classic_controllers/classic_controllers_ind_motor_example.py +++ b/examples/classic_controllers/classic_controllers_ind_motor_example.py @@ -52,8 +52,8 @@ for i in range(10001): env.render() action = controller.control(state, reference) - (state, reference), reward, done, _ = env.step(action) - if done: + (state, reference), reward, terminated, truncated, _ = env.step(action) + if terminated: env.reset() controller.reset() env.close() diff --git a/examples/classic_controllers/classic_controllers_synch_motor_example.py b/examples/classic_controllers/classic_controllers_synch_motor_example.py index 3af8f8c8..aa7a4c5b 100644 --- a/examples/classic_controllers/classic_controllers_synch_motor_example.py +++ b/examples/classic_controllers/classic_controllers_synch_motor_example.py @@ -56,8 +56,8 @@ for i in range(10001): env.render() action = controller.control(state, reference) - (state, reference), reward, done, _ = env.step(action) - if done: + (state, reference), reward, terminated, truncated, _ = env.step(action) + if terminated: env.reset() controller.reset() diff --git a/examples/classic_controllers/controllers/torque_to_current_conversion.py b/examples/classic_controllers/controllers/torque_to_current_conversion.py index d0c0833f..54362614 100644 --- a/examples/classic_controllers/controllers/torque_to_current_conversion.py +++ b/examples/classic_controllers/controllers/torque_to_current_conversion.py @@ -10,12 +10,12 @@ class TorqueToCurrentConversion: This class represents the torque controller for cascaded control of synchronous motors. For low speeds only the current limitation of the motor is important. The current vector to set a desired torque is selected so that the amount of the current vector is minimum (Maximum Torque per Current). For higher speeds, the voltage limitation - of the synchronous motor or the actuator must also be taken into account. This is done by converting the + of the synchronous motor or the actuator must also be taken into account. This is terminated by converting the available voltage to a speed-dependent maximum flux. An additional modulation controller is used for the flux control. By limiting the flux and the maximum torque per flux (MTPF), an operating point for the flux and the - torque is obtained. This is then converted into a current operating point. The conversion can be done by + torque is obtained. This is then converted into a current operating point. The conversion can be terminated by different methods (parameter torque_control). On the one hand, maps can be determined in advance by - interpolation or analytically, or the analytical determination can be done online. + interpolation or analytically, or the analytical determination can be terminated online. For the visualization of the operating points, both for the current operating points as well as the flux and torque operating points, predefined plots are available (plot_torque: default True). Also the values of the modulation controller can be visualized (plot_modulation: default False). diff --git a/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py b/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py index 9805c669..51ab8bc5 100644 --- a/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py @@ -75,8 +75,8 @@ for i in range(10001): action = controller.control(state, reference) env.render() - (state, reference), reward, done, _ = env.step(action) - if done: + (state, reference), reward, terminated, truncated, _ = env.step(action) + if terminated: env.reset() controller.reset() diff --git a/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py b/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py index a09b6835..cc9b696f 100644 --- a/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py @@ -55,8 +55,8 @@ for i in range(10001): env.render() action = controller.control(state, reference) - (state, reference), reward, done, _ = env.step(action) - if done: + (state, reference), reward, terminated, truncated, _ = env.step(action) + if terminated: env.reset() controller.reset() env.close() diff --git a/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py b/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py index d9881a94..b4d5f2cc 100644 --- a/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py @@ -106,8 +106,8 @@ for i in range(10001): env.render() action = controller.control(state, reference) - (state, reference), reward, done, _ = env.step(action) - if done: + (state, reference), reward, terminated, truncated, _ = env.step(action) + if terminated: env.reset() controller.reset() diff --git a/examples/classic_controllers/external_plot.py b/examples/classic_controllers/external_plot.py index 850b0d61..23c30668 100644 --- a/examples/classic_controllers/external_plot.py +++ b/examples/classic_controllers/external_plot.py @@ -25,14 +25,14 @@ class ExternalPlot(TimePlot): >>> # setting the labels of the plots >>> external_plot.set_label({'y_label': 'y', 'state_label': '$state$', 'ref_label': '$reference$', ... 'add_label': ['$add_1$', '$add_2$']}) - >>> done = True + >>> terminated = True >>> for t in range(100000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() >>> data = [np.sin(t / 500), np.sin(t / 1000), np.sin(t / 1500), np.sin(t / 2000)] >>> external_plot.add_data(data) # passing the data to the external plot - >>> (state, reference), reward, done, _ = env.step([0, 0]) + >>> (state, reference), reward, terminated, truncated, _ = env.step([0, 0]) """ def __init__(self, referenced=False, additional_lines=0, min=0, max=1): @@ -149,8 +149,8 @@ def set_label(self, labels): if 'add_label' in labels.keys(): self.add_labels = labels['add_label'] - def on_step_end(self, k, state, reference, reward, done): - super().on_step_end(k, state, reference, reward, done) + def on_step_end(self, k, state, reference, reward, terminated): + super().on_step_end(k, state, reference, reward, terminated) idx = self.data_idx self._x_data[idx] = self._t diff --git a/examples/classic_controllers/externally_referenced_state_plot.py b/examples/classic_controllers/externally_referenced_state_plot.py index d18a15f0..0ec2e85b 100644 --- a/examples/classic_controllers/externally_referenced_state_plot.py +++ b/examples/classic_controllers/externally_referenced_state_plot.py @@ -13,15 +13,15 @@ class ExternallyReferencedStatePlot(StatePlot): 'DqCont-SC-PMSM-v0', visualization=dict(additional_plots=(my_externally_referenced_plot,), ) - done = True + terminated = True for _ in range(10000): - if done: + if terminated: state, reference = env.reset() external_reference_value = my_external_isd_reference_generator.get_reference() my_externally_referenced_plot.external_reference(external_reference_value) env.render() action = env.action_space.sample() - (state, reference), reward, done, _ = env.step(action) + (state, reference), reward, terminated, truncated, _ = env.step(action) """ def __init__(self, state): diff --git a/examples/environment_features/external_speed_profile.py b/examples/environment_features/external_speed_profile.py index 38e8b8cb..ed74a689 100644 --- a/examples/environment_features/external_speed_profile.py +++ b/examples/environment_features/external_speed_profile.py @@ -84,9 +84,9 @@ for i in range(5000): env.render() action = env.action_space.sample() - (state, reference), reward, done, _ = env.step(action) + (state, reference), reward, terminated, truncated, _ = env.step(action) - if done: + if terminated: state, _ = env.reset() cum_rew += reward diff --git a/examples/environment_features/scim_ideal_grid_simulation.py b/examples/environment_features/scim_ideal_grid_simulation.py index 4c41f9ab..7d47db5f 100644 --- a/examples/environment_features/scim_ideal_grid_simulation.py +++ b/examples/environment_features/scim_ideal_grid_simulation.py @@ -76,7 +76,7 @@ def grid_voltage(t): time = idx * tau # apply the voltage as given by the grid - (state, reference), reward, done, _ = env.step(u_abc(time)) + (state, reference), reward, terminated, truncated, _ = env.step(u_abc(time)) # save the results of this simulation step STATE = np.append(STATE, np.transpose([state * limits]), axis=1) diff --git a/examples/environment_features/userdefined_initialization.py b/examples/environment_features/userdefined_initialization.py index e12ca853..17d4f8cd 100644 --- a/examples/environment_features/userdefined_initialization.py +++ b/examples/environment_features/userdefined_initialization.py @@ -79,9 +79,9 @@ for i in range(5000): env.render() action = env.action_space.sample() - (state, reference), reward, done, _ = env.step(action) + (state, reference), reward, terminated, truncated, _ = env.step(action) - if done: + if terminated: break diff --git a/gym_electric_motor/callbacks.py b/gym_electric_motor/callbacks.py index 22bd78f2..5cab3ad9 100644 --- a/gym_electric_motor/callbacks.py +++ b/gym_electric_motor/callbacks.py @@ -76,7 +76,7 @@ def set_env(self, env): else: self._env.reference_generator._limit_margin = self._limit_margin - def on_step_end(self, k, state, reference, reward, done): + def on_step_end(self, k, state, reference, reward, terminated): # See docstring of superclass if self._update_time == 'step': self._step += 1 diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index e5123bda..82143b76 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -109,7 +109,7 @@ def reference_generator(self, reference_generator): reference_generator(ReferenceGenerator): The new reference generator of the environment. """ self._reference_generator = reference_generator - self._done = True + self._terminated = True @property def reward_function(self): @@ -128,7 +128,7 @@ def reward_function(self, reward_function): reward_function(RewardFunction): The new reward function of the environment. """ self._reward_function = reward_function - self._done = True + self._terminated = True @property def constraint_monitor(self): @@ -225,7 +225,8 @@ def __init__(self, physical_system, reference_generator, reward_function, visual )) self.action_space = self.physical_system.action_space self.reward_range = self._reward_function.reward_range - self._done = True + self._terminated = True + self._truncated = False self._callbacks = list(callbacks) self._callbacks += list(self._visualizations) self._call_callbacks('set_env', self) @@ -246,7 +247,7 @@ def reset(self, seed = None,*_, **__): self._seed(seed) self._call_callbacks('on_reset_begin') - self._done = False + self._terminated = False state = self._physical_system.reset() reference, next_ref, _ = self.reference_generator.reset(state) self._reward_function.reset(state, reference) @@ -269,11 +270,11 @@ def step(self, action): Returns: observation(Tuple(ndarray(float),ndarray(float)): Tuple of the new state and the next reference. reward(float): Amount of reward received for the last step. - done(bool): Flag, indicating if a reset is required before new steps can be taken. + terminated(bool): Flag, indicating if a reset is required before new steps can be taken. {}: An empty dictionary for consistency with the OpenAi Gym interface. """ - assert not self._done, 'A reset is required before the environment can perform further steps' + assert not self._terminated, 'A reset is required before the environment can perform further steps' self._call_callbacks('on_step_begin', self.physical_system.k, action) state = self._physical_system.simulate(action) reference = self.reference_generator.get_reference(state) @@ -281,12 +282,12 @@ def step(self, action): reward = self._reward_function.reward( state, reference, self._physical_system.k, action, violation_degree ) - self._done = violation_degree >= 1.0 + self._terminated = violation_degree >= 1.0 ref_next = self.reference_generator.get_reference_observation(state) self._call_callbacks( - 'on_step_end', self.physical_system.k, state, reference, reward, self._done + 'on_step_end', self.physical_system.k, state, reference, reward, self._terminated ) - return (state[self.state_filter], ref_next), reward, self._done, {} + return (state[self.state_filter], ref_next), reward, self._terminated, self._truncated,{} def _seed(self, seed=None): sg = np.random.SeedSequence(seed) @@ -653,7 +654,7 @@ def on_step_begin(self, k, action): """Gets called at the beginning of each step""" pass - def on_step_end(self, k, state, reference, reward, done): + def on_step_end(self, k, state, reference, reward, terminated): """Gets called at the end of each step""" pass diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py index 5a5cc252..b0b35910 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py @@ -76,12 +76,12 @@ class ContCurrentControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py index 59ff3741..9657326e 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py @@ -76,12 +76,12 @@ class ContSpeedControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py index 583191d2..836da426 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py @@ -76,12 +76,12 @@ class ContTorqueControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py index 0b3777cf..4bbf5998 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py @@ -76,12 +76,12 @@ class FiniteCurrentControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py index 321a28d9..aa050424 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py @@ -76,12 +76,12 @@ class FiniteSpeedControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py index bbcba120..38109686 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py @@ -76,12 +76,12 @@ class FiniteTorqueControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py index a9c38fb5..c61dc8dd 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py @@ -76,12 +76,12 @@ class ContCurrentControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__( self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py index 70a4da74..08408540 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py @@ -76,12 +76,12 @@ class ContSpeedControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py index 7cc7d36e..73ccb15a 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py @@ -76,12 +76,12 @@ class ContTorqueControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py index c2f8eba7..a74dd86f 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py @@ -76,12 +76,12 @@ class FiniteCurrentControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment) ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__( self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py index 8abde974..dba8641c 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py @@ -76,12 +76,12 @@ class FiniteSpeedControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__( self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py index 21207b01..6e4325ba 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py @@ -76,12 +76,12 @@ class FiniteTorqueControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__( self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py index 016e1878..a728d2b8 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py @@ -76,12 +76,12 @@ class ContCurrentControlDcSeriesMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py index 46d99492..b7f280c0 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py @@ -76,12 +76,12 @@ class ContSpeedControlDcSeriesMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py index 432f737f..e3b42163 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py @@ -76,12 +76,12 @@ class ContTorqueControlDcSeriesMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py index c1cf1bd2..6fadd79c 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py @@ -76,12 +76,12 @@ class FiniteCurrentControlDcSeriesMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py index 01e8368b..1bd64c30 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py @@ -76,12 +76,12 @@ class FiniteSpeedControlDcSeriesMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py index 6a1e6f3b..3d49ede1 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py @@ -76,12 +76,12 @@ class FiniteTorqueControlDcSeriesMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py index 85a4d1e0..b5d587f4 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py @@ -77,12 +77,12 @@ class ContCurrentControlDcShuntMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py index cb0b78d3..02862f6e 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py @@ -77,12 +77,12 @@ class ContSpeedControlDcShuntMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py index ee0da0aa..c9036f59 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py @@ -77,12 +77,12 @@ class ContTorqueControlDcShuntMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py index 00bf0c08..deb4a19e 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py @@ -77,12 +77,12 @@ class FiniteCurrentControlDcShuntMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py index b8b0a13a..df4610a6 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py @@ -77,12 +77,12 @@ class FiniteSpeedControlDcShuntMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py index 180fa309..937f5b85 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py @@ -77,12 +77,12 @@ class FiniteTorqueControlDcShuntMotorEnv(ElectricMotorEnvironment): ... converter=my_overridden_converter, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py index 8f846906..814a8bba 100644 --- a/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py @@ -77,12 +77,12 @@ class ContCurrentControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnviro ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py index 8f6f7f55..5cd8940f 100644 --- a/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py @@ -77,12 +77,12 @@ class ContSpeedControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnvironm ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py index aff20613..ae57f232 100644 --- a/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py @@ -78,12 +78,12 @@ class ContTorqueControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnviron ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py index 6c627566..da78891e 100644 --- a/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py @@ -77,12 +77,12 @@ class FiniteCurrentControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnvi ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py index 0587a20f..32bdf897 100644 --- a/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py @@ -77,12 +77,12 @@ class FiniteSpeedControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnviro ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py index 2890b0fa..bff56d24 100644 --- a/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py @@ -77,12 +77,12 @@ class FiniteTorqueControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnvir ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py index cc9575b7..db45bbbd 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py @@ -84,12 +84,12 @@ class ContCurrentControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__( self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py index f83b5503..7ff678be 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py @@ -84,12 +84,12 @@ class ContSpeedControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py index 0666944e..e00fd364 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py @@ -84,12 +84,12 @@ class ContTorqueControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py index 71b83c26..5d9ef33a 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py @@ -84,12 +84,12 @@ class FiniteCurrentControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py index 130208ad..62b9b1ba 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py @@ -84,12 +84,12 @@ class FiniteSpeedControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py index e230e384..8fc60481 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py @@ -84,12 +84,12 @@ class FiniteTorqueControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py index 26b660d0..f3e3a00d 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py @@ -82,12 +82,12 @@ class ContCurrentControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py index 25b592d8..7cbd7352 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py @@ -82,12 +82,12 @@ class ContSpeedControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py index b3b7d248..561a3f18 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py @@ -82,12 +82,12 @@ class ContTorqueControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py index f6f495b1..47f35276 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py @@ -82,12 +82,12 @@ class FiniteCurrentControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py index 19236fc8..c18c5cbb 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py @@ -82,12 +82,12 @@ class FiniteSpeedControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py index ad6a677f..81c73b3e 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py @@ -82,12 +82,12 @@ class FiniteTorqueControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment) ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py index 4d607460..67ff9a6b 100644 --- a/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py @@ -77,12 +77,12 @@ class ContCurrentControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironm ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py index 2f96ba5c..ff0ed3e9 100644 --- a/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py @@ -77,12 +77,12 @@ class ContSpeedControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironmen ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py index 7722621a..5a34c282 100644 --- a/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py @@ -77,12 +77,12 @@ class ContTorqueControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironme ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py index e8f90edd..1e58b5ce 100644 --- a/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py @@ -77,12 +77,12 @@ class FiniteCurrentControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnviro ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py index 4f09c436..51493b8c 100644 --- a/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py @@ -77,12 +77,12 @@ class FiniteSpeedControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironm ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py index 79fc525b..bedb48c9 100644 --- a/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py @@ -77,12 +77,12 @@ class FiniteTorqueControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnviron ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py index 69258072..1c214525 100644 --- a/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py @@ -77,12 +77,12 @@ class ContCurrentControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py index 7d79eff8..e0a03062 100644 --- a/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py @@ -77,12 +77,12 @@ class ContSpeedControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py index 34b319bd..b7c62db3 100644 --- a/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py @@ -77,12 +77,12 @@ class ContTorqueControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py index 04c8aded..fac6024b 100644 --- a/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py @@ -77,12 +77,12 @@ class FiniteCurrentControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py index 9c2d3f79..e0d0e962 100644 --- a/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py @@ -77,12 +77,12 @@ class FiniteSpeedControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py index 7d86e9e8..91579fe2 100644 --- a/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py @@ -77,12 +77,12 @@ class FiniteTorqueControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment) ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), diff --git a/gym_electric_motor/physical_systems/mechanical_loads/polynomial_static_load.py b/gym_electric_motor/physical_systems/mechanical_loads/polynomial_static_load.py index 5a6bb351..17565758 100644 --- a/gym_electric_motor/physical_systems/mechanical_loads/polynomial_static_load.py +++ b/gym_electric_motor/physical_systems/mechanical_loads/polynomial_static_load.py @@ -27,12 +27,12 @@ class PolynomialStaticLoad(MechanicalLoad): ... 'Cont-SC-ExtExDc-v0', ... load=my_poly_static_load ... ) - >>> done = True + >>> terminated = True >>> for _ in range(1000): - >>> if done: + >>> if terminated: >>> state, reference = env.reset() >>> env.render() - >>> (state, reference), reward, done, _ = env.step(env.action_space.sample()) + >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ diff --git a/gym_electric_motor/visualization/console_printer.py b/gym_electric_motor/visualization/console_printer.py index 8b1941c3..6226c96b 100644 --- a/gym_electric_motor/visualization/console_printer.py +++ b/gym_electric_motor/visualization/console_printer.py @@ -54,7 +54,7 @@ def on_step_begin(self, k, action): self._k = k self._action = action - def on_step_end(self, k, state, reference, reward, done): + def on_step_end(self, k, state, reference, reward, terminated): """Gets called at each step of the environment. Handles per step printing as well es constraint violation printing""" self._k = k @@ -62,7 +62,7 @@ def on_step_end(self, k, state, reference, reward, done): self._reference = reference self._reward = reward self._cum_reward += reward - self._done = done + self._done = terminated def render(self): if self._print_freq > 0: diff --git a/gym_electric_motor/visualization/motor_dashboard.py b/gym_electric_motor/visualization/motor_dashboard.py index fce7b833..76e5d7ef 100644 --- a/gym_electric_motor/visualization/motor_dashboard.py +++ b/gym_electric_motor/visualization/motor_dashboard.py @@ -115,7 +115,7 @@ def on_step_begin(self, k, action): for plot in self._plots: plot.on_step_begin(k, action) - def on_step_end(self, k, state, reference, reward, done): + def on_step_end(self, k, state, reference, reward, terminated): """The information after the step is passed Args: @@ -124,10 +124,10 @@ def on_step_end(self, k, state, reference, reward, done): reference(array(float)): The reference corresponding to the state :math:`s^*_k`. reward(float): The reward that has been received for the last action that lead to the current state :math:`r_{k}`. - done(bool): Flag, that indicates, if the last action lead to a terminal state :math:`t_{k}`. + terminated(bool): Flag, that indicates, if the last action lead to a terminal state :math:`t_{k}`. """ for plot in self._plots: - plot.on_step_end(k, state, reference, reward, done) + plot.on_step_end(k, state, reference, reward, terminated) self._k += 1 if self._k % self._update_interval == 0: self._update_render = True diff --git a/gym_electric_motor/visualization/motor_dashboard_plots/base_plots.py b/gym_electric_motor/visualization/motor_dashboard_plots/base_plots.py index 80fe6be8..c1ead86e 100644 --- a/gym_electric_motor/visualization/motor_dashboard_plots/base_plots.py +++ b/gym_electric_motor/visualization/motor_dashboard_plots/base_plots.py @@ -172,10 +172,10 @@ def on_reset_begin(self): self._reset_memory.append(self._t) self._done = False - def on_step_end(self, k, state, reference, reward, done): + def on_step_end(self, k, state, reference, reward, terminated): self._k += 1 self._t += self._tau - self._done = done + self._done = terminated def render(self): super().render() diff --git a/gym_electric_motor/visualization/motor_dashboard_plots/cumulative_constraint_violation_plot.py b/gym_electric_motor/visualization/motor_dashboard_plots/cumulative_constraint_violation_plot.py index acd4d489..43b51214 100644 --- a/gym_electric_motor/visualization/motor_dashboard_plots/cumulative_constraint_violation_plot.py +++ b/gym_electric_motor/visualization/motor_dashboard_plots/cumulative_constraint_violation_plot.py @@ -20,9 +20,9 @@ def reset_data(self): super().reset_data() self._violations = [0] - def on_step_end(self, k, state, reference, reward, done): - super().on_step_end(k, state, reference, reward, done) - if done: + def on_step_end(self, k, state, reference, reward, terminated): + super().on_step_end(k, state, reference, reward, terminated) + if terminated: # Add another point for a step-like plot self._x_data.append(self._k - 1) self._violations.append(self._no_of_violations) diff --git a/gym_electric_motor/visualization/motor_dashboard_plots/episode_length_plot.py b/gym_electric_motor/visualization/motor_dashboard_plots/episode_length_plot.py index a171cda6..f4068434 100644 --- a/gym_electric_motor/visualization/motor_dashboard_plots/episode_length_plot.py +++ b/gym_electric_motor/visualization/motor_dashboard_plots/episode_length_plot.py @@ -21,7 +21,7 @@ def initialize(self, axis): super().initialize(axis) self._lines.append(self._axis.plot([], [], color=self._colors[0])[0]) - def on_step_end(self, k, state, reference, reward, done): + def on_step_end(self, k, state, reference, reward, terminated): self._episode_length = k def reset_data(self): diff --git a/gym_electric_motor/visualization/motor_dashboard_plots/mean_episode_reward_plot.py b/gym_electric_motor/visualization/motor_dashboard_plots/mean_episode_reward_plot.py index ce98c2d3..418258a8 100644 --- a/gym_electric_motor/visualization/motor_dashboard_plots/mean_episode_reward_plot.py +++ b/gym_electric_motor/visualization/motor_dashboard_plots/mean_episode_reward_plot.py @@ -22,8 +22,8 @@ def initialize(self, axis): self._y_data.append(self._reward_data) self._lines.append(self._axis.plot([], self._reward_data, color=self._colors[0])[0]) - def on_step_end(self, k, state, reference, reward, done): - super().on_step_end(k, state, reference, reward, done) + def on_step_end(self, k, state, reference, reward, terminated): + super().on_step_end(k, state, reference, reward, terminated) self._reward_sum += reward self._episode_length = k diff --git a/gym_electric_motor/visualization/motor_dashboard_plots/reward_plot.py b/gym_electric_motor/visualization/motor_dashboard_plots/reward_plot.py index 354437bc..8a2b1d63 100644 --- a/gym_electric_motor/visualization/motor_dashboard_plots/reward_plot.py +++ b/gym_electric_motor/visualization/motor_dashboard_plots/reward_plot.py @@ -34,8 +34,8 @@ def reset_data(self): super().reset_data() self._reward_data = np.full(shape=self._x_data.shape, fill_value=np.nan) - def on_step_end(self, k, state, reference, reward, done): + def on_step_end(self, k, state, reference, reward, terminated): idx = self.data_idx self._x_data[idx] = self._t self._reward_data[idx] = reward - super().on_step_end(k, state, reference, reward, done) + super().on_step_end(k, state, reference, reward, terminated) diff --git a/gym_electric_motor/visualization/motor_dashboard_plots/state_plot.py b/gym_electric_motor/visualization/motor_dashboard_plots/state_plot.py index 9f278d9e..f614967d 100644 --- a/gym_electric_motor/visualization/motor_dashboard_plots/state_plot.py +++ b/gym_electric_motor/visualization/motor_dashboard_plots/state_plot.py @@ -138,8 +138,8 @@ def initialize(self, axis): self._y_data = [self._state_data, self._ref_data] - def on_step_end(self, k, state, reference, reward, done): - super().on_step_end(k, state, reference, reward, done) + def on_step_end(self, k, state, reference, reward, terminated): + super().on_step_end(k, state, reference, reward, terminated) # Write the data to the data containers state_ = state[self._state_idx] ref = reference[self._state_idx] diff --git a/tests/integration_tests/test_environment_execution.py b/tests/integration_tests/test_environment_execution.py index 2815f905..f9e2b267 100644 --- a/tests/integration_tests/test_environment_execution.py +++ b/tests/integration_tests/test_environment_execution.py @@ -16,14 +16,14 @@ def test_execution(dc_motor, control_task, action_type, version, no_of_steps): env_id = f'{action_type}-{control_task}-{dc_motor}-{version}' env = gem.make(env_id) - done = True + terminated = True for i in range(no_of_steps): - if done: + if terminated: observation = env.reset() state, reference = observation action = env.action_space.sample() assert action in env.action_space - observation, reward, done, info = env.step(action) + observation, reward, terminated, truncated, info = env.step(action) assert not np.any(np.isnan(observation[0])), 'An invalid nan-value is in the state.' assert not np.any(np.isnan(observation[1])), 'An invalid nan-value is in the reference.' assert info == {} diff --git a/tests/integration_tests/test_environment_seeding.py b/tests/integration_tests/test_environment_seeding.py index 7b26275f..4f9207ff 100644 --- a/tests/integration_tests/test_environment_seeding.py +++ b/tests/integration_tests/test_environment_seeding.py @@ -21,7 +21,7 @@ def test_seeding_same_env(dc_motor, control_task, action_type, version, no_of_st env = gem.make(env_id) # Sample actions that are used in both executions actions = [env.action_space.sample() for _ in range(no_of_steps)] - done = True + terminated = True states1 = [] references1 = [] rewards1 = [] @@ -34,7 +34,7 @@ def test_seeding_same_env(dc_motor, control_task, action_type, version, no_of_st rewards1.append(reward) states1.append(state) references1.append(reference) - done1.append(done) + done1.append(terminated) done = True states2 = [] @@ -49,7 +49,7 @@ def test_seeding_same_env(dc_motor, control_task, action_type, version, no_of_st rewards2.append(reward) states2.append(state) references2.append(reference) - done2.append(done) + done2.append(terminated) # Assure that the epsiodes of the initially and reseeded environment are equal references1 = np.array(references1).flatten() @@ -71,7 +71,7 @@ def test_seeding_new_env(dc_motor, control_task, action_type, version, no_of_ste env_id = f'{action_type}-{control_task}-{dc_motor}-{version}' env = gem.make(env_id) actions = [env.action_space.sample() for _ in range(no_of_steps)] - done = True + terminated = True states1 = [] references1 = [] @@ -85,7 +85,7 @@ def test_seeding_new_env(dc_motor, control_task, action_type, version, no_of_ste rewards1.append(reward) states1.append(state) references1.append(reference) - done1.append(done) + done1.append(terminated) env = gem.make(env_id) done = True @@ -99,11 +99,11 @@ def test_seeding_new_env(dc_motor, control_task, action_type, version, no_of_ste state, reference = env.reset(seed) action = env.action_space.sample() assert action in env.action_space - (state, reference), reward, done, info = env.step(actions[i]) + (state, reference), reward, terminated, info = env.step(actions[i]) rewards2.append(reward) states2.append(state) references2.append(reference) - done2.append(done) + done2.append(terminated) # Assure that the episodes of both environments are equal assert (np.all(np.array(states1) == np.array(states2))) diff --git a/tests/test_core.py b/tests/test_core.py index 25b7068d..fd8034fd 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -132,7 +132,7 @@ def test_step(self, env, action, set_done): for callback in cbs: assert callback.step_begin == 0 assert callback.step_end == 0 - (state, reference), reward, done, _ = env.step(action) + (state, reference), reward, terminated, truncated, _ = env.step(action) # Each of callback's step functions were called in step for callback in cbs: assert callback.step_begin == 1 @@ -144,7 +144,7 @@ def test_step(self, env, action, set_done): 'State passed to the Reference Generator not equal to Physical System state' assert ps.action == action, 'Action passed to Physical System not equal to selected action' assert reward == -1 if set_done else 1 - assert done == set_done + assert terminated == set_done # If episode terminated, no further step without reset if set_done: with pytest.raises(Exception): diff --git a/tests/testing_utils.py b/tests/testing_utils.py index 03cb14db..0272261b 100644 --- a/tests/testing_utils.py +++ b/tests/testing_utils.py @@ -199,7 +199,7 @@ def __init__(self, **kwargs): self.last_action = None self.last_time_step = None self.closed = False - self.done = False + self.terminated = False self.kwargs = kwargs super().__init__() From c1acb3bc62f5b4e5c3f77b07980cf3666f8f03b7 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Sun, 18 Jun 2023 14:22:07 +0200 Subject: [PATCH 19/37] applying changes in .step() returns to test --- gym_electric_motor/core.py | 2 +- .../test_environment_seeding.py | 40 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 82143b76..9d866972 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -287,7 +287,7 @@ def step(self, action): self._call_callbacks( 'on_step_end', self.physical_system.k, state, reference, reward, self._terminated ) - return (state[self.state_filter], ref_next), reward, self._terminated, self._truncated,{} + return (state[self.state_filter], ref_next), reward, self._terminated, self._truncated, {} def _seed(self, seed=None): sg = np.random.SeedSequence(seed) diff --git a/tests/integration_tests/test_environment_seeding.py b/tests/integration_tests/test_environment_seeding.py index 4f9207ff..c036d437 100644 --- a/tests/integration_tests/test_environment_seeding.py +++ b/tests/integration_tests/test_environment_seeding.py @@ -25,31 +25,31 @@ def test_seeding_same_env(dc_motor, control_task, action_type, version, no_of_st states1 = [] references1 = [] rewards1 = [] - done1 = [] + terminated1 = [] # Execute the env for i in range(no_of_steps): - if done: + if terminated: state, reference = env.reset(seed) - (state, reference), reward, done, info = env.step(actions[i]) + (state, reference), reward, terminated, truncated, info = env.step(actions[i]) rewards1.append(reward) states1.append(state) references1.append(reference) - done1.append(terminated) + terminated1.append(terminated) - done = True + terminated = True states2 = [] references2 = [] rewards2 = [] - done2 = [] + terminated2 = [] # Execute the environment again for i in range(no_of_steps): - if done: + if terminated: state, reference = env.reset(seed) - (state, reference), reward, done, info = env.step(actions[i]) + (state, reference), reward, terminated, truncated, info = env.step(actions[i]) rewards2.append(reward) states2.append(state) references2.append(reference) - done2.append(terminated) + terminated2.append(terminated) # Assure that the epsiodes of the initially and reseeded environment are equal references1 = np.array(references1).flatten() @@ -57,7 +57,7 @@ def test_seeding_same_env(dc_motor, control_task, action_type, version, no_of_st assert(np.all(np.array(states1) == np.array(states2))) assert(np.all(np.array(references1).flatten() == np.array(references2).flatten())) assert(np.all(np.array(rewards1) == np.array(rewards2))) - assert (np.all(np.array(done1) == np.array(done2))) + assert (np.all(np.array(terminated1) == np.array(terminated2))) @pytest.mark.parametrize('no_of_steps', [100]) @@ -76,37 +76,37 @@ def test_seeding_new_env(dc_motor, control_task, action_type, version, no_of_ste states1 = [] references1 = [] rewards1 = [] - done1 = [] + terminated1 = [] for i in range(no_of_steps): - if done: + if terminated: state, reference = env.reset(seed) - (state, reference), reward, done, info = env.step(actions[i]) + (state, reference), reward, terminated, truncated, info = env.step(actions[i]) rewards1.append(reward) states1.append(state) references1.append(reference) - done1.append(terminated) + terminated1.append(terminated) env = gem.make(env_id) - done = True + terminated = True states2 = [] references2 = [] rewards2 = [] - done2 = [] + terminated2 = [] for i in range(no_of_steps): - if done: + if terminated: state, reference = env.reset(seed) action = env.action_space.sample() assert action in env.action_space - (state, reference), reward, terminated, info = env.step(actions[i]) + (state, reference), reward, terminated, truncated, info = env.step(actions[i]) rewards2.append(reward) states2.append(state) references2.append(reference) - done2.append(terminated) + terminated2.append(terminated) # Assure that the episodes of both environments are equal assert (np.all(np.array(states1) == np.array(states2))) assert (np.all(np.array(references1).flatten() == np.array(references2).flatten())) assert (np.all(np.array(rewards1) == np.array(rewards2))) - assert (np.all(np.array(done1) == np.array(done2))) + assert (np.all(np.array(terminated1) == np.array(terminated2))) From 0305a4ef7738c925d3b5e0a81beb068d8efa9e7b Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Fri, 23 Jun 2023 11:54:03 +0200 Subject: [PATCH 20/37] render_mode human and None working --- .../classic_controllers_dc_motor_example.py | 4 ++-- ...assic_controllers_dc_motor_integration_test.py | 7 +++---- .../controllers/cascaded_controller.py | 8 +++++--- gym_electric_motor/core.py | 15 ++++++++++++--- .../permex_dc_motor_env/cont_tc_permex_dc_env.py | 4 ++-- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_example.py b/examples/classic_controllers/classic_controllers_dc_motor_example.py index 862a05e9..f66d5a58 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_example.py @@ -38,8 +38,7 @@ external_ref_plots = [ExternallyReferencedStatePlot(state) for state in states] # initialize the gym-electric-motor environment - env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots)) - + env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="file") """ initialize the controller @@ -51,6 +50,7 @@ a (optional) tuning parameter of the symmetrical optimum (default: 4) """ + visualization=MotorDashboard(additional_plots=external_ref_plots) controller = Controller.make(env, external_ref_plots=external_ref_plots) state, reference = env.reset(seed = None) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py index bde8fd84..b345d384 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py @@ -38,9 +38,8 @@ external_ref_plots = [ExternallyReferencedStatePlot(state) for state in states] # initialize the gym-electric-motor environment - env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots)) - env.seed(1337) - + env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="file") + """ initialize the controller @@ -54,7 +53,7 @@ """ controller = Controller.make(env, external_ref_plots=external_ref_plots) - state, reference = env.reset() + state, reference = env.reset(seed=1337) # simulate the environment for i in range(10001): action = controller.control(state, reference) diff --git a/examples/classic_controllers/controllers/cascaded_controller.py b/examples/classic_controllers/controllers/cascaded_controller.py index 3b60f8d0..9296a179 100644 --- a/examples/classic_controllers/controllers/cascaded_controller.py +++ b/examples/classic_controllers/controllers/cascaded_controller.py @@ -16,6 +16,7 @@ class CascadedController: def __init__(self, environment, stages, _controllers, visualization, ref_states, external_ref_plots=(), **controller_kwargs): + self.env = environment self.visualization = visualization self.action_space = environment.action_space self.state_space = environment.physical_system.state_space @@ -171,9 +172,10 @@ def control(self, state, reference): else: action = np.array([action, action_u_e], dtype='object') - # Plot the external references - plot(external_reference_plots=self.external_ref_plots, state_names=self.state_names, - visualization=self.visualization, external_data=self.get_plot_data()) + if self.env.render_mode in ["human", "file"]: + # Plot the external references + plot(external_reference_plots=self.external_ref_plots, state_names=self.state_names, + visualization=self.visualization, external_data=self.get_plot_data()) return action diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index e5123bda..ab534584 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -165,7 +165,7 @@ def visualizations(self): return self._visualizations def __init__(self, physical_system, reference_generator, reward_function, visualization=(), state_filter=None, - callbacks=(), constraints=(), physical_system_wrappers=(), **kwargs): + callbacks=(), constraints=(), physical_system_wrappers=(), render_mode=None, **kwargs): """ Setting and initialization of all environments' modules. @@ -186,6 +186,7 @@ def __init__(self, physical_system, reference_generator, reward_function, visual state_filter(list(str)): Selection of states that are shown in the observation. physical_system_wrappers(iterable(PhysicalSystemWrapper)): PhysicalSystemWrapper instances to be wrapped around the physical system. + render_mode(str) : if visualization is given, render_mode is set to "human", else render_mode ist set to None callbacks(list(Callback)): Callbacks being called in the environment **kwargs: Arguments to be passed to the modules. """ @@ -226,6 +227,13 @@ def __init__(self, physical_system, reference_generator, reward_function, visual self.action_space = self.physical_system.action_space self.reward_range = self._reward_function.reward_range self._done = True + + # Set render mode and metadata + render_modes = [None, "human", "file"] + self.metadata = {"render_modes": render_modes} + assert render_mode in render_modes + self.render_mode = render_mode + self._callbacks = list(callbacks) self._callbacks += list(self._visualizations) self._call_callbacks('set_env', self) @@ -257,8 +265,9 @@ def render(self, *_, **__): """ Update the visualization of the motor. """ - for visualization in self._visualizations: - visualization.render() + if self.render_mode == "human": + for visualization in self._visualizations: + visualization.render() def step(self, action): """Perform one simulation step of the environment with an action of the action space. diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py index 7cc7d36e..15344753 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py @@ -86,7 +86,7 @@ class ContTorqueControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=()): + constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -148,5 +148,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) From e8ea66acac9227b877f2ce16bb6029f5fe1f3272 Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Fri, 23 Jun 2023 13:08:26 +0200 Subject: [PATCH 21/37] render_mode "file" is working --- .../classic_controllers_dc_motor_example.py | 3 +-- gym_electric_motor/__init__.py | 5 +++- gym_electric_motor/core.py | 25 +++++++++++++++++-- gym_electric_motor/utils.py | 2 +- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_example.py b/examples/classic_controllers/classic_controllers_dc_motor_example.py index 6cf178c6..3fab1f38 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_example.py @@ -50,14 +50,13 @@ a (optional) tuning parameter of the symmetrical optimum (default: 4) """ - visualization=MotorDashboard(additional_plots=external_ref_plots) + visualization = MotorDashboard(additional_plots=external_ref_plots) controller = Controller.make(env, external_ref_plots=external_ref_plots) state, reference = env.reset(seed = None) # simulate the environment for i in range(10001): action = controller.control(state, reference) - env.render() (state, reference), reward, terminated, truncated, _ = env.step(action) if terminated: env.reset() diff --git a/gym_electric_motor/__init__.py b/gym_electric_motor/__init__.py index 4070c032..2a73df67 100644 --- a/gym_electric_motor/__init__.py +++ b/gym_electric_motor/__init__.py @@ -5,7 +5,7 @@ from .core import ConstraintMonitor from .random_component import RandomComponent from .constraints import Constraint, LimitConstraint -from .utils import make, register_superclass +from .utils import register_superclass register_superclass(RewardFunction) register_superclass(ElectricMotorVisualization) @@ -18,6 +18,9 @@ import gym_electric_motor.physical_systems import gym_electric_motor.envs import gym_electric_motor.physical_system_wrappers +import gym_electric_motor.core + +make = core.ElectricMotorEnvironment.make from gymnasium.envs.registration import register import gymnasium diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 148720ff..0ffa7896 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -17,6 +17,8 @@ - Visualization of the PhysicalSystems state, reference and reward for the user. """ +import datetime + import gymnasium import numpy as np from gymnasium.spaces import Box @@ -164,6 +166,8 @@ def visualizations(self): """Returns a list of all active motor visualizations.""" return self._visualizations + env_id = "0" + def __init__(self, physical_system, reference_generator, reward_function, visualization=(), state_filter=None, callbacks=(), constraints=(), physical_system_wrappers=(), render_mode=None, **kwargs): """ @@ -241,6 +245,11 @@ def __init__(self, physical_system, reference_generator, reward_function, visual self._callbacks += list(self._visualizations) self._call_callbacks('set_env', self) + def make(env_id, *args, **kwargs): + env = gymnasium.make(env_id, *args, **kwargs) + env.env_id = env_id + return env + def _call_callbacks(self, func_name, *args): """Calls each callback's func_name function with *args""" for callback in self._callbacks: @@ -268,7 +277,7 @@ def render(self, *_, **__): """ Update the visualization of the motor. """ - if self.render_mode == "human": + if self.render_mode in ["human", "file"]: for visualization in self._visualizations: visualization.render() @@ -298,6 +307,11 @@ def step(self, action): self._call_callbacks( 'on_step_end', self.physical_system.k, state, reference, reward, self._terminated ) + + # Call render code + if self.render_mode in ["human", "file"]: + self.render() + return (state[self.state_filter], ref_next), reward, self._terminated, self._truncated, {} def _seed(self, seed=None): @@ -315,13 +329,20 @@ def _seed(self, seed=None): return [sg.entropy] def close(self): + # Save figure with timestamp as filename + if self.render_mode == "file": + figure = self._get_figure() + timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S") + + filename = f"{self.env_id}_{timestamp}.png" + figure.savefig(filename, dpi=300) """Called when the environment is deleted. Closes all its modules.""" self._call_callbacks('on_close') self._reward_function.close() self._physical_system.close() self._reference_generator.close() - def get_figure(self): + def _get_figure(self): """ Get main figure (MotorDashboard) """ assert len(self._visualizations) == 1 motor_dashboard = self._visualizations[0] diff --git a/gym_electric_motor/utils.py b/gym_electric_motor/utils.py index 7c060908..7c907f00 100644 --- a/gym_electric_motor/utils.py +++ b/gym_electric_motor/utils.py @@ -159,4 +159,4 @@ def update_parameter_dict(source_dict, update_dict, copy=True): #: Short notation for the gymnasium.make call to avoid the necessary import of gym when making environments. -make = gymnasium.make +# make = gymnasium.make From 6b6267f55388fb8e89bdb3879abffc523db8f40c Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Fri, 23 Jun 2023 13:30:38 +0200 Subject: [PATCH 22/37] customizable filename prefix for "file" mode --- .../classic_controllers_dc_motor_integration_test.py | 7 ++----- gym_electric_motor/core.py | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py index b1fedb2e..a8ca4076 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py @@ -39,7 +39,7 @@ # initialize the gym-electric-motor environment env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="file") - + env.metadata["filename_prefix"] = "integration-test" """ initialize the controller @@ -53,16 +53,13 @@ """ controller = Controller.make(env, external_ref_plots=external_ref_plots) - state, reference = env.reset(seed=1337) + state, reference = env.reset(seed=1972) # simulate the environment for i in range(10001): action = controller.control(state, reference) - env.render() (state, reference), reward, terminated, truncated, _ = env.step(action) if terminated: env.reset() controller.reset() - fig = env.get_figure() - fig.savefig("test3.png", dpi=300) env.close() diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 0ffa7896..16445fe1 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -236,7 +236,7 @@ def __init__(self, physical_system, reference_generator, reward_function, visual # Set render mode and metadata render_modes = [None, "human", "file"] - self.metadata = {"render_modes": render_modes} + self.metadata["render_modes"] = render_modes assert render_mode in render_modes self.render_mode = render_mode @@ -247,7 +247,7 @@ def __init__(self, physical_system, reference_generator, reward_function, visual def make(env_id, *args, **kwargs): env = gymnasium.make(env_id, *args, **kwargs) - env.env_id = env_id + env.metadata["filename_prefix"] = env_id return env def _call_callbacks(self, func_name, *args): @@ -333,8 +333,8 @@ def close(self): if self.render_mode == "file": figure = self._get_figure() timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S") - - filename = f"{self.env_id}_{timestamp}.png" + filename_prefix = self.metadata["filename_prefix"] + filename = f"{filename_prefix}_{timestamp}.png" figure.savefig(filename, dpi=300) """Called when the environment is deleted. Closes all its modules.""" self._call_callbacks('on_close') From ad70e317b4acb727e300ee28a3a7e9f854141739 Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Fri, 23 Jun 2023 13:41:04 +0200 Subject: [PATCH 23/37] create a output folder "plots" for saved figs --- .gitignore | 2 ++ gym_electric_motor/core.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f6c3b0be..bfcc7603 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,5 @@ examples/logs/ /my_examples/ .vscode/settings.json .vscode/launch.json + +plots/ \ No newline at end of file diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 16445fe1..26c6ad6c 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -17,6 +17,7 @@ - Visualization of the PhysicalSystems state, reference and reward for the user. """ +import os import datetime import gymnasium @@ -331,10 +332,16 @@ def _seed(self, seed=None): def close(self): # Save figure with timestamp as filename if self.render_mode == "file": + # create output folder if it not exists + output_folder_name = "plots" + if not os.path.exists(output_folder_name): + # Create the folder "gem_output" + os.makedirs(output_folder_name) + figure = self._get_figure() timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S") filename_prefix = self.metadata["filename_prefix"] - filename = f"{filename_prefix}_{timestamp}.png" + filename = f"{output_folder_name}/{filename_prefix}_{timestamp}.png" figure.savefig(filename, dpi=300) """Called when the environment is deleted. Closes all its modules.""" self._call_callbacks('on_close') From d0322ffd6270dfbc1bc427e3768672438c57b998 Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Fri, 23 Jun 2023 13:41:13 +0200 Subject: [PATCH 24/37] removed render() call --- README.md | 1 - .../classic_controllers/classic_controllers_ind_motor_example.py | 1 - .../classic_controllers_synch_motor_example.py | 1 - .../custom_classic_controllers_dc_motor_example.py | 1 - .../custom_classic_controllers_ind_motor_example.py | 1 - .../custom_classic_controllers_synch_motor_example.py | 1 - examples/classic_controllers/external_plot.py | 1 - examples/classic_controllers/externally_referenced_state_plot.py | 1 - examples/environment_features/external_speed_profile.py | 1 - examples/environment_features/userdefined_initialization.py | 1 - .../envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py | 1 - .../envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py | 1 - .../envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py | 1 - .../envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py | 1 - .../envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py | 1 - .../envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py | 1 - .../envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py | 1 - .../envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py | 1 - .../envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py | 1 - .../envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py | 1 - .../envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py | 1 - .../envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py | 1 - .../envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py | 1 - .../envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py | 1 - .../envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py | 1 - .../envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py | 1 - .../envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py | 1 - .../envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py | 1 - .../envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py | 1 - .../envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py | 1 - .../envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py | 1 - .../envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py | 1 - .../envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py | 1 - .../envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py | 1 - gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py | 1 - gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py | 1 - gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py | 1 - gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py | 1 - gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py | 1 - gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py | 1 - .../gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py | 1 - .../gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py | 1 - .../gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py | 1 - .../gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py | 1 - .../gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py | 1 - .../gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py | 1 - .../squirrel_cage_induction_motor_envs/cont_cc_scim_env.py | 1 - .../squirrel_cage_induction_motor_envs/cont_sc_scim_env.py | 1 - .../squirrel_cage_induction_motor_envs/cont_tc_scim_env.py | 1 - .../squirrel_cage_induction_motor_envs/finite_cc_scim_env.py | 1 - .../squirrel_cage_induction_motor_envs/finite_sc_scim_env.py | 1 - .../squirrel_cage_induction_motor_envs/finite_tc_scim_env.py | 1 - gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py | 1 - gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py | 1 - gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py | 1 - gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py | 1 - gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py | 1 - gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py | 1 - gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py | 1 - gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py | 1 - gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py | 1 - gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py | 1 - gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py | 1 - gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py | 1 - .../physical_systems/mechanical_loads/polynomial_static_load.py | 1 - 65 files changed, 65 deletions(-) diff --git a/README.md b/README.md index 008c4e40..8fa0842f 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,6 @@ if __name__ == '__main__': env = gem.make("Finite-CC-PMSM-v0") # instantiate a discretely controlled PMSM env.reset() for _ in range(10000): - env.render() # visualize environment (states, references), rewards, done, _ =\ env.step(env.action_space.sample()) # pick random control actions if done: diff --git a/examples/classic_controllers/classic_controllers_ind_motor_example.py b/examples/classic_controllers/classic_controllers_ind_motor_example.py index 0eceb6fe..d026eb37 100644 --- a/examples/classic_controllers/classic_controllers_ind_motor_example.py +++ b/examples/classic_controllers/classic_controllers_ind_motor_example.py @@ -50,7 +50,6 @@ # simulate the environment for i in range(10001): - env.render() action = controller.control(state, reference) (state, reference), reward, terminated, truncated, _ = env.step(action) if terminated: diff --git a/examples/classic_controllers/classic_controllers_synch_motor_example.py b/examples/classic_controllers/classic_controllers_synch_motor_example.py index aa7a4c5b..045dc432 100644 --- a/examples/classic_controllers/classic_controllers_synch_motor_example.py +++ b/examples/classic_controllers/classic_controllers_synch_motor_example.py @@ -54,7 +54,6 @@ # simulate the environment for i in range(10001): - env.render() action = controller.control(state, reference) (state, reference), reward, terminated, truncated, _ = env.step(action) if terminated: diff --git a/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py b/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py index 51ab8bc5..b9f48ed3 100644 --- a/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py @@ -74,7 +74,6 @@ # simulate the environment for i in range(10001): action = controller.control(state, reference) - env.render() (state, reference), reward, terminated, truncated, _ = env.step(action) if terminated: env.reset() diff --git a/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py b/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py index cc9b696f..d4d5a0f9 100644 --- a/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_ind_motor_example.py @@ -53,7 +53,6 @@ # simulate the environment for i in range(10001): - env.render() action = controller.control(state, reference) (state, reference), reward, terminated, truncated, _ = env.step(action) if terminated: diff --git a/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py b/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py index b4d5f2cc..e8127bda 100644 --- a/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py @@ -104,7 +104,6 @@ # simulate the environment for i in range(10001): - env.render() action = controller.control(state, reference) (state, reference), reward, terminated, truncated, _ = env.step(action) if terminated: diff --git a/examples/classic_controllers/external_plot.py b/examples/classic_controllers/external_plot.py index 23c30668..679736c0 100644 --- a/examples/classic_controllers/external_plot.py +++ b/examples/classic_controllers/external_plot.py @@ -29,7 +29,6 @@ class ExternalPlot(TimePlot): >>> for t in range(100000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> data = [np.sin(t / 500), np.sin(t / 1000), np.sin(t / 1500), np.sin(t / 2000)] >>> external_plot.add_data(data) # passing the data to the external plot >>> (state, reference), reward, terminated, truncated, _ = env.step([0, 0]) diff --git a/examples/classic_controllers/externally_referenced_state_plot.py b/examples/classic_controllers/externally_referenced_state_plot.py index 0ec2e85b..b0daf0ae 100644 --- a/examples/classic_controllers/externally_referenced_state_plot.py +++ b/examples/classic_controllers/externally_referenced_state_plot.py @@ -19,7 +19,6 @@ class ExternallyReferencedStatePlot(StatePlot): state, reference = env.reset() external_reference_value = my_external_isd_reference_generator.get_reference() my_externally_referenced_plot.external_reference(external_reference_value) - env.render() action = env.action_space.sample() (state, reference), reward, terminated, truncated, _ = env.step(action) """ diff --git a/examples/environment_features/external_speed_profile.py b/examples/environment_features/external_speed_profile.py index ed74a689..89f38236 100644 --- a/examples/environment_features/external_speed_profile.py +++ b/examples/environment_features/external_speed_profile.py @@ -82,7 +82,6 @@ cum_rew = 0 for i in range(5000): - env.render() action = env.action_space.sample() (state, reference), reward, terminated, truncated, _ = env.step(action) diff --git a/examples/environment_features/userdefined_initialization.py b/examples/environment_features/userdefined_initialization.py index 17d4f8cd..7ae529c3 100644 --- a/examples/environment_features/userdefined_initialization.py +++ b/examples/environment_features/userdefined_initialization.py @@ -77,7 +77,6 @@ # Here we should have omega in the interval [60 1/s, 80 1/s] and current closely around 25 A for i in range(5000): - env.render() action = env.action_space.sample() (state, reference), reward, terminated, truncated, _ = env.step(action) diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py index b0b35910..ee10aa99 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py @@ -80,7 +80,6 @@ class ContCurrentControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py index 9657326e..86d35e56 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py @@ -80,7 +80,6 @@ class ContSpeedControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py index 836da426..bd15e543 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py @@ -80,7 +80,6 @@ class ContTorqueControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py index 4bbf5998..4318eebd 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py @@ -80,7 +80,6 @@ class FiniteCurrentControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py index aa050424..0ae4a787 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py @@ -80,7 +80,6 @@ class FiniteSpeedControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py index 38109686..51db5ea8 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py @@ -80,7 +80,6 @@ class FiniteTorqueControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py index c61dc8dd..a7bb4ca0 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py @@ -80,7 +80,6 @@ class ContCurrentControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__( diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py index 08408540..3e4b32b7 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py @@ -80,7 +80,6 @@ class ContSpeedControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py index a986c4bb..7cba7ab8 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_tc_permex_dc_env.py @@ -80,7 +80,6 @@ class ContTorqueControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py index a74dd86f..16bcde73 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py @@ -80,7 +80,6 @@ class FiniteCurrentControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment) >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__( diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py index dba8641c..5addba2e 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py @@ -80,7 +80,6 @@ class FiniteSpeedControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__( diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py index 6e4325ba..8a271066 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py @@ -80,7 +80,6 @@ class FiniteTorqueControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__( diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py index a728d2b8..d23a142d 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py @@ -80,7 +80,6 @@ class ContCurrentControlDcSeriesMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py index b7f280c0..ec77c2eb 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py @@ -80,7 +80,6 @@ class ContSpeedControlDcSeriesMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py index e3b42163..3f819e83 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py @@ -80,7 +80,6 @@ class ContTorqueControlDcSeriesMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py index 6fadd79c..cf2ac4ee 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py @@ -80,7 +80,6 @@ class FiniteCurrentControlDcSeriesMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py index 1bd64c30..73bfdbd5 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py @@ -80,7 +80,6 @@ class FiniteSpeedControlDcSeriesMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py index 3d49ede1..31acc535 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py @@ -80,7 +80,6 @@ class FiniteTorqueControlDcSeriesMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py index b5d587f4..c92a3a9f 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py @@ -81,7 +81,6 @@ class ContCurrentControlDcShuntMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py index 02862f6e..283ec5ed 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py @@ -81,7 +81,6 @@ class ContSpeedControlDcShuntMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py index c9036f59..b453507e 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py @@ -81,7 +81,6 @@ class ContTorqueControlDcShuntMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py index deb4a19e..7c0eecc9 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py @@ -81,7 +81,6 @@ class FiniteCurrentControlDcShuntMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py index df4610a6..6b397f8e 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py @@ -81,7 +81,6 @@ class FiniteSpeedControlDcShuntMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py index 937f5b85..121a1a1f 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py @@ -81,7 +81,6 @@ class FiniteTorqueControlDcShuntMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ diff --git a/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py index 814a8bba..4efd2f0f 100644 --- a/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py @@ -81,7 +81,6 @@ class ContCurrentControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnviro >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py index 5cd8940f..d23cb56d 100644 --- a/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py @@ -81,7 +81,6 @@ class ContSpeedControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnvironm >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py index ae57f232..a3095b3c 100644 --- a/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py @@ -82,7 +82,6 @@ class ContTorqueControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnviron >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py index da78891e..30e75193 100644 --- a/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py @@ -81,7 +81,6 @@ class FiniteCurrentControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnvi >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py index 32bdf897..28c47d35 100644 --- a/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py @@ -81,7 +81,6 @@ class FiniteSpeedControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnviro >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py index bff56d24..a28f3a38 100644 --- a/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py @@ -81,7 +81,6 @@ class FiniteTorqueControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnvir >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py index db45bbbd..16be0d47 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py @@ -88,7 +88,6 @@ class ContCurrentControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__( diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py index 7ff678be..233aa6e2 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py @@ -88,7 +88,6 @@ class ContSpeedControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py index e00fd364..0cb8659c 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py @@ -88,7 +88,6 @@ class ContTorqueControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py index 5d9ef33a..cefcd679 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py @@ -88,7 +88,6 @@ class FiniteCurrentControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py index 62b9b1ba..15262594 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py @@ -88,7 +88,6 @@ class FiniteSpeedControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py index 8fc60481..030a5ce5 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py @@ -88,7 +88,6 @@ class FiniteTorqueControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py index f3e3a00d..4021cf98 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py @@ -86,7 +86,6 @@ class ContCurrentControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py index 7cbd7352..ab90ac88 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py @@ -86,7 +86,6 @@ class ContSpeedControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py index 561a3f18..7e65095e 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py @@ -86,7 +86,6 @@ class ContTorqueControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py index 47f35276..ab574a55 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py @@ -86,7 +86,6 @@ class FiniteCurrentControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py index c18c5cbb..bfb37ba5 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py @@ -86,7 +86,6 @@ class FiniteSpeedControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py index 81c73b3e..3a24c608 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py @@ -86,7 +86,6 @@ class FiniteTorqueControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment) >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py index 67ff9a6b..aa8b40ef 100644 --- a/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py @@ -81,7 +81,6 @@ class ContCurrentControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironm >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py index ff0ed3e9..35c91b90 100644 --- a/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py @@ -81,7 +81,6 @@ class ContSpeedControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironmen >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py index 5a34c282..1d5a48ec 100644 --- a/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py @@ -81,7 +81,6 @@ class ContTorqueControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironme >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py index 1e58b5ce..d461461f 100644 --- a/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py @@ -81,7 +81,6 @@ class FiniteCurrentControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnviro >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py index 51493b8c..f9877b87 100644 --- a/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py @@ -81,7 +81,6 @@ class FiniteSpeedControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironm >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py index bedb48c9..d489f0ec 100644 --- a/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py @@ -81,7 +81,6 @@ class FiniteTorqueControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnviron >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py index 1c214525..1f9581f5 100644 --- a/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py @@ -81,7 +81,6 @@ class ContCurrentControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py index e0a03062..a865ee47 100644 --- a/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py @@ -81,7 +81,6 @@ class ContSpeedControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py index b7c62db3..905fad1a 100644 --- a/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py @@ -81,7 +81,6 @@ class ContTorqueControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py index fac6024b..4ec31868 100644 --- a/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py @@ -81,7 +81,6 @@ class FiniteCurrentControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py index e0d0e962..43f0f800 100644 --- a/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py @@ -81,7 +81,6 @@ class FiniteSpeedControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py index 91579fe2..d612a54a 100644 --- a/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py @@ -81,7 +81,6 @@ class FiniteTorqueControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment) >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, diff --git a/gym_electric_motor/physical_systems/mechanical_loads/polynomial_static_load.py b/gym_electric_motor/physical_systems/mechanical_loads/polynomial_static_load.py index 17565758..9106b816 100644 --- a/gym_electric_motor/physical_systems/mechanical_loads/polynomial_static_load.py +++ b/gym_electric_motor/physical_systems/mechanical_loads/polynomial_static_load.py @@ -31,7 +31,6 @@ class PolynomialStaticLoad(MechanicalLoad): >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() - >>> env.render() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) """ From 3c64ec8bc2d8db273e65cd9fb30fdce8654c8f20 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Fri, 23 Jun 2023 14:02:47 +0200 Subject: [PATCH 25/37] alignment of y-labels in plot added --- gym_electric_motor/visualization/motor_dashboard.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gym_electric_motor/visualization/motor_dashboard.py b/gym_electric_motor/visualization/motor_dashboard.py index 76e5d7ef..e08c16b5 100644 --- a/gym_electric_motor/visualization/motor_dashboard.py +++ b/gym_electric_motor/visualization/motor_dashboard.py @@ -90,6 +90,7 @@ def __init__( self._k = 0 self._update_render = False + def on_reset_begin(self): """Called before the environment is reset. All subplots are reset.""" for plot in self._plots: @@ -270,11 +271,14 @@ def _initialize_figures_window(self): for plot, axis in zip(self._time_plots, axes_step): plot.initialize(axis) + self._figures[0].align_ylabels() + def _update(self): """Called every *update cycle* steps to refresh the figure.""" for plot in self._plots: plot.render() for fig in self._figures: + #fig.align_ylabels() fig.canvas.draw() fig.canvas.flush_events() From 0594432310264442b56deb00c54b23df2043e33d Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Fri, 30 Jun 2023 13:49:36 +0200 Subject: [PATCH 26/37] possibility to save a file after plot --- ...c_controllers_dc_motor_integration_test.py | 12 +++- .../controllers/cascaded_controller.py | 2 +- gym_electric_motor/core.py | 65 ++++++++++++------- 3 files changed, 51 insertions(+), 28 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py index a8ca4076..0dcf8c09 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py @@ -2,6 +2,7 @@ from externally_referenced_state_plot import ExternallyReferencedStatePlot import gym_electric_motor as gem from gym_electric_motor.visualization import MotorDashboard +import time if __name__ == '__main__': @@ -38,8 +39,11 @@ external_ref_plots = [ExternallyReferencedStatePlot(state) for state in states] # initialize the gym-electric-motor environment - env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="file") + env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="once") env.metadata["filename_prefix"] = "integration-test" + env.metadata["filename_suffix"] = "" + env.metadata["save_figure_on_close"] = True + # env.metadata["hold_figure_on_close"] = False """ initialize the controller @@ -55,11 +59,13 @@ state, reference = env.reset(seed=1972) # simulate the environment - for i in range(10001): + for i in range(3001): action = controller.control(state, reference) (state, reference), reward, terminated, truncated, _ = env.step(action) + if i == 100: + pass if terminated: env.reset() controller.reset() - env.close() + env.close() \ No newline at end of file diff --git a/examples/classic_controllers/controllers/cascaded_controller.py b/examples/classic_controllers/controllers/cascaded_controller.py index 9296a179..9bc108f4 100644 --- a/examples/classic_controllers/controllers/cascaded_controller.py +++ b/examples/classic_controllers/controllers/cascaded_controller.py @@ -172,7 +172,7 @@ def control(self, state, reference): else: action = np.array([action, action_u_e], dtype='object') - if self.env.render_mode in ["human", "file"]: + if self.env.render_mode in ["human", "once"]: # Plot the external references plot(external_reference_plots=self.external_ref_plots, state_names=self.state_names, visualization=self.visualization, external_data=self.get_plot_data()) diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 26c6ad6c..315d1fa3 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -28,7 +28,7 @@ from .random_component import RandomComponent from .constraints import Constraint, LimitConstraint import gym_electric_motor as gem - +import matplotlib.pyplot class ElectricMotorEnvironment(gymnasium.core.Env): """ @@ -87,6 +87,11 @@ class ElectricMotorEnvironment(gymnasium.core.Env): The reward function can terminate an episode, if a physical limit of the motor has been violated. """ + env_id = None + metadata = {"render_modes": [None, "human", "once"], + "save_figure_on_close": False, + "hold_figure_on_close": True} + @property def physical_system(self): """ @@ -167,8 +172,6 @@ def visualizations(self): """Returns a list of all active motor visualizations.""" return self._visualizations - env_id = "0" - def __init__(self, physical_system, reference_generator, reward_function, visualization=(), state_filter=None, callbacks=(), constraints=(), physical_system_wrappers=(), render_mode=None, **kwargs): """ @@ -236,9 +239,7 @@ def __init__(self, physical_system, reference_generator, reward_function, visual self._truncated = False # Set render mode and metadata - render_modes = [None, "human", "file"] - self.metadata["render_modes"] = render_modes - assert render_mode in render_modes + assert render_mode in self.metadata["render_modes"] self.render_mode = render_mode @@ -249,6 +250,10 @@ def __init__(self, physical_system, reference_generator, reward_function, visual def make(env_id, *args, **kwargs): env = gymnasium.make(env_id, *args, **kwargs) env.metadata["filename_prefix"] = env_id + + timestamp = datetime.datetime.now().strftime("%Y-%m-%d-%H%M%S") + env.metadata["filename_suffix"] = f"_{timestamp}" + return env def _call_callbacks(self, func_name, *args): @@ -278,9 +283,8 @@ def render(self, *_, **__): """ Update the visualization of the motor. """ - if self.render_mode in ["human", "file"]: - for visualization in self._visualizations: - visualization.render() + for visualization in self._visualizations: + visualization.render() def step(self, action): """Perform one simulation step of the environment with an action of the action space. @@ -310,7 +314,7 @@ def step(self, action): ) # Call render code - if self.render_mode in ["human", "file"]: + if self.render_mode in ["human"]: self.render() return (state[self.state_filter], ref_next), reward, self._terminated, self._truncated, {} @@ -328,28 +332,41 @@ def _seed(self, seed=None): if isinstance(rc, gem.RandomComponent): rc.seed(sub) return [sg.entropy] + + def save_fig(self, figure): + """ Save figure with timestamped as filename """ + # create output folder if it not exists + output_folder_name = "plots" + if not os.path.exists(output_folder_name): + # Create the folder "gem_output" + os.makedirs(output_folder_name) + + filename_prefix = self.metadata["filename_prefix"] + filename_suffix = self.metadata["filename_suffix"] + filename = f"{output_folder_name}/{filename_prefix}{filename_suffix}.png" + figure.savefig(filename, dpi=300) def close(self): - # Save figure with timestamp as filename - if self.render_mode == "file": - # create output folder if it not exists - output_folder_name = "plots" - if not os.path.exists(output_folder_name): - # Create the folder "gem_output" - os.makedirs(output_folder_name) - - figure = self._get_figure() - timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S") - filename_prefix = self.metadata["filename_prefix"] - filename = f"{output_folder_name}/{filename_prefix}_{timestamp}.png" - figure.savefig(filename, dpi=300) """Called when the environment is deleted. Closes all its modules.""" self._call_callbacks('on_close') self._reward_function.close() self._physical_system.close() self._reference_generator.close() - def _get_figure(self): + if self.render_mode == "once": + self.render() + + # Save figure with timestamp as filename + if self.metadata["save_figure_on_close"]: + assert self.render_mode != None + self.save_fig(self.figure()) + + # Blocking plot call to still interactive with it + if self.metadata["hold_figure_on_close"]: + matplotlib.pyplot.show(block=True) + + + def figure(self): """ Get main figure (MotorDashboard) """ assert len(self._visualizations) == 1 motor_dashboard = self._visualizations[0] From 747a974af6bd2b96fd04fe0551469399557c8569 Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Fri, 30 Jun 2023 14:18:05 +0200 Subject: [PATCH 27/37] renamed render modes --- ...c_controllers_dc_motor_integration_test.py | 2 +- .../controllers/cascaded_controller.py | 2 +- gym_electric_motor/core.py | 25 +++++++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py index 0dcf8c09..f229b45c 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py @@ -39,7 +39,7 @@ external_ref_plots = [ExternallyReferencedStatePlot(state) for state in states] # initialize the gym-electric-motor environment - env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="once") + env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="figure_once") env.metadata["filename_prefix"] = "integration-test" env.metadata["filename_suffix"] = "" env.metadata["save_figure_on_close"] = True diff --git a/examples/classic_controllers/controllers/cascaded_controller.py b/examples/classic_controllers/controllers/cascaded_controller.py index 9bc108f4..539bd1ce 100644 --- a/examples/classic_controllers/controllers/cascaded_controller.py +++ b/examples/classic_controllers/controllers/cascaded_controller.py @@ -172,7 +172,7 @@ def control(self, state, reference): else: action = np.array([action, action_u_e], dtype='object') - if self.env.render_mode in ["human", "once"]: + if self.env.render_mode in ["figure", "figure_once"]: # Plot the external references plot(external_reference_plots=self.external_ref_plots, state_names=self.state_names, visualization=self.visualization, external_data=self.get_plot_data()) diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 315d1fa3..26030191 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -88,7 +88,7 @@ class ElectricMotorEnvironment(gymnasium.core.Env): """ env_id = None - metadata = {"render_modes": [None, "human", "once"], + metadata = {"render_modes": [None, "figure", "figure_once", "pickle_file"], "save_figure_on_close": False, "hold_figure_on_close": True} @@ -194,7 +194,7 @@ def __init__(self, physical_system, reference_generator, reward_function, visual state_filter(list(str)): Selection of states that are shown in the observation. physical_system_wrappers(iterable(PhysicalSystemWrapper)): PhysicalSystemWrapper instances to be wrapped around the physical system. - render_mode(str) : if visualization is given, render_mode is set to "human", else render_mode ist set to None + render_mode(str) : if visualization is given, render_mode is set to "figure", else render_mode ist set to None callbacks(list(Callback)): Callbacks being called in the environment **kwargs: Arguments to be passed to the modules. """ @@ -314,7 +314,7 @@ def step(self, action): ) # Call render code - if self.render_mode in ["human"]: + if self.render_mode == "figure": self.render() return (state[self.state_filter], ref_next), reward, self._terminated, self._truncated, {} @@ -346,14 +346,8 @@ def save_fig(self, figure): filename = f"{output_folder_name}/{filename_prefix}{filename_suffix}.png" figure.savefig(filename, dpi=300) - def close(self): - """Called when the environment is deleted. Closes all its modules.""" - self._call_callbacks('on_close') - self._reward_function.close() - self._physical_system.close() - self._reference_generator.close() - - if self.render_mode == "once": + def rendering_on_close(self): + if self.render_mode == "figure_once": self.render() # Save figure with timestamp as filename @@ -365,6 +359,15 @@ def close(self): if self.metadata["hold_figure_on_close"]: matplotlib.pyplot.show(block=True) + def close(self): + """Called when the environment is deleted. Closes all its modules.""" + self._call_callbacks('on_close') + self._reward_function.close() + self._physical_system.close() + self._reference_generator.close() + + self.rendering_on_close() + def figure(self): """ Get main figure (MotorDashboard) """ From dfe53a332ad0c00432d196fb57c17b46e83ff877 Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Sat, 1 Jul 2023 14:07:43 +0200 Subject: [PATCH 28/37] Fixed keyword argument passthrough --- .../envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py | 4 ++-- .../envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py | 4 ++-- .../gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py | 4 ++-- .../gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py | 4 ++-- .../gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py index a7bb4ca0..c6fe0e88 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_cc_permex_dc_env.py @@ -85,7 +85,7 @@ class ContCurrentControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): def __init__( self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=() + constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs ): """ Args: @@ -145,5 +145,5 @@ def __init__( super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py index 3e4b32b7..217297f0 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/cont_sc_permex_dc_env.py @@ -84,7 +84,7 @@ class ContSpeedControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=()): + constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -144,5 +144,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py index 16bcde73..07ee24e6 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_cc_permex_dc_env.py @@ -85,7 +85,7 @@ class FiniteCurrentControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment) def __init__( self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=() + constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=(), **kwargs ): """ Args: @@ -144,5 +144,5 @@ def __init__( super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py index 5addba2e..35e3dbd7 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_sc_permex_dc_env.py @@ -85,7 +85,7 @@ class FiniteSpeedControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): def __init__( self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=() + constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=(), **kwargs ): """ Args: @@ -147,5 +147,5 @@ def __init__( super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py index 8a271066..00a81039 100644 --- a/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/permex_dc_motor_env/finite_tc_permex_dc_env.py @@ -85,7 +85,7 @@ class FiniteTorqueControlDcPermanentlyExcitedMotorEnv(ElectricMotorEnvironment): def __init__( self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=() + constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=(), **kwargs ): """ Args: @@ -144,6 +144,6 @@ def __init__( super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) From 055567b28dbeee3f16d756b4f99a498d0522e95a Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Sat, 1 Jul 2023 14:25:41 +0200 Subject: [PATCH 29/37] Fix for other render modes --- examples/classic_controllers/controllers/cascaded_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/classic_controllers/controllers/cascaded_controller.py b/examples/classic_controllers/controllers/cascaded_controller.py index 539bd1ce..e526060e 100644 --- a/examples/classic_controllers/controllers/cascaded_controller.py +++ b/examples/classic_controllers/controllers/cascaded_controller.py @@ -172,7 +172,7 @@ def control(self, state, reference): else: action = np.array([action, action_u_e], dtype='object') - if self.env.render_mode in ["figure", "figure_once"]: + if self.env.render_mode != None: # Plot the external references plot(external_reference_plots=self.external_ref_plots, state_names=self.state_names, visualization=self.visualization, external_data=self.get_plot_data()) From 7d35b26d9d781284bf2cb5510710a7e20e21048b Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Sat, 1 Jul 2023 14:26:05 +0200 Subject: [PATCH 30/37] Fixed keyword argument passthrough for other envs --- .../envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py | 4 ++-- .../envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py | 4 ++-- .../envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py | 4 ++-- .../envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py | 4 ++-- .../envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py | 4 ++-- .../envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py | 4 ++-- .../envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py | 4 ++-- .../envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py | 4 ++-- .../envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py | 4 ++-- .../gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py | 4 ++-- .../gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py | 4 ++-- .../gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py | 4 ++-- .../envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py | 4 ++-- .../envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py | 4 ++-- .../envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py | 4 ++-- .../envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py | 4 ++-- .../envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py | 4 ++-- .../envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py | 4 ++-- gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py | 4 ++-- gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py | 4 ++-- gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py | 4 ++-- gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py | 4 ++-- gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py | 4 ++-- gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py | 4 ++-- .../doubly_fed_induction_motor_envs/cont_cc_dfim_env.py | 4 ++-- .../doubly_fed_induction_motor_envs/cont_sc_dfim_env.py | 4 ++-- .../doubly_fed_induction_motor_envs/cont_tc_dfim_env.py | 4 ++-- .../doubly_fed_induction_motor_envs/finite_cc_dfim_env.py | 4 ++-- .../doubly_fed_induction_motor_envs/finite_sc_dfim_env.py | 4 ++-- .../doubly_fed_induction_motor_envs/finite_tc_dfim_env.py | 4 ++-- .../squirrel_cage_induction_motor_envs/cont_cc_scim_env.py | 4 ++-- .../squirrel_cage_induction_motor_envs/cont_sc_scim_env.py | 4 ++-- .../squirrel_cage_induction_motor_envs/cont_tc_scim_env.py | 4 ++-- .../squirrel_cage_induction_motor_envs/finite_cc_scim_env.py | 4 ++-- .../squirrel_cage_induction_motor_envs/finite_sc_scim_env.py | 4 ++-- .../squirrel_cage_induction_motor_envs/finite_tc_scim_env.py | 4 ++-- gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py | 4 ++-- gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py | 4 ++-- gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py | 4 ++-- gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py | 4 ++-- gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py | 4 ++-- gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py | 4 ++-- gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py | 4 ++-- gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py | 4 ++-- gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py | 4 ++-- gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py | 4 ++-- gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py | 4 ++-- gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py | 4 ++-- 48 files changed, 96 insertions(+), 96 deletions(-) diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py index ee10aa99..d7604d9c 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_cc_extex_dc_env.py @@ -84,7 +84,7 @@ class ContCurrentControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-4, physical_system_wrappers=()): + constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -155,5 +155,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py index 86d35e56..c1a22090 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_sc_extex_dc_env.py @@ -84,7 +84,7 @@ class ContSpeedControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-4, physical_system_wrappers=()): + constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -148,5 +148,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py index bd15e543..d3f6c194 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/cont_tc_extex_dc_env.py @@ -84,7 +84,7 @@ class ContTorqueControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=()): + constraints=('i_a', 'i_e',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -148,5 +148,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py index 4318eebd..232de8a5 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_cc_extex_dc_env.py @@ -84,7 +84,7 @@ class FiniteCurrentControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5, physical_system_wrappers=()): + constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -152,5 +152,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py index 0ae4a787..de2836a6 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_sc_extex_dc_env.py @@ -84,7 +84,7 @@ class FiniteSpeedControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5, physical_system_wrappers=()): + constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -149,5 +149,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py index 51db5ea8..5a6986e1 100644 --- a/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/extex_dc_motor_env/finite_tc_extex_dc_env.py @@ -84,7 +84,7 @@ class FiniteTorqueControlDcExternallyExcitedMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5,physical_system_wrappers=()): + constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5,physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -147,5 +147,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py index d23a142d..0d18b2ca 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_cc_series_dc_env.py @@ -84,7 +84,7 @@ class ContCurrentControlDcSeriesMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=()): + constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -143,5 +143,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py index ec77c2eb..018757c0 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_sc_series_dc_env.py @@ -85,7 +85,7 @@ class ContSpeedControlDcSeriesMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=()): + constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -145,6 +145,6 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py index 3f819e83..0fbb1a58 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/cont_tc_series_dc_env.py @@ -85,7 +85,7 @@ class ContTorqueControlDcSeriesMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=()): + constraints=('i',), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -142,5 +142,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py index cf2ac4ee..57ef5a8c 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_cc_series_dc_env.py @@ -84,7 +84,7 @@ class FiniteCurrentControlDcSeriesMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=()): + constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -141,5 +141,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py index 73bfdbd5..e6cf017b 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_sc_series_dc_env.py @@ -84,7 +84,7 @@ class FiniteSpeedControlDcSeriesMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=()): + constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -144,6 +144,6 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py index 31acc535..930cb898 100644 --- a/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/series_dc_motor_env/finite_tc_series_dc_env.py @@ -84,7 +84,7 @@ class FiniteTorqueControlDcSeriesMotorEnv(ElectricMotorEnvironment): """ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=()): + constraints=('i',), calc_jacobian=True, tau=1e-5, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -143,5 +143,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py index c92a3a9f..f868e0c4 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_cc_shunt_dc_env.py @@ -86,7 +86,7 @@ class ContCurrentControlDcShuntMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-4, physical_system_wrappers=()): + constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -146,5 +146,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),) + physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),), **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py index 283ec5ed..826b67a4 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_sc_shunt_dc_env.py @@ -86,7 +86,7 @@ class ContSpeedControlDcShuntMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-4, physical_system_wrappers=()): + constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -147,5 +147,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),) + physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),), **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py index b453507e..698607de 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/cont_tc_shunt_dc_env.py @@ -86,7 +86,7 @@ class ContTorqueControlDcShuntMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-4, physical_system_wrappers=()): + constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -151,5 +151,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),) + physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),), **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py index 7c0eecc9..e49ac86b 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_cc_shunt_dc_env.py @@ -86,7 +86,7 @@ class FiniteCurrentControlDcShuntMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5, physical_system_wrappers=()): + constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -145,5 +145,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),) + physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),), **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py index 6b397f8e..f1b376b6 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_sc_shunt_dc_env.py @@ -86,7 +86,7 @@ class FiniteSpeedControlDcShuntMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5, physical_system_wrappers=()): + constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -147,5 +147,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),) + physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),), **kwargs ) diff --git a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py index 121a1a1f..03e1cee4 100644 --- a/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py +++ b/gym_electric_motor/envs/gym_dcm/shunt_dc_motor_env/finite_tc_shunt_dc_env.py @@ -86,7 +86,7 @@ class FiniteTorqueControlDcShuntMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), - constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5, physical_system_wrappers=()): + constraints=('i_a', 'i_e'), calc_jacobian=True, tau=1e-5, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -143,5 +143,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),) + physical_system_wrappers=tuple(physical_system_wrappers) + (CurrentSumProcessor(('i_a', 'i_e')),), **kwargs ) diff --git a/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py index 4efd2f0f..7f07e548 100644 --- a/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/cont_cc_eesm_env.py @@ -86,7 +86,7 @@ class ContCurrentControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnviro def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')), LimitConstraint(('i_e',))), calc_jacobian=True, - tau=1e-4, physical_system_wrappers=()): + tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -164,5 +164,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py index d23cb56d..7ecb11b7 100644 --- a/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/cont_sc_eesm_env.py @@ -86,7 +86,7 @@ class ContSpeedControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnvironm def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')), LimitConstraint(('i_e',))), calc_jacobian=True, - tau=1e-4, physical_system_wrappers=()): + tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -154,5 +154,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py index a3095b3c..b07248a1 100644 --- a/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/cont_tc_eesm_env.py @@ -87,7 +87,7 @@ class ContTorqueControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnviron def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')), LimitConstraint(('i_e',))), calc_jacobian=True, - tau=1e-4, physical_system_wrappers=()): + tau=1e-4, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -160,5 +160,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py index 30e75193..058b7b8d 100644 --- a/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/finite_cc_eesm_env.py @@ -86,7 +86,7 @@ class FiniteCurrentControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnvi def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')), LimitConstraint(('i_e',))), calc_jacobian=True, - tau=1e-5, physical_system_wrappers=()): + tau=1e-5, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -159,5 +159,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py index 28c47d35..b0d4f275 100644 --- a/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/finite_sc_eesm_env.py @@ -86,7 +86,7 @@ class FiniteSpeedControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnviro def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')), LimitConstraint(('i_e',))), calc_jacobian=True, - tau=1e-5, physical_system_wrappers=()): + tau=1e-5, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -154,5 +154,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py b/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py index a28f3a38..7e09ab53 100644 --- a/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py +++ b/gym_electric_motor/envs/gym_eesm/finite_tc_eesm_env.py @@ -86,7 +86,7 @@ class FiniteTorqueControlExternallyExcitedSynchronousMotorEnv(ElectricMotorEnvir def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')), LimitConstraint(('i_e',))), calc_jacobian=True, - tau=1e-5, physical_system_wrappers=()): + tau=1e-5, physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -154,5 +154,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py index 16be0d47..aef2bdad 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_cc_dfim_env.py @@ -94,7 +94,7 @@ def __init__( self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-4, - physical_system_wrappers=() + physical_system_wrappers=(), **kwargs ): """ Args: @@ -173,5 +173,5 @@ def __init__( super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py index 233aa6e2..5b655c9f 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_sc_dfim_env.py @@ -93,7 +93,7 @@ class ContSpeedControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-4, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -162,5 +162,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py index 0cb8659c..dcd6b4be 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/cont_tc_dfim_env.py @@ -93,7 +93,7 @@ class ContTorqueControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-4, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -166,5 +166,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py index cefcd679..3f5c6e4c 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_cc_dfim_env.py @@ -93,7 +93,7 @@ class FiniteCurrentControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -171,5 +171,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py index 15262594..2154ba2c 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_sc_dfim_env.py @@ -93,7 +93,7 @@ class FiniteSpeedControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -162,5 +162,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py index 030a5ce5..70830114 100644 --- a/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py +++ b/gym_electric_motor/envs/gym_im/doubly_fed_induction_motor_envs/finite_tc_dfim_env.py @@ -93,7 +93,7 @@ class FiniteTorqueControlDoublyFedInductionMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -160,5 +160,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py index 4021cf98..b74aa172 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_cc_scim_env.py @@ -91,7 +91,7 @@ class ContCurrentControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-4, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -160,5 +160,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py index ab90ac88..0f0740e7 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_sc_scim_env.py @@ -91,7 +91,7 @@ class ContSpeedControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), physical_system_wrappers=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), - calc_jacobian=True, tau=1e-4): + calc_jacobian=True, tau=1e-4, **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -152,5 +152,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py index 7e65095e..bdd32746 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/cont_tc_scim_env.py @@ -91,7 +91,7 @@ class ContTorqueControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-4, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -155,5 +155,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py index ab574a55..f98f0ab7 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_cc_scim_env.py @@ -91,7 +91,7 @@ class FiniteCurrentControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -160,5 +160,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py index bfb37ba5..8232ce9b 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_sc_scim_env.py @@ -91,7 +91,7 @@ class FiniteSpeedControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -152,5 +152,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py index 3a24c608..7fa8846d 100644 --- a/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py +++ b/gym_electric_motor/envs/gym_im/squirrel_cage_induction_motor_envs/finite_tc_scim_env.py @@ -91,7 +91,7 @@ class FiniteTorqueControlSquirrelCageInductionMotorEnv(ElectricMotorEnvironment) def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -149,5 +149,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py index aa8b40ef..ec0f07cc 100644 --- a/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/cont_cc_pmsm_env.py @@ -86,7 +86,7 @@ class ContCurrentControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironm def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-4, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -155,5 +155,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py index 35c91b90..83be801c 100644 --- a/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/cont_sc_pmsm_env.py @@ -86,7 +86,7 @@ class ContSpeedControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironmen def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-4, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -145,5 +145,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py index 1d5a48ec..e9a6d3e3 100644 --- a/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/cont_tc_pmsm_env.py @@ -86,7 +86,7 @@ class ContTorqueControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironme def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-4, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -150,5 +150,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py index d461461f..a4b78982 100644 --- a/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/finite_cc_pmsm_env.py @@ -86,7 +86,7 @@ class FiniteCurrentControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnviro def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -155,5 +155,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py index f9877b87..041f9078 100644 --- a/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/finite_sc_pmsm_env.py @@ -86,7 +86,7 @@ class FiniteSpeedControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnvironm def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -145,5 +145,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py b/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py index d489f0ec..6228d54a 100644 --- a/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py +++ b/gym_electric_motor/envs/gym_pmsm/finite_tc_pmsm_env.py @@ -86,7 +86,7 @@ class FiniteTorqueControlPermanentMagnetSynchronousMotorEnv(ElectricMotorEnviron def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -144,5 +144,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py index 1f9581f5..3b2b42a8 100644 --- a/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/cont_cc_synrm_env.py @@ -86,7 +86,7 @@ class ContCurrentControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-4, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -155,5 +155,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py index a865ee47..32ac8682 100644 --- a/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/cont_sc_synrm_env.py @@ -86,7 +86,7 @@ class ContSpeedControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-4, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -146,5 +146,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py index 905fad1a..e7365ae0 100644 --- a/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/cont_tc_synrm_env.py @@ -86,7 +86,7 @@ class ContTorqueControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-4, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -150,5 +150,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py index 4ec31868..e79608dd 100644 --- a/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/finite_cc_synrm_env.py @@ -86,7 +86,7 @@ class FiniteCurrentControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -155,5 +155,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py index 43f0f800..7ade4aec 100644 --- a/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/finite_sc_synrm_env.py @@ -86,7 +86,7 @@ class FiniteSpeedControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment): def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -147,5 +147,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) diff --git a/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py b/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py index d612a54a..4336ad23 100644 --- a/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py +++ b/gym_electric_motor/envs/gym_synrm/finite_tc_synrm_env.py @@ -86,7 +86,7 @@ class FiniteTorqueControlSynchronousReluctanceMotorEnv(ElectricMotorEnvironment) def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(SquaredConstraint(('i_sq', 'i_sd')),), calc_jacobian=True, tau=1e-5, - physical_system_wrappers=()): + physical_system_wrappers=(), **kwargs): """ Args: supply(env-arg): Specification of the :py:class:`.VoltageSupply` for the environment @@ -144,5 +144,5 @@ def __init__(self, supply=None, converter=None, motor=None, load=None, ode_solve super().__init__( physical_system=physical_system, reference_generator=reference_generator, reward_function=reward_function, constraints=constraints, visualization=visualization, state_filter=state_filter, callbacks=callbacks, - physical_system_wrappers=physical_system_wrappers + physical_system_wrappers=physical_system_wrappers, **kwargs ) From 44482e1758b660daf5158311eece3f2c6570222c Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Sat, 1 Jul 2023 14:48:39 +0200 Subject: [PATCH 31/37] Latex figure mode with saving as pdf --- ...c_controllers_dc_motor_integration_test.py | 3 +- gym_electric_motor/core.py | 41 +++++++++++++------ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py index f229b45c..4aa1ff15 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py @@ -39,10 +39,11 @@ external_ref_plots = [ExternallyReferencedStatePlot(state) for state in states] # initialize the gym-electric-motor environment - env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="figure_once") + env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="figure_academic") env.metadata["filename_prefix"] = "integration-test" env.metadata["filename_suffix"] = "" env.metadata["save_figure_on_close"] = True + env.metadata["hold_figure_on_close"] = False # env.metadata["hold_figure_on_close"] = False """ initialize the controller diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index 26030191..acb4f85b 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -29,6 +29,9 @@ from .constraints import Constraint, LimitConstraint import gym_electric_motor as gem import matplotlib.pyplot +from matplotlib.figure import Figure +import matplotlib + class ElectricMotorEnvironment(gymnasium.core.Env): """ @@ -88,7 +91,7 @@ class ElectricMotorEnvironment(gymnasium.core.Env): """ env_id = None - metadata = {"render_modes": [None, "figure", "figure_once", "pickle_file"], + metadata = {"render_modes": [None, "figure", "figure_once", "figure_academic"], "save_figure_on_close": False, "hold_figure_on_close": True} @@ -333,7 +336,7 @@ def _seed(self, seed=None): rc.seed(sub) return [sg.entropy] - def save_fig(self, figure): + def save_fig(self, figure, filetype="png"): """ Save figure with timestamped as filename """ # create output folder if it not exists output_folder_name = "plots" @@ -343,21 +346,35 @@ def save_fig(self, figure): filename_prefix = self.metadata["filename_prefix"] filename_suffix = self.metadata["filename_suffix"] - filename = f"{output_folder_name}/{filename_prefix}{filename_suffix}.png" + filename = f"{output_folder_name}/{filename_prefix}{filename_suffix}.{filetype}" figure.savefig(filename, dpi=300) def rendering_on_close(self): - if self.render_mode == "figure_once": + + # Figure Mode + if self.render_mode and self.render_mode.startswith("figure"): + + # Academic Mode (latex font) + if self.render_mode == "figure_academic": + matplotlib.rcParams.update({ + "text.usetex": True, + "font.family": "Helvetica" + }) + self.render() - # Save figure with timestamp as filename - if self.metadata["save_figure_on_close"]: - assert self.render_mode != None - self.save_fig(self.figure()) + # Save figure with timestamp as filename + if self.metadata["save_figure_on_close"]: + if self.render_mode == "figure_academic": + self.save_fig(self.figure(), filetype="pdf") + else: + self.save_fig(self.figure()) - # Blocking plot call to still interactive with it - if self.metadata["hold_figure_on_close"]: - matplotlib.pyplot.show(block=True) + # Blocking plot call to still interactive with it + if self.metadata["hold_figure_on_close"]: + matplotlib.pyplot.show(block=True) + + def close(self): """Called when the environment is deleted. Closes all its modules.""" @@ -369,7 +386,7 @@ def close(self): self.rendering_on_close() - def figure(self): + def figure(self) -> Figure: """ Get main figure (MotorDashboard) """ assert len(self._visualizations) == 1 motor_dashboard = self._visualizations[0] From 9710ca88c45060e32d62fea8182845a1d40cf420 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Sat, 1 Jul 2023 16:25:36 +0200 Subject: [PATCH 32/37] new integration test draft --- .../classic_controllers_dc_motor_example.py | 2 +- ...controllers_dc_motor_integration_test_2.py | 86 +++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 examples/classic_controllers/classic_controllers_dc_motor_integration_test_2.py diff --git a/examples/classic_controllers/classic_controllers_dc_motor_example.py b/examples/classic_controllers/classic_controllers_dc_motor_example.py index 3fab1f38..f3a07ad9 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_example.py @@ -46,7 +46,7 @@ environment gym-electric-motor environment external_ref_plots (optional) plots of the environment, to plot all reference values stages (optional) structure of the controller - automated_gain (optional) if True (default), the controller will be tune automatically + automated_gain (optional) if True (default), the controller will be tuned automatically a (optional) tuning parameter of the symmetrical optimum (default: 4) """ diff --git a/examples/classic_controllers/classic_controllers_dc_motor_integration_test_2.py b/examples/classic_controllers/classic_controllers_dc_motor_integration_test_2.py new file mode 100644 index 00000000..dd42220c --- /dev/null +++ b/examples/classic_controllers/classic_controllers_dc_motor_integration_test_2.py @@ -0,0 +1,86 @@ +from classic_controllers import Controller +from externally_referenced_state_plot import ExternallyReferencedStatePlot +import gym_electric_motor as gem +from gym_electric_motor.visualization import MotorDashboard +from gym_electric_motor.reference_generators import SinusoidalReferenceGenerator +import time + +if __name__ == '__main__': + + """ + motor type: 'PermExDc' Permanently Excited DC Motor + 'ExtExDc' Externally Excited MC Motor + 'SeriesDc' DC Series Motor + 'ShuntDc' DC Shunt Motor + + control type: 'SC' Speed Control + 'TC' Torque Control + 'CC' Current Control + + action_type: 'Cont' Continuous Action Space + 'Finite' Discrete Action Space + """ + + motor_type = 'PermExDc' + control_type = 'SC' + action_type = 'Cont' + + motor = action_type + '-' + control_type + '-' + motor_type + '-v0' + + if motor_type in ['PermExDc', 'SeriesDc']: + states = ['omega', 'torque', 'i', 'u'] + elif motor_type == 'ShuntDc': + states = ['omega', 'torque', 'i_a', 'i_e', 'u'] + elif motor_type == 'ExtExDc': + states = ['omega', 'torque', 'i_a', 'i_e', 'u_a', 'u_e'] + else: + raise KeyError(motor_type + ' is not available') + + # definition of the plotted variables + external_ref_plots = [ExternallyReferencedStatePlot(state) for state in states] + + # definition of the reference generator + + ref_generator = SinusoidalReferenceGenerator(amplitude_range= (100,100), + frequency_range= (5,5), + offset_range = (0,0), + episode_lengths = (10001, 10001)) + + # initialize the gym-electric-motor environment + env = gem.make(motor, + visualization=MotorDashboard(additional_plots=external_ref_plots), + render_mode="figure", + reference_generator = ref_generator) + + env.metadata["filename_prefix"] = "integration-test" + env.metadata["filename_suffix"] = "" + env.metadata["save_figure_on_close"] = False + env.metadata["hold_figure_on_close"] = True + """ + initialize the controller + + Args: + environment gym-electric-motor environment + external_ref_plots (optional) plots of the environment, to plot all reference values + stages (optional) structure of the controller + automated_gain (optional) if True (default), the controller will be tuned automatically + a (optional) tuning parameter of the symmetrical optimum (default: 4) + + """ + controller = Controller.make(env, external_ref_plots=external_ref_plots) + + state, reference = env.reset(seed=1337) + # simulate the environment + for i in range(10001): + action = controller.control(state, reference) + #if i % 100 == 0: + # (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) + #else: + (state, reference), reward, terminated, truncated, _ = env.step(action) + + + if terminated: + env.reset() + controller.reset() + + env.close() \ No newline at end of file From 2203317a422f7a75833fab498ab42f57443500ea Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Sat, 8 Jul 2023 17:48:13 +0200 Subject: [PATCH 33/37] added auto-scaling for integrationtest --- .../classic_controllers_dc_motor_integration_test_2.py | 3 ++- gym_electric_motor/core.py | 5 +++-- gym_electric_motor/visualization/motor_dashboard.py | 4 +++- .../visualization/motor_dashboard_plots/base_plots.py | 9 +++++++++ .../visualization/motor_dashboard_plots/state_plot.py | 8 ++++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_integration_test_2.py b/examples/classic_controllers/classic_controllers_dc_motor_integration_test_2.py index dd42220c..2e7b40d2 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_integration_test_2.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_integration_test_2.py @@ -41,7 +41,7 @@ # definition of the reference generator - ref_generator = SinusoidalReferenceGenerator(amplitude_range= (100,100), + ref_generator = SinusoidalReferenceGenerator(amplitude_range= (1,1), frequency_range= (5,5), offset_range = (0,0), episode_lengths = (10001, 10001)) @@ -49,6 +49,7 @@ # initialize the gym-electric-motor environment env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), + scale_plots=True, render_mode="figure", reference_generator = ref_generator) diff --git a/gym_electric_motor/core.py b/gym_electric_motor/core.py index acb4f85b..d6b16a8f 100644 --- a/gym_electric_motor/core.py +++ b/gym_electric_motor/core.py @@ -176,7 +176,7 @@ def visualizations(self): return self._visualizations def __init__(self, physical_system, reference_generator, reward_function, visualization=(), state_filter=None, - callbacks=(), constraints=(), physical_system_wrappers=(), render_mode=None, **kwargs): + callbacks=(), constraints=(), physical_system_wrappers=(), render_mode=None, scale_plots = None, **kwargs): """ Setting and initialization of all environments' modules. @@ -244,8 +244,9 @@ def __init__(self, physical_system, reference_generator, reward_function, visual # Set render mode and metadata assert render_mode in self.metadata["render_modes"] self.render_mode = render_mode - + self.scale_plots = scale_plots + self._callbacks = list(callbacks) self._callbacks += list(self._visualizations) self._call_callbacks('set_env', self) diff --git a/gym_electric_motor/visualization/motor_dashboard.py b/gym_electric_motor/visualization/motor_dashboard.py index e08c16b5..8bd65e7f 100644 --- a/gym_electric_motor/visualization/motor_dashboard.py +++ b/gym_electric_motor/visualization/motor_dashboard.py @@ -33,7 +33,7 @@ def update_interval(self): def __init__( self, state_plots=(), action_plots=(), reward_plot=False, additional_plots=(), - update_interval=1000, time_plot_width=10000, style=None + update_interval=1000, time_plot_width=10000, style=None, scale_plots = None ): """ Args: @@ -90,6 +90,8 @@ def __init__( self._k = 0 self._update_render = False + #self._scale_plots = scale_plots + def on_reset_begin(self): """Called before the environment is reset. All subplots are reset.""" diff --git a/gym_electric_motor/visualization/motor_dashboard_plots/base_plots.py b/gym_electric_motor/visualization/motor_dashboard_plots/base_plots.py index c1ead86e..3dd20f4d 100644 --- a/gym_electric_motor/visualization/motor_dashboard_plots/base_plots.py +++ b/gym_electric_motor/visualization/motor_dashboard_plots/base_plots.py @@ -195,6 +195,15 @@ def _scale_x_axis(self): lower_lim = upper_lim - self._x_width * self._tau self._axis.set_xlim(lower_lim, upper_lim) + def _scale_y_axis(self): + if self._scale_plots_to_data: + + y_min = min(np.nanmin(self._y_data[0]), np.nanmin(self._y_data[1])) + y_max = max(np.nanmax(self._y_data[0]), np.nanmax(self._y_data[1])) + + self._axis.set_ylim(y_min-np.sign(y_min)*0.1*y_min, + y_max+np.sign(y_max)*0.1*y_max) + class EpisodePlot(MotorDashboardPlot): """Base Plot class that all episode based plots .""" diff --git a/gym_electric_motor/visualization/motor_dashboard_plots/state_plot.py b/gym_electric_motor/visualization/motor_dashboard_plots/state_plot.py index f614967d..83930b04 100644 --- a/gym_electric_motor/visualization/motor_dashboard_plots/state_plot.py +++ b/gym_electric_motor/visualization/motor_dashboard_plots/state_plot.py @@ -71,6 +71,10 @@ def __init__(self, state): # Flag, if the passed data is normalized self._normalized = True + self._scale_plots_to_data = False + + + def set_env(self, env): # Docstring of superclass super().set_env(env) @@ -97,6 +101,10 @@ def set_env(self, env): # Set the y-axis label self._label = self.state_labels.get(self._state, self._state) + self._scale_plots_to_data = env.scale_plots + + + def reset_data(self): super().reset_data() # Initialize the data containers From fb084ba39486fdd2ae0effe0db4576ebaa80c250 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Sat, 15 Jul 2023 20:22:38 +0200 Subject: [PATCH 34/37] updated examples according to new render_modes --- .../classic_controllers_dc_motor_example.py | 2 +- .../custom_classic_controllers_dc_motor_example.py | 2 +- .../custom_classic_controllers_synch_motor_example.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_example.py b/examples/classic_controllers/classic_controllers_dc_motor_example.py index f3a07ad9..d0a12bbd 100644 --- a/examples/classic_controllers/classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/classic_controllers_dc_motor_example.py @@ -38,7 +38,7 @@ external_ref_plots = [ExternallyReferencedStatePlot(state) for state in states] # initialize the gym-electric-motor environment - env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="file") + env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="figure_once") """ initialize the controller diff --git a/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py b/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py index b9f48ed3..c2aafa38 100644 --- a/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_dc_motor_example.py @@ -39,7 +39,7 @@ external_ref_plots = [ExternallyReferencedStatePlot(state) for state in states] # initialize the gym-electric-motor environment - env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots)) + env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode = 'figure') """ initialize the controller diff --git a/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py b/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py index e8127bda..59bb2789 100644 --- a/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py +++ b/examples/classic_controllers/custom_classic_controllers_synch_motor_example.py @@ -35,7 +35,8 @@ # initialize the gym-electric-motor environment env = gem.make(env_id, visualization=MotorDashboard(additional_plots=external_ref_plots), - motor=dict(limit_values=limit_values, nominal_values=nominal_values, motor_parameter=motor_parameter)) + motor=dict(limit_values=limit_values, nominal_values=nominal_values, motor_parameter=motor_parameter), + render_mode = 'figure') """ initialize the controller From 1f527a0e8242b74c2a13482a86e3649afc8bcb7f Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Sat, 15 Jul 2023 21:00:36 +0200 Subject: [PATCH 35/37] updated to fit code after migration to gymnasium --- .../environment_features/GEM_cookbook.ipynb | 138 +++++++++--------- 1 file changed, 70 insertions(+), 68 deletions(-) diff --git a/examples/environment_features/GEM_cookbook.ipynb b/examples/environment_features/GEM_cookbook.ipynb index 62e04a83..b832ad51 100644 --- a/examples/environment_features/GEM_cookbook.ipynb +++ b/examples/environment_features/GEM_cookbook.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -10,6 +11,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -50,6 +52,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -142,6 +145,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -149,6 +153,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -159,6 +164,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -169,29 +175,33 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, "metadata": {}, "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Warning: Cannot change to a different GUI toolkit: widget. Using notebook instead.\n" + ] + }, + { + "data": { + "application/javascript": "/* Put everything inside the global mpl namespace */\n/* global mpl */\nwindow.mpl = {};\n\nmpl.get_websocket_type = function () {\n if (typeof WebSocket !== 'undefined') {\n return WebSocket;\n } else if (typeof MozWebSocket !== 'undefined') {\n return MozWebSocket;\n } else {\n alert(\n 'Your browser does not have WebSocket support. ' +\n 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n 'Firefox 4 and 5 are also supported but you ' +\n 'have to enable WebSockets in about:config.'\n );\n }\n};\n\nmpl.figure = function (figure_id, websocket, ondownload, parent_element) {\n this.id = figure_id;\n\n this.ws = websocket;\n\n this.supports_binary = this.ws.binaryType !== undefined;\n\n if (!this.supports_binary) {\n var warnings = document.getElementById('mpl-warnings');\n if (warnings) {\n warnings.style.display = 'block';\n warnings.textContent =\n 'This browser does not support binary websocket messages. ' +\n 'Performance may be slow.';\n }\n }\n\n this.imageObj = new Image();\n\n this.context = undefined;\n this.message = undefined;\n this.canvas = undefined;\n this.rubberband_canvas = undefined;\n this.rubberband_context = undefined;\n this.format_dropdown = undefined;\n\n this.image_mode = 'full';\n\n this.root = document.createElement('div');\n this.root.setAttribute('style', 'display: inline-block');\n this._root_extra_style(this.root);\n\n parent_element.appendChild(this.root);\n\n this._init_header(this);\n this._init_canvas(this);\n this._init_toolbar(this);\n\n var fig = this;\n\n this.waiting = false;\n\n this.ws.onopen = function () {\n fig.send_message('supports_binary', { value: fig.supports_binary });\n fig.send_message('send_image_mode', {});\n if (fig.ratio !== 1) {\n fig.send_message('set_device_pixel_ratio', {\n device_pixel_ratio: fig.ratio,\n });\n }\n fig.send_message('refresh', {});\n };\n\n this.imageObj.onload = function () {\n if (fig.image_mode === 'full') {\n // Full images could contain transparency (where diff images\n // almost always do), so we need to clear the canvas so that\n // there is no ghosting.\n fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n }\n fig.context.drawImage(fig.imageObj, 0, 0);\n };\n\n this.imageObj.onunload = function () {\n fig.ws.close();\n };\n\n this.ws.onmessage = this._make_on_message_function(this);\n\n this.ondownload = ondownload;\n};\n\nmpl.figure.prototype._init_header = function () {\n var titlebar = document.createElement('div');\n titlebar.classList =\n 'ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix';\n var titletext = document.createElement('div');\n titletext.classList = 'ui-dialog-title';\n titletext.setAttribute(\n 'style',\n 'width: 100%; text-align: center; padding: 3px;'\n );\n titlebar.appendChild(titletext);\n this.root.appendChild(titlebar);\n this.header = titletext;\n};\n\nmpl.figure.prototype._canvas_extra_style = function (_canvas_div) {};\n\nmpl.figure.prototype._root_extra_style = function (_canvas_div) {};\n\nmpl.figure.prototype._init_canvas = function () {\n var fig = this;\n\n var canvas_div = (this.canvas_div = document.createElement('div'));\n canvas_div.setAttribute('tabindex', '0');\n canvas_div.setAttribute(\n 'style',\n 'border: 1px solid #ddd;' +\n 'box-sizing: content-box;' +\n 'clear: both;' +\n 'min-height: 1px;' +\n 'min-width: 1px;' +\n 'outline: 0;' +\n 'overflow: hidden;' +\n 'position: relative;' +\n 'resize: both;' +\n 'z-index: 2;'\n );\n\n function on_keyboard_event_closure(name) {\n return function (event) {\n return fig.key_event(event, name);\n };\n }\n\n canvas_div.addEventListener(\n 'keydown',\n on_keyboard_event_closure('key_press')\n );\n canvas_div.addEventListener(\n 'keyup',\n on_keyboard_event_closure('key_release')\n );\n\n this._canvas_extra_style(canvas_div);\n this.root.appendChild(canvas_div);\n\n var canvas = (this.canvas = document.createElement('canvas'));\n canvas.classList.add('mpl-canvas');\n canvas.setAttribute(\n 'style',\n 'box-sizing: content-box;' +\n 'pointer-events: none;' +\n 'position: relative;' +\n 'z-index: 0;'\n );\n\n this.context = canvas.getContext('2d');\n\n var backingStore =\n this.context.backingStorePixelRatio ||\n this.context.webkitBackingStorePixelRatio ||\n this.context.mozBackingStorePixelRatio ||\n this.context.msBackingStorePixelRatio ||\n this.context.oBackingStorePixelRatio ||\n this.context.backingStorePixelRatio ||\n 1;\n\n this.ratio = (window.devicePixelRatio || 1) / backingStore;\n\n var rubberband_canvas = (this.rubberband_canvas = document.createElement(\n 'canvas'\n ));\n rubberband_canvas.setAttribute(\n 'style',\n 'box-sizing: content-box;' +\n 'left: 0;' +\n 'pointer-events: none;' +\n 'position: absolute;' +\n 'top: 0;' +\n 'z-index: 1;'\n );\n\n // Apply a ponyfill if ResizeObserver is not implemented by browser.\n if (this.ResizeObserver === undefined) {\n if (window.ResizeObserver !== undefined) {\n this.ResizeObserver = window.ResizeObserver;\n } else {\n var obs = _JSXTOOLS_RESIZE_OBSERVER({});\n this.ResizeObserver = obs.ResizeObserver;\n }\n }\n\n this.resizeObserverInstance = new this.ResizeObserver(function (entries) {\n var nentries = entries.length;\n for (var i = 0; i < nentries; i++) {\n var entry = entries[i];\n var width, height;\n if (entry.contentBoxSize) {\n if (entry.contentBoxSize instanceof Array) {\n // Chrome 84 implements new version of spec.\n width = entry.contentBoxSize[0].inlineSize;\n height = entry.contentBoxSize[0].blockSize;\n } else {\n // Firefox implements old version of spec.\n width = entry.contentBoxSize.inlineSize;\n height = entry.contentBoxSize.blockSize;\n }\n } else {\n // Chrome <84 implements even older version of spec.\n width = entry.contentRect.width;\n height = entry.contentRect.height;\n }\n\n // Keep the size of the canvas and rubber band canvas in sync with\n // the canvas container.\n if (entry.devicePixelContentBoxSize) {\n // Chrome 84 implements new version of spec.\n canvas.setAttribute(\n 'width',\n entry.devicePixelContentBoxSize[0].inlineSize\n );\n canvas.setAttribute(\n 'height',\n entry.devicePixelContentBoxSize[0].blockSize\n );\n } else {\n canvas.setAttribute('width', width * fig.ratio);\n canvas.setAttribute('height', height * fig.ratio);\n }\n /* This rescales the canvas back to display pixels, so that it\n * appears correct on HiDPI screens. */\n canvas.style.width = width + 'px';\n canvas.style.height = height + 'px';\n\n rubberband_canvas.setAttribute('width', width);\n rubberband_canvas.setAttribute('height', height);\n\n // And update the size in Python. We ignore the initial 0/0 size\n // that occurs as the element is placed into the DOM, which should\n // otherwise not happen due to the minimum size styling.\n if (fig.ws.readyState == 1 && width != 0 && height != 0) {\n fig.request_resize(width, height);\n }\n }\n });\n this.resizeObserverInstance.observe(canvas_div);\n\n function on_mouse_event_closure(name) {\n /* User Agent sniffing is bad, but WebKit is busted:\n * https://bugs.webkit.org/show_bug.cgi?id=144526\n * https://bugs.webkit.org/show_bug.cgi?id=181818\n * The worst that happens here is that they get an extra browser\n * selection when dragging, if this check fails to catch them.\n */\n var UA = navigator.userAgent;\n var isWebKit = /AppleWebKit/.test(UA) && !/Chrome/.test(UA);\n if(isWebKit) {\n return function (event) {\n /* This prevents the web browser from automatically changing to\n * the text insertion cursor when the button is pressed. We\n * want to control all of the cursor setting manually through\n * the 'cursor' event from matplotlib */\n event.preventDefault()\n return fig.mouse_event(event, name);\n };\n } else {\n return function (event) {\n return fig.mouse_event(event, name);\n };\n }\n }\n\n canvas_div.addEventListener(\n 'mousedown',\n on_mouse_event_closure('button_press')\n );\n canvas_div.addEventListener(\n 'mouseup',\n on_mouse_event_closure('button_release')\n );\n canvas_div.addEventListener(\n 'dblclick',\n on_mouse_event_closure('dblclick')\n );\n // Throttle sequential mouse events to 1 every 20ms.\n canvas_div.addEventListener(\n 'mousemove',\n on_mouse_event_closure('motion_notify')\n );\n\n canvas_div.addEventListener(\n 'mouseenter',\n on_mouse_event_closure('figure_enter')\n );\n canvas_div.addEventListener(\n 'mouseleave',\n on_mouse_event_closure('figure_leave')\n );\n\n canvas_div.addEventListener('wheel', function (event) {\n if (event.deltaY < 0) {\n event.step = 1;\n } else {\n event.step = -1;\n }\n on_mouse_event_closure('scroll')(event);\n });\n\n canvas_div.appendChild(canvas);\n canvas_div.appendChild(rubberband_canvas);\n\n this.rubberband_context = rubberband_canvas.getContext('2d');\n this.rubberband_context.strokeStyle = '#000000';\n\n this._resize_canvas = function (width, height, forward) {\n if (forward) {\n canvas_div.style.width = width + 'px';\n canvas_div.style.height = height + 'px';\n }\n };\n\n // Disable right mouse context menu.\n canvas_div.addEventListener('contextmenu', function (_e) {\n event.preventDefault();\n return false;\n });\n\n function set_focus() {\n canvas.focus();\n canvas_div.focus();\n }\n\n window.setTimeout(set_focus, 100);\n};\n\nmpl.figure.prototype._init_toolbar = function () {\n var fig = this;\n\n var toolbar = document.createElement('div');\n toolbar.classList = 'mpl-toolbar';\n this.root.appendChild(toolbar);\n\n function on_click_closure(name) {\n return function (_event) {\n return fig.toolbar_button_onclick(name);\n };\n }\n\n function on_mouseover_closure(tooltip) {\n return function (event) {\n if (!event.currentTarget.disabled) {\n return fig.toolbar_button_onmouseover(tooltip);\n }\n };\n }\n\n fig.buttons = {};\n var buttonGroup = document.createElement('div');\n buttonGroup.classList = 'mpl-button-group';\n for (var toolbar_ind in mpl.toolbar_items) {\n var name = mpl.toolbar_items[toolbar_ind][0];\n var tooltip = mpl.toolbar_items[toolbar_ind][1];\n var image = mpl.toolbar_items[toolbar_ind][2];\n var method_name = mpl.toolbar_items[toolbar_ind][3];\n\n if (!name) {\n /* Instead of a spacer, we start a new button group. */\n if (buttonGroup.hasChildNodes()) {\n toolbar.appendChild(buttonGroup);\n }\n buttonGroup = document.createElement('div');\n buttonGroup.classList = 'mpl-button-group';\n continue;\n }\n\n var button = (fig.buttons[name] = document.createElement('button'));\n button.classList = 'mpl-widget';\n button.setAttribute('role', 'button');\n button.setAttribute('aria-disabled', 'false');\n button.addEventListener('click', on_click_closure(method_name));\n button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n\n var icon_img = document.createElement('img');\n icon_img.src = '_images/' + image + '.png';\n icon_img.srcset = '_images/' + image + '_large.png 2x';\n icon_img.alt = tooltip;\n button.appendChild(icon_img);\n\n buttonGroup.appendChild(button);\n }\n\n if (buttonGroup.hasChildNodes()) {\n toolbar.appendChild(buttonGroup);\n }\n\n var fmt_picker = document.createElement('select');\n fmt_picker.classList = 'mpl-widget';\n toolbar.appendChild(fmt_picker);\n this.format_dropdown = fmt_picker;\n\n for (var ind in mpl.extensions) {\n var fmt = mpl.extensions[ind];\n var option = document.createElement('option');\n option.selected = fmt === mpl.default_extension;\n option.innerHTML = fmt;\n fmt_picker.appendChild(option);\n }\n\n var status_bar = document.createElement('span');\n status_bar.classList = 'mpl-message';\n toolbar.appendChild(status_bar);\n this.message = status_bar;\n};\n\nmpl.figure.prototype.request_resize = function (x_pixels, y_pixels) {\n // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n // which will in turn request a refresh of the image.\n this.send_message('resize', { width: x_pixels, height: y_pixels });\n};\n\nmpl.figure.prototype.send_message = function (type, properties) {\n properties['type'] = type;\n properties['figure_id'] = this.id;\n this.ws.send(JSON.stringify(properties));\n};\n\nmpl.figure.prototype.send_draw_message = function () {\n if (!this.waiting) {\n this.waiting = true;\n this.ws.send(JSON.stringify({ type: 'draw', figure_id: this.id }));\n }\n};\n\nmpl.figure.prototype.handle_save = function (fig, _msg) {\n var format_dropdown = fig.format_dropdown;\n var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n fig.ondownload(fig, format);\n};\n\nmpl.figure.prototype.handle_resize = function (fig, msg) {\n var size = msg['size'];\n if (size[0] !== fig.canvas.width || size[1] !== fig.canvas.height) {\n fig._resize_canvas(size[0], size[1], msg['forward']);\n fig.send_message('refresh', {});\n }\n};\n\nmpl.figure.prototype.handle_rubberband = function (fig, msg) {\n var x0 = msg['x0'] / fig.ratio;\n var y0 = (fig.canvas.height - msg['y0']) / fig.ratio;\n var x1 = msg['x1'] / fig.ratio;\n var y1 = (fig.canvas.height - msg['y1']) / fig.ratio;\n x0 = Math.floor(x0) + 0.5;\n y0 = Math.floor(y0) + 0.5;\n x1 = Math.floor(x1) + 0.5;\n y1 = Math.floor(y1) + 0.5;\n var min_x = Math.min(x0, x1);\n var min_y = Math.min(y0, y1);\n var width = Math.abs(x1 - x0);\n var height = Math.abs(y1 - y0);\n\n fig.rubberband_context.clearRect(\n 0,\n 0,\n fig.canvas.width / fig.ratio,\n fig.canvas.height / fig.ratio\n );\n\n fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n};\n\nmpl.figure.prototype.handle_figure_label = function (fig, msg) {\n // Updates the figure title.\n fig.header.textContent = msg['label'];\n};\n\nmpl.figure.prototype.handle_cursor = function (fig, msg) {\n fig.canvas_div.style.cursor = msg['cursor'];\n};\n\nmpl.figure.prototype.handle_message = function (fig, msg) {\n fig.message.textContent = msg['message'];\n};\n\nmpl.figure.prototype.handle_draw = function (fig, _msg) {\n // Request the server to send over a new figure.\n fig.send_draw_message();\n};\n\nmpl.figure.prototype.handle_image_mode = function (fig, msg) {\n fig.image_mode = msg['mode'];\n};\n\nmpl.figure.prototype.handle_history_buttons = function (fig, msg) {\n for (var key in msg) {\n if (!(key in fig.buttons)) {\n continue;\n }\n fig.buttons[key].disabled = !msg[key];\n fig.buttons[key].setAttribute('aria-disabled', !msg[key]);\n }\n};\n\nmpl.figure.prototype.handle_navigate_mode = function (fig, msg) {\n if (msg['mode'] === 'PAN') {\n fig.buttons['Pan'].classList.add('active');\n fig.buttons['Zoom'].classList.remove('active');\n } else if (msg['mode'] === 'ZOOM') {\n fig.buttons['Pan'].classList.remove('active');\n fig.buttons['Zoom'].classList.add('active');\n } else {\n fig.buttons['Pan'].classList.remove('active');\n fig.buttons['Zoom'].classList.remove('active');\n }\n};\n\nmpl.figure.prototype.updated_canvas_event = function () {\n // Called whenever the canvas gets updated.\n this.send_message('ack', {});\n};\n\n// A function to construct a web socket function for onmessage handling.\n// Called in the figure constructor.\nmpl.figure.prototype._make_on_message_function = function (fig) {\n return function socket_on_message(evt) {\n if (evt.data instanceof Blob) {\n var img = evt.data;\n if (img.type !== 'image/png') {\n /* FIXME: We get \"Resource interpreted as Image but\n * transferred with MIME type text/plain:\" errors on\n * Chrome. But how to set the MIME type? It doesn't seem\n * to be part of the websocket stream */\n img.type = 'image/png';\n }\n\n /* Free the memory for the previous frames */\n if (fig.imageObj.src) {\n (window.URL || window.webkitURL).revokeObjectURL(\n fig.imageObj.src\n );\n }\n\n fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n img\n );\n fig.updated_canvas_event();\n fig.waiting = false;\n return;\n } else if (\n typeof evt.data === 'string' &&\n evt.data.slice(0, 21) === 'data:image/png;base64'\n ) {\n fig.imageObj.src = evt.data;\n fig.updated_canvas_event();\n fig.waiting = false;\n return;\n }\n\n var msg = JSON.parse(evt.data);\n var msg_type = msg['type'];\n\n // Call the \"handle_{type}\" callback, which takes\n // the figure and JSON message as its only arguments.\n try {\n var callback = fig['handle_' + msg_type];\n } catch (e) {\n console.log(\n \"No handler for the '\" + msg_type + \"' message type: \",\n msg\n );\n return;\n }\n\n if (callback) {\n try {\n // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n callback(fig, msg);\n } catch (e) {\n console.log(\n \"Exception inside the 'handler_\" + msg_type + \"' callback:\",\n e,\n e.stack,\n msg\n );\n }\n }\n };\n};\n\nfunction getModifiers(event) {\n var mods = [];\n if (event.ctrlKey) {\n mods.push('ctrl');\n }\n if (event.altKey) {\n mods.push('alt');\n }\n if (event.shiftKey) {\n mods.push('shift');\n }\n if (event.metaKey) {\n mods.push('meta');\n }\n return mods;\n}\n\n/*\n * return a copy of an object with only non-object keys\n * we need this to avoid circular references\n * https://stackoverflow.com/a/24161582/3208463\n */\nfunction simpleKeys(original) {\n return Object.keys(original).reduce(function (obj, key) {\n if (typeof original[key] !== 'object') {\n obj[key] = original[key];\n }\n return obj;\n }, {});\n}\n\nmpl.figure.prototype.mouse_event = function (event, name) {\n if (name === 'button_press') {\n this.canvas.focus();\n this.canvas_div.focus();\n }\n\n // from https://stackoverflow.com/q/1114465\n var boundingRect = this.canvas.getBoundingClientRect();\n var x = (event.clientX - boundingRect.left) * this.ratio;\n var y = (event.clientY - boundingRect.top) * this.ratio;\n\n this.send_message(name, {\n x: x,\n y: y,\n button: event.button,\n step: event.step,\n modifiers: getModifiers(event),\n guiEvent: simpleKeys(event),\n });\n\n return false;\n};\n\nmpl.figure.prototype._key_event_extra = function (_event, _name) {\n // Handle any extra behaviour associated with a key event\n};\n\nmpl.figure.prototype.key_event = function (event, name) {\n // Prevent repeat events\n if (name === 'key_press') {\n if (event.key === this._key) {\n return;\n } else {\n this._key = event.key;\n }\n }\n if (name === 'key_release') {\n this._key = null;\n }\n\n var value = '';\n if (event.ctrlKey && event.key !== 'Control') {\n value += 'ctrl+';\n }\n else if (event.altKey && event.key !== 'Alt') {\n value += 'alt+';\n }\n else if (event.shiftKey && event.key !== 'Shift') {\n value += 'shift+';\n }\n\n value += 'k' + event.key;\n\n this._key_event_extra(event, name);\n\n this.send_message(name, { key: value, guiEvent: simpleKeys(event) });\n return false;\n};\n\nmpl.figure.prototype.toolbar_button_onclick = function (name) {\n if (name === 'download') {\n this.handle_save(this, null);\n } else {\n this.send_message('toolbar_button', { name: name });\n }\n};\n\nmpl.figure.prototype.toolbar_button_onmouseover = function (tooltip) {\n this.message.textContent = tooltip;\n};\n\n///////////////// REMAINING CONTENT GENERATED BY embed_js.py /////////////////\n// prettier-ignore\nvar _JSXTOOLS_RESIZE_OBSERVER=function(A){var t,i=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakMap,o=new Set;function s(e){if(!(this instanceof s))throw new TypeError(\"Constructor requires 'new' operator\");i.set(this,e)}function h(){throw new TypeError(\"Function is not a constructor\")}function c(e,t,i,n){e=0 in arguments?Number(arguments[0]):0,t=1 in arguments?Number(arguments[1]):0,i=2 in arguments?Number(arguments[2]):0,n=3 in arguments?Number(arguments[3]):0,this.right=(this.x=this.left=e)+(this.width=i),this.bottom=(this.y=this.top=t)+(this.height=n),Object.freeze(this)}function d(){t=requestAnimationFrame(d);var s=new WeakMap,p=new Set;o.forEach((function(t){r.get(t).forEach((function(i){var r=t instanceof window.SVGElement,o=a.get(t),d=r?0:parseFloat(o.paddingTop),f=r?0:parseFloat(o.paddingRight),l=r?0:parseFloat(o.paddingBottom),u=r?0:parseFloat(o.paddingLeft),g=r?0:parseFloat(o.borderTopWidth),m=r?0:parseFloat(o.borderRightWidth),w=r?0:parseFloat(o.borderBottomWidth),b=u+f,F=d+l,v=(r?0:parseFloat(o.borderLeftWidth))+m,W=g+w,y=r?0:t.offsetHeight-W-t.clientHeight,E=r?0:t.offsetWidth-v-t.clientWidth,R=b+v,z=F+W,M=r?t.width:parseFloat(o.width)-R-E,O=r?t.height:parseFloat(o.height)-z-y;if(n.has(t)){var k=n.get(t);if(k[0]===M&&k[1]===O)return}n.set(t,[M,O]);var S=Object.create(h.prototype);S.target=t,S.contentRect=new c(u,d,M,O),s.has(i)||(s.set(i,[]),p.add(i)),s.get(i).push(S)}))})),p.forEach((function(e){i.get(e).call(e,s.get(e),e)}))}return s.prototype.observe=function(i){if(i instanceof window.Element){r.has(i)||(r.set(i,new Set),o.add(i),a.set(i,window.getComputedStyle(i)));var n=r.get(i);n.has(this)||n.add(this),cancelAnimationFrame(t),t=requestAnimationFrame(d)}},s.prototype.unobserve=function(i){if(i instanceof window.Element&&r.has(i)){var n=r.get(i);n.has(this)&&(n.delete(this),n.size||(r.delete(i),o.delete(i))),n.size||r.delete(i),o.size||cancelAnimationFrame(t)}},A.DOMRectReadOnly=c,A.ResizeObserver=s,A.ResizeObserverEntry=h,A}; // eslint-disable-line\nmpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Left button pans, Right button zooms\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-arrows\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\\nx/y fixes axis\", \"fa fa-square-o\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o\", \"download\"]];\n\nmpl.extensions = [\"eps\", \"jpeg\", \"pgf\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\", \"webp\"];\n\nmpl.default_extension = \"png\";/* global mpl */\n\nvar comm_websocket_adapter = function (comm) {\n // Create a \"websocket\"-like object which calls the given IPython comm\n // object with the appropriate methods. Currently this is a non binary\n // socket, so there is still some room for performance tuning.\n var ws = {};\n\n ws.binaryType = comm.kernel.ws.binaryType;\n ws.readyState = comm.kernel.ws.readyState;\n function updateReadyState(_event) {\n if (comm.kernel.ws) {\n ws.readyState = comm.kernel.ws.readyState;\n } else {\n ws.readyState = 3; // Closed state.\n }\n }\n comm.kernel.ws.addEventListener('open', updateReadyState);\n comm.kernel.ws.addEventListener('close', updateReadyState);\n comm.kernel.ws.addEventListener('error', updateReadyState);\n\n ws.close = function () {\n comm.close();\n };\n ws.send = function (m) {\n //console.log('sending', m);\n comm.send(m);\n };\n // Register the callback with on_msg.\n comm.on_msg(function (msg) {\n //console.log('receiving', msg['content']['data'], msg);\n var data = msg['content']['data'];\n if (data['blob'] !== undefined) {\n data = {\n data: new Blob(msg['buffers'], { type: data['blob'] }),\n };\n }\n // Pass the mpl event to the overridden (by mpl) onmessage function.\n ws.onmessage(data);\n });\n return ws;\n};\n\nmpl.mpl_figure_comm = function (comm, msg) {\n // This is the function which gets called when the mpl process\n // starts-up an IPython Comm through the \"matplotlib\" channel.\n\n var id = msg.content.data.id;\n // Get hold of the div created by the display call when the Comm\n // socket was opened in Python.\n var element = document.getElementById(id);\n var ws_proxy = comm_websocket_adapter(comm);\n\n function ondownload(figure, _format) {\n window.open(figure.canvas.toDataURL());\n }\n\n var fig = new mpl.figure(id, ws_proxy, ondownload, element);\n\n // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n // web socket which is closed, not our websocket->open comm proxy.\n ws_proxy.onopen();\n\n fig.parent_element = element;\n fig.cell_info = mpl.find_output_cell(\"
\");\n if (!fig.cell_info) {\n console.error('Failed to find cell for figure', id, fig);\n return;\n }\n fig.cell_info[0].output_area.element.on(\n 'cleared',\n { fig: fig },\n fig._remove_fig_handler\n );\n};\n\nmpl.figure.prototype.handle_close = function (fig, msg) {\n var width = fig.canvas.width / fig.ratio;\n fig.cell_info[0].output_area.element.off(\n 'cleared',\n fig._remove_fig_handler\n );\n fig.resizeObserverInstance.unobserve(fig.canvas_div);\n\n // Update the output cell to use the data from the current canvas.\n fig.push_to_output();\n var dataURL = fig.canvas.toDataURL();\n // Re-enable the keyboard manager in IPython - without this line, in FF,\n // the notebook keyboard shortcuts fail.\n IPython.keyboard_manager.enable();\n fig.parent_element.innerHTML =\n '';\n fig.close_ws(fig, msg);\n};\n\nmpl.figure.prototype.close_ws = function (fig, msg) {\n fig.send_message('closing', msg);\n // fig.ws.close()\n};\n\nmpl.figure.prototype.push_to_output = function (_remove_interactive) {\n // Turn the data on the canvas into data in the output cell.\n var width = this.canvas.width / this.ratio;\n var dataURL = this.canvas.toDataURL();\n this.cell_info[1]['text/html'] =\n '';\n};\n\nmpl.figure.prototype.updated_canvas_event = function () {\n // Tell IPython that the notebook contents must change.\n IPython.notebook.set_dirty(true);\n this.send_message('ack', {});\n var fig = this;\n // Wait a second, then push the new image to the DOM so\n // that it is saved nicely (might be nice to debounce this).\n setTimeout(function () {\n fig.push_to_output();\n }, 1000);\n};\n\nmpl.figure.prototype._init_toolbar = function () {\n var fig = this;\n\n var toolbar = document.createElement('div');\n toolbar.classList = 'btn-toolbar';\n this.root.appendChild(toolbar);\n\n function on_click_closure(name) {\n return function (_event) {\n return fig.toolbar_button_onclick(name);\n };\n }\n\n function on_mouseover_closure(tooltip) {\n return function (event) {\n if (!event.currentTarget.disabled) {\n return fig.toolbar_button_onmouseover(tooltip);\n }\n };\n }\n\n fig.buttons = {};\n var buttonGroup = document.createElement('div');\n buttonGroup.classList = 'btn-group';\n var button;\n for (var toolbar_ind in mpl.toolbar_items) {\n var name = mpl.toolbar_items[toolbar_ind][0];\n var tooltip = mpl.toolbar_items[toolbar_ind][1];\n var image = mpl.toolbar_items[toolbar_ind][2];\n var method_name = mpl.toolbar_items[toolbar_ind][3];\n\n if (!name) {\n /* Instead of a spacer, we start a new button group. */\n if (buttonGroup.hasChildNodes()) {\n toolbar.appendChild(buttonGroup);\n }\n buttonGroup = document.createElement('div');\n buttonGroup.classList = 'btn-group';\n continue;\n }\n\n button = fig.buttons[name] = document.createElement('button');\n button.classList = 'btn btn-default';\n button.href = '#';\n button.title = name;\n button.innerHTML = '';\n button.addEventListener('click', on_click_closure(method_name));\n button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n buttonGroup.appendChild(button);\n }\n\n if (buttonGroup.hasChildNodes()) {\n toolbar.appendChild(buttonGroup);\n }\n\n // Add the status bar.\n var status_bar = document.createElement('span');\n status_bar.classList = 'mpl-message pull-right';\n toolbar.appendChild(status_bar);\n this.message = status_bar;\n\n // Add the close button to the window.\n var buttongrp = document.createElement('div');\n buttongrp.classList = 'btn-group inline pull-right';\n button = document.createElement('button');\n button.classList = 'btn btn-mini btn-primary';\n button.href = '#';\n button.title = 'Stop Interaction';\n button.innerHTML = '';\n button.addEventListener('click', function (_evt) {\n fig.handle_close(fig, {});\n });\n button.addEventListener(\n 'mouseover',\n on_mouseover_closure('Stop Interaction')\n );\n buttongrp.appendChild(button);\n var titlebar = this.root.querySelector('.ui-dialog-titlebar');\n titlebar.insertBefore(buttongrp, titlebar.firstChild);\n};\n\nmpl.figure.prototype._remove_fig_handler = function (event) {\n var fig = event.data.fig;\n if (event.target !== this) {\n // Ignore bubbled events from children.\n return;\n }\n fig.close_ws(fig, {});\n};\n\nmpl.figure.prototype._root_extra_style = function (el) {\n el.style.boxSizing = 'content-box'; // override notebook setting of border-box.\n};\n\nmpl.figure.prototype._canvas_extra_style = function (el) {\n // this is important to make the div 'focusable\n el.setAttribute('tabindex', 0);\n // reach out to IPython and tell the keyboard manager to turn it's self\n // off when our div gets focus\n\n // location in version 3\n if (IPython.notebook.keyboard_manager) {\n IPython.notebook.keyboard_manager.register_events(el);\n } else {\n // location in version 2\n IPython.keyboard_manager.register_events(el);\n }\n};\n\nmpl.figure.prototype._key_event_extra = function (event, _name) {\n // Check for shift+enter\n if (event.shiftKey && event.which === 13) {\n this.canvas_div.blur();\n // select the cell after this one\n var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n IPython.notebook.select(index + 1);\n }\n};\n\nmpl.figure.prototype.handle_save = function (fig, _msg) {\n fig.ondownload(fig, null);\n};\n\nmpl.find_output_cell = function (html_output) {\n // Return the cell and output element which can be found *uniquely* in the notebook.\n // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n // IPython event is triggered only after the cells have been serialised, which for\n // our purposes (turning an active figure into a static one), is too late.\n var cells = IPython.notebook.get_cells();\n var ncells = cells.length;\n for (var i = 0; i < ncells; i++) {\n var cell = cells[i];\n if (cell.cell_type === 'code') {\n for (var j = 0; j < cell.output_area.outputs.length; j++) {\n var data = cell.output_area.outputs[j];\n if (data.data) {\n // IPython >= 3 moved mimebundle to data attribute of output\n data = data.data;\n }\n if (data['text/html'] === html_output) {\n return [cell, data, j];\n }\n }\n }\n }\n};\n\n// Register the function which deals with the matplotlib target/channel.\n// The kernel may be null if the page has been refreshed.\nif (IPython.notebook.kernel !== null) {\n IPython.notebook.kernel.comm_manager.register_target(\n 'matplotlib',\n mpl.mpl_figure_comm\n );\n}\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "9c613fb7abf54461a575817c30e50706", - "version_major": 2, - "version_minor": 0 - }, - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAyAAAAJYCAYAAACadoJwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAB6NklEQVR4nO3deXxU9fX/8fdkshHMYogQIhgQFEjYFAlClWANm8jSIvBAWdwAKbgLKrWiQotSEf2CBbEB9GdlsdWwCJbAA0EkSAEJqwhKQIUQqZCAQDJkPr8/pplkIEC2WZJ5PR+PeZA5c+6dc+fMDDm5985YjDFGAAAAAOABAd4uAAAAAID/YAABAAAA4DEMIAAAAAA8hgEEAAAAgMcwgAAAAADwGAYQAAAAAB7DAAIAAADAYxhAAAAAAHgMAwgAAAAAj2EAAQAAAOAxDCAAAAAAPIYBBAAAAIDHMIAAAAAA8BgGEAAAAAAewwACAAAAwGMYQAAAAAB4DAMIAAAAAI9hAAEAAADgMQwgAAAAADyGAQQAAACAxzCAAAAAAPAYBhAAAAAAHsMAAgAAAMBjGEAAAAAAeAwDCAAAAACPYQABAAAA4DEMIAAAAAA8hgEEAAAAgMcwgAAAAADwGAYQAAAAAB7DAAIAAADAYxhAAAAAAHgMAwgA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pfIyEhvl3dZwcHBateundasWeMcQOx2u9asWaOxY8eWukxISIhCQkIuigcFBV30BlZYWCiLxaKAgAAFBPjcpydf1s6dOxUVFaXrr7/e26W4WL58uXr37u08bOqf//ynmjdvrhYtWmjo0KF64oknNGHCBFkslsuuJyAgQBaLpdS+lUVFl0P1RL/9C/32L/TbP9DjyvOp32TT09N18OBB9e7dWzk5Ofrpp580efJkRUdHq2nTpt4u74qeeuopvfvuu3rvvfe0d+9ejR49Wr/++qseeOABb5fmVdu3b1fr1q3LnJ+SkqL9+/e7sSKHJUuWuHzRZWpqqoYMGSJJ6tGjh3Jzc7Vu3Tq31wEAAOBPfGoPSJHFixdr+/btzuurVq3SP/7xD+8VVEaDBg3Szz//rBdffFHZ2dlq27atPvvss4tOTHe7wkKp5MneVqsUECBdeNJUUNCVcwMCHLFKyMzMVNu2bcucv3//frcfird3714dOXJEd955pyRp37592rx5sz755BNJjnNWBg0apNTUVHXp0sWttQAAAPgTn9oDUiQ0NFR79uxxXu/WrZt27drlxYrKbuzYsTp06JDy8/P11VdfqUOHDp4vYtIkKTi4+FL0jfJhYcWxG25wxN54wzU3NdURv+Yax/X/fTpUZWzfvl1t2rSRJL377ru6+eab1bJlSw0aNEiStHv3bnXo0EGtW7fWn//8Z8XGxiogIEBZWVlq06aN7rvvPt1www0aPXq00tLS1KFDB7Vs2dJlL8ndd9+tdu3aqWXLls5hNSMjQ0lJSTp//ryOHTumG264QdnZ2ZKkpUuXqmvXrs5zNlJTU3X+/HnFxcUpMDBQgYGBmjVrlv71r38pNze30o8BAAAAHHxyD0hqaqoGDRqkLl26qG3bttq5c+cVj8NHCX/6k/THPxZfL9qDUdqnNjz1lPTEExfn/vyz499Knm+Sl5enrKwstW3bVidOnNDbb7+trVu3ymq16uTJk8rPz9egQYO0YMECtWrVSv369XM5XGvv3r1avHixmjZtqpYtW+qqq67SV199pXfeeUczZ87UW2+9JUl6//33FR0drV9//VXt27fXPffco44dO6pz58567bXX9PXXX+vFF19UbGysJMfhVyNHjpQknT9/Xu+//76mTZumbt26udTfr18/LViwQI888kilHgcAAAA4+OQekMTERG3dulW33367srKy1KhRI61cudLbZVUfVqvj8KqiS9EQUTJWdALVlXKr4PArq9WqxMREBQYG6sSJExo/frx2796tqKgopaWlKTk5Wa1atZLk+BjmkgNIs2bN1KxZM1mtVrVo0cL5RY+tWrVSVlaWM2/69Olq06aNOnXqpMOHD+vw4cOSpMmTJ+v//b//p3Pnzmno0KGSpJycHG3ZskV33323JMfJ6CdOnNBDDz2kli1bulz69++v1KK9QgAAAKg0nxxABg8erHPnzmngwIG65ZZbdO211+qaa67xdlmogMzMTDVv3lwhISEKDw/Xrl271LZtWw0cOFBpaWnauXOny/khW7dudRlASn5KWEBAgPN6QECACgsLJTm+N+XLL7/UV1995by/oo83zsnJUUFBgfOLIiVp2bJlSkpKUkxMjCTHHreUlJRSP2mtf//+2rJli3bs2FG1DwwAAICf8skBZPfu3YqIiNCePXv0xz/+UZ9//rkeffRRb5eFChg7dqx27twpyXFyeXh4uIYOHark5GTl5+crOjraeX7PqlWrtHr16nJ9YpbkOMyrTp06Cg0N1fbt25WZmem8bcSIEZoxY4bat2+vadOmSbr406+WLVumTz/9tNR1JyUlyRhT7poAAABQOp88ByQoKEjGGM2bN0/PPfechgwZonbt2nm7LFTS5MmTtWnTJoWFhalTp04aMGCAjh8/rp49e+qmm25Sy5YtFR8fr6uvvrpc6+3Ro4dmzZqlhIQEJSYmOp8rqampqlu3rnr16qUuXbooKSlJffv21W233abBgwe7YxMBAABwBT45gDzyyCO6+eabdfLkSb300kuSpF9//dW7RaHS3nvvvYtidevW1datW0vNb9SokbZs2eK8/s9//tP586233qrly5dLchym9dlnn120fMuWLfXQQw9JkmrXrq3du3dLksaPH1/xjQAAAECleO0QrKFDh+rs2bOS5DxhuMiIESO0du1a7dy5U7Vr19aBAwd06623eqNMAAAAAFXIa3tAateurfz8fNWqVUuNGjXS1VdfrdatW6tt27Zq06aNbrrpJiUkJEiSmjZtqvnz53urVA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4eLjq1q2rfv36OQ8LKtKlSxdZLBaXy4UnOx8+fFi9evVSWFiY6tatq3Hjxun8+ar5NCp/sGPHjkp9YSEAAAB8H3tAJK1bt05jxoxR+/btdf78eU2YMEHdunXTnj17VLt2bWfeiBEj9Morrzivh4WFOX8uLCxUr169FBsbq40bN+ro0aMaNmyYgoKC9Je//MWj21NdjRgxwtslAAAAwM0YQCR99tlnLtfnz5+vunXrauvWrercubMzHhYWptjY2FLXsWrVKu3Zs0erV69WvXr11LZtW02aNEnPPvusXnrpJQUHB7t1GwAAAIDqgEOwSpGbmytJio52/fbvf/zjH4qJiVHLli31/PPP68yZM87bMjIy1KpVK9WrV88Z6969u/Ly8rR7927PFA4AAAD4OPaAXMBut+uJJ57Qb37zG7Vs2dIZv/feexUfH6+4uDjt2LFDzz77rPbt26ePP/5YkpSdne0yfEhyXs/Ozi71vvLz85Wfn++8npeXJ0my2Wyy2WwuuTabTcYY2e122e32ym8oqozdbpcxRjabTVartczLFfX4wl6jZqLf/oV++xf67V/oc+UxgFxgzJgx2rVrlzZs2OASHzlypPPnVq1aqX79+rrzzjv13XffqUmTJhW6rylTpujll1++KL527VqX80skKTAwULGxsTp9+rQKCgoqdH9wj4KCAp09e1br16+v0IcOpKenu6Eq+Cr67V/ot3+h3/6h5BEwqBgGkBLGjh2r5cuXa/369WrQoMFlczt06CBJOnDggJo0aaLY2Fht3rzZJefYsWOSdMnzRp5//nk99dRTzut5eXlq2LCh7rjjDtWpU8cl99y5c/rhhx901VVXKTQ0tNzbBvc5d+6catWqpc6dO5erNzabTenp6eratauCgoLcWCF8Af32L/Tbv9Bv/1J0xAoqjgFEkjFGjz76qD755BN9/vnnaty48RWX2b59uySpfv36kqSOHTvqz3/+s3JyclS3bl1Jjr+EREREKCEhodR1hISEKCQk5KJ4UFDQRW9ghYWFslgsCggIUEAAp+74koCAAFksllL7VhYVXQ7VE/32L/Tbv9Bv/0CPK48BRI7Drj788EMtWbJE4eHhznM2IiMjVatWLX333Xf68MMPddddd6lOnTrasWOHnnzySXXu3Nn5vRXdunVTQkKChg4dqqlTpyo7O1svvPCCxowZU+qQAQAAAPgj/pQuadasWcrNzVWXLl1Uv35952XRokWSpODgYK1evVrdunVT8+bN9fTTT6t///5atmyZcx1Wq1XLly+X1WpVx44dNWTIEA0bNszle0MAAAAAf8ceEDkOwbqchg0bat26dVdcT3x8vFasWFFVZQEAAAA1DntAAAAAAHgMAwgAAAAAj2EAgc8rOkTupZdecrkOAACA6odzQODzZs2apcDAQP3666967rnn1LNnTyUnJ3u7LAAAAFQAe0DgEaNGjdJ9991XoWX/8Ic/KDc3V//3f/+n3r17M3wAAABUYwwg8IgpU6Zozpw5FVp29uzZioyM1GOPPaZly5bpiy++KDXvgQce0AsvvOASy8jIkNVqVa9evSp03wAAAKhaDCDwiOjoaNWuXbtCy44aNUojR45U7dq19eqrr+q22267KKewsFDLly9Xnz59XOKpqal69NFHtX79eh05cqRC9w8AAICqwwACt8vKypLFYlFWVlaFlrdYLJKKT0Ivul7Sxo0bFRQUpPbt2ztjp0+f1qJFizR69Gj16tVL8+fPr9D9AwAAoOowgMDtMjMzFRUVpUaNGrntPpYuXarevXu7DCeLFy9W8+bN1axZMw0ZMkRz587lE7QAAAC8jE/BqmkOb5JWvyzln6qa9YVGSHe+KF13a4VXsX37drVu3bpq6rmEJUuWaPr06S6x1NRUDRkyRJLUo0cP5ebmat26derSpYtbawEAAMClMYDUNBtnSIc3Vv06KzGAZGZmqm3btlVXzwX27t2rI0eO6M4773TG9u3bp82bN+uTTz6RJAUGBmrQoEFKTU1lAAEAAPAiBpCaptOj0plfqnYPSKdHK7WK7du36+67766aekqxdOlSde3aVaGhoc5Yamqqzp8/r7i4OGfMGKOQkBDNnDlTkZGRbqsHAAAAl8YAUtNcd6v04EpvV+GUl5enrKws5x6Qd999V7NmzVJBQYESExO1aNEi7d69WyNHjtTJkyfVrVs37dixQ2vWrCnzfSxZskQjR450Xj9//rzef/99TZs2Td26dXPJ7devnxYsWKBHHnmkSr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AAAwCd4ZQCZO3eusrOztWDBAoWHh+uJJ55QTEyM+vfvr/fff1+//PKLN8qqtDfeeEMjRozQAw88oISEBM2ePVthYWGaO3eut0sDAAAAfILXvgk9ICBAt99+u26//XZNnTpVe/fu1bJly/TOO+9o5MiRSkpKUp8+fTR48GBde+213iqzzAoKCrR161Y9//zzzlhAQIBSUlKUkZFR6jL5+fnKz893Xs/Ly5Mk2Ww22Ww2l1ybzSZjjOx2u+x2uxu2ABVlt9tljJHNZpPVai3zckU9vrDXqJnot3+h3/6FfvsX+lx5XhtALtSiRQu1aNFC48ePV05OjpYtW+Y8D+SZZ57xcnVXdvz4cRUWFqpevXou8Xr16umbb74pdZkpU6bo5Zdfvii+du1ahYWFucQCAwMVGxur06dP14jD1WqSgoICnT17VuvXr9f58+fLvXx6erobqoKvot/+hX77F/rtH86cOePtEqo9izHGeLuImuDIkSO69tprtXHjRnXs2NEZHz9+vNatW6evvvrqomVK2wPSsGFDHT16VHXq1HHJPXfunH744QfnCe7wHefOnVNWVpYaNmxYrt7YbDalp6era9euCgoKcmOF8AX027/Qb/9Cv/1LXl6eYmJilJubq4iICG+XUy35zB4QSUpJSVGbNm3UqlUrtW7dWomJiQoJCfF2WWUSExMjq9WqY8eOucSPHTum2NjYUpcJCQkpdfuCgoIuegMrLCyUxWJRQECAAgJ85tOTy2zUqFE6ffq0/vGPf3i7lCoXEBAgi8VSat/KoqLLoXqi3/6FfvsX+u0f6HHl+dRvsq1bt9b333+vb775Rn/84x8VERGhxMREDRw4UJMnT/Z2eZcVHBysdu3aac2aNc6Y3W7XmjVrXPaI+KspU6Zozpw53i7jIg888IBeeOEF5/WMjAxZrVb16tXLi1UBAADUXD61ByQ9PV07d+50Xl+xYoU2bdqku+++Wzt27PBiZWXz1FNPafjw4brllluUlJSkN998U7/++qseeOABb5fmddHR0d4u4SKFhYVavny5Pv30U2csNTVVjz76qFJTU3XkyBHFxcV5sUIAAICax6f2gERGRmrfvn3O63fddZeWLVumpKQkPfzww16srGw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MAAgAAAMBjGEAAAAAAeAwDCAAAAACPYQABAAAA4DEMIAAAAAA85v8DPbVHbs6hWkwAAAAASUVORK5CYII=", "text/html": [ - "\n", - "
\n", - "
\n", - " Figure\n", - "
\n", - " \n", - "
\n", - " " + "
" ], "text/plain": [ - "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …" + "" ] }, "metadata": {}, @@ -211,27 +221,28 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ - "done = True\n", + "terminated = True\n", "\n", "for _ in range(10000):\n", - " if done:\n", + " if terminated:\n", " # Reset the environment\n", " # This is required initally or after an episode end due to a constraint violation in the env.\n", " state, references = env.reset()\n", - " # visualize environment. Red vertical lines indicate a constraint violation and therefore, a reset environment.\n", + " # Visualization of environment: Red vertical lines indicate a constraint violation and therefore, a reset environment.\n", " # Blue vertical lines indicate an additional reset by the user which is not due to a terminated episode.\n", - " env.render() \n", + " \n", " # pick random control actions\n", " action = env.action_space.sample()\n", " # Execute one control cycle on the environment\n", - " (states, references), rewards, done, _ = env.step(action) " + " (states, references), rewards, terminated, truncated, _ = env.step(action) " ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -254,6 +265,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -261,6 +273,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -284,6 +297,7 @@ "* state_filter(list(str))\n", "* callbacks(list(Callback))\n", "* physical_system_wrappers(iterable(PhysicalSystemWrapper))\n", + "* render_mode(str)\n", "\n", "#### Environment-arg type:\n", "The `env-arg` type is a short notation for all parameters that can be passed in three different ways to override the default behavior. Exemplary, it is shown how to change the reference generator of an environment in three different ways:\n", @@ -310,6 +324,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -339,6 +354,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -389,7 +405,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -417,6 +433,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -431,7 +448,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -439,6 +456,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -453,7 +471,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -465,6 +483,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -486,7 +505,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -501,6 +520,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -522,7 +542,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -566,6 +586,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -583,7 +604,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -597,6 +618,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -612,7 +634,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -623,6 +645,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -650,7 +673,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -682,6 +705,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -697,7 +721,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -717,6 +741,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -734,7 +759,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -809,7 +834,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -817,6 +842,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -831,7 +857,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -851,7 +877,7 @@ " load=load,\n", " reward_function=rf,\n", " tau=tau,\n", - " supply=supply,\n", + " #supply=supply,\n", " reference_generator=rg,\n", " ode_solver='euler',\n", " callbacks=my_callback,\n", @@ -861,42 +887,16 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### 2.9 Seeding\n", - "The random processes in the environment can be made reproducible by seeding the environments. The `env.seed()` method has to be called after the initialization and before the first reset to seed all random generators.\n", - "\n", - "The `env.seed` method returns a list of seeds that are used in the different random generators in the environment.\n", - "The first entry in the list is the base-seed which can be used afterwards to reset the random generators to the previous state." - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n" - ] - } - ], - "source": [ - "# Without any argument, a random base-seed will be generated\n", - "initial_seeds = env.seed()\n", - "\n", - "# ... execute the env for multiple steps / episodes ...\n", - "new_seeds = env.seed(initial_seeds[0])\n", - "\n", - "# ... execute the env again for multiple steps / episodes ... \n", - "# these episodes will use the SAME randomly generated numbers\n", - "print(initial_seeds == new_seeds)" + "The random processes in the environment can be made reproducible by seeding the environments. The seeding takes place when resetting an environment, i.e. calling `env.reset(seed=seed)` with the keyword argument `seed`. " ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -904,6 +904,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -966,14 +967,15 @@ "env.reset()\n", "k = 0\n", "for i in range(int(3e4)): \n", - " env.render() # visualize environment\n", - " (states, refs), rewards, done, _ = env.step(env.action_space.sample()) # pick random control actions\n", - " if done:\n", + "\n", + " (states, refs), rewards, terminated, truncated, _ = env.step(env.action_space.sample()) # pick random control actions\n", + " if terminated:\n", " env.reset()\n", "env.close()" ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -997,7 +999,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.5" + "version": "3.10.6" }, "varInspector": { "cols": { From 054f19b1b5f6c31e6b784f2e22a679f30d031346 Mon Sep 17 00:00:00 2001 From: KoehlerM173 Date: Mon, 17 Jul 2023 08:29:13 +0200 Subject: [PATCH 36/37] removed first draft of integration test and renamend current --- ...c_controllers_dc_motor_integration_test.py | 72 ------------------- ...tion_test_classic_controllers_dc_motor.py} | 0 2 files changed, 72 deletions(-) delete mode 100644 examples/classic_controllers/classic_controllers_dc_motor_integration_test.py rename examples/classic_controllers/{classic_controllers_dc_motor_integration_test_2.py => integration_test_classic_controllers_dc_motor.py} (100%) diff --git a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py b/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py deleted file mode 100644 index 4aa1ff15..00000000 --- a/examples/classic_controllers/classic_controllers_dc_motor_integration_test.py +++ /dev/null @@ -1,72 +0,0 @@ -from classic_controllers import Controller -from externally_referenced_state_plot import ExternallyReferencedStatePlot -import gym_electric_motor as gem -from gym_electric_motor.visualization import MotorDashboard -import time - -if __name__ == '__main__': - - """ - motor type: 'PermExDc' Permanently Excited DC Motor - 'ExtExDc' Externally Excited MC Motor - 'SeriesDc' DC Series Motor - 'ShuntDc' DC Shunt Motor - - control type: 'SC' Speed Control - 'TC' Torque Control - 'CC' Current Control - - action_type: 'Cont' Continuous Action Space - 'Finite' Discrete Action Space - """ - - motor_type = 'PermExDc' - control_type = 'TC' - action_type = 'Cont' - - motor = action_type + '-' + control_type + '-' + motor_type + '-v0' - - if motor_type in ['PermExDc', 'SeriesDc']: - states = ['omega', 'torque', 'i', 'u'] - elif motor_type == 'ShuntDc': - states = ['omega', 'torque', 'i_a', 'i_e', 'u'] - elif motor_type == 'ExtExDc': - states = ['omega', 'torque', 'i_a', 'i_e', 'u_a', 'u_e'] - else: - raise KeyError(motor_type + ' is not available') - - # definition of the plotted variables - external_ref_plots = [ExternallyReferencedStatePlot(state) for state in states] - - # initialize the gym-electric-motor environment - env = gem.make(motor, visualization=MotorDashboard(additional_plots=external_ref_plots), render_mode="figure_academic") - env.metadata["filename_prefix"] = "integration-test" - env.metadata["filename_suffix"] = "" - env.metadata["save_figure_on_close"] = True - env.metadata["hold_figure_on_close"] = False - # env.metadata["hold_figure_on_close"] = False - """ - initialize the controller - - Args: - environment gym-electric-motor environment - external_ref_plots (optional) plots of the environment, to plot all reference values - stages (optional) structure of the controller - automated_gain (optional) if True (default), the controller will be tune automatically - a (optional) tuning parameter of the symmetrical optimum (default: 4) - - """ - controller = Controller.make(env, external_ref_plots=external_ref_plots) - - state, reference = env.reset(seed=1972) - # simulate the environment - for i in range(3001): - action = controller.control(state, reference) - (state, reference), reward, terminated, truncated, _ = env.step(action) - if i == 100: - pass - if terminated: - env.reset() - controller.reset() - - env.close() \ No newline at end of file diff --git a/examples/classic_controllers/classic_controllers_dc_motor_integration_test_2.py b/examples/classic_controllers/integration_test_classic_controllers_dc_motor.py similarity index 100% rename from examples/classic_controllers/classic_controllers_dc_motor_integration_test_2.py rename to examples/classic_controllers/integration_test_classic_controllers_dc_motor.py From 0e2e6f560247c10d9c67810aabb3d9720bcefad7 Mon Sep 17 00:00:00 2001 From: Stefan Arndt Date: Mon, 17 Jul 2023 10:13:48 +0200 Subject: [PATCH 37/37] Updated with gymnasium --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 36077ac8..428fdccb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ scipy>=1.4.1 gym<0.24.0,>=0.15.4 pytest>=5.2.2 pytest-cov +gymnasium>=0.29.0 \ No newline at end of file