PI Speed Controller
- class gem_controllers.pi_speed_controller.PISpeedController(_env: (<class 'gym_electric_motor.core.ElectricMotorEnvironment'>, None) = None, env_id: (<class 'str'>, None) = None, torque_controller: (<class 'gem_controllers.torque_controller.TorqueController'>, None) = None, base_speed_controller: str = 'PI')[source]
Bases:
GemController
This class forms the PI speed controller, for any motor.
Initilizes a PI speed control stage.
- Parameters:
_env (ElectricMotorEnvironment) – The GEM-Environment that the controller shall be created for.
env_id (str) – The corresponding environment-id to specify the concrete environment.
torque_controller (TorqueController) – The underlying torque control stage
base_speed_controller (str) – Selection which base controller should be used for the speed control stage.
- control(state, reference)[source]
Claculate the reference values for the input voltages.
- Parameters:
state (np.array) – actual state of the environment
reference (np.array) – speed references
- Returns:
voltage reference
- Return type:
np.ndarray
- control_environment(env, n_steps, max_episode_length=inf, render_env=False)
Function to control an environment with the GemController.
- Parameters:
env (ElectricMotorEnvironment) – The GEM-Environment that the controller should control.
n_steps (int) – Number of iteration steps.
max_episode_length (int) – Maximum length of an epsiode, after which the environment and controller should be reset.
render_env (bool) – Flag, if the states of the environment should be plotted.
- get_signal_value(signal_name)
Get the value of a signal calling by the signal name.
- Parameters:
signal_name (str) – Name of a signal of the state
- Returns:
float
- classmethod make(env: ~gym_electric_motor.core.ElectricMotorEnvironment, env_id: str, decoupling: bool = True, current_safety_margin: float = 0.2, base_current_controller: str = 'PI', base_speed_controller: str = 'PI', a: int = 4, should_plot: bool = False, plot_references: bool = True, block_diagram: bool = True, save_block_diagram_as: (<class 'str'>, <class 'tuple'>) = None)
A factory function that generates (and parameterizes) a matching GemController for a given gym-electric-motor environment env.
- Parameters:
env (ElectricMotorEnvironment) – The GEM-Environment that the controller shall be created for.
env_id (str) – The corresponding environment-id to specify the concrete environment.
decoupling (bool) – Flag, if a EMF-Feedforward correction stage should be used in the pi current controller.
current_safety_margin (float in [0..1]) – The ratio between the maximum current set point the reference controller generates and the absolute current limit.
base_speed_controller ('PI'/'PID'/'P'/'ThreePoint') – Selection of the basic control algorithm for the speed controller.
base_current_controller ('PI'/'PID'/'P'/'ThreePoint') – Selection of the basic control algorithm for the current controller.
a (float) – Tuning parameter of the symmetrical optimum.
plot_references (bool) – Flag, if the reference values of the underlying control circuits should be plotted
block_diagram (bool) – Selection whether the block diagram should be displayed
save_block_diagram_as (str, tuple) – Selection of whether the block diagram should be saved
- Returns:
An initialized (and tuned) instance of a controller that fits to the specified environment.
- Return type:
- speed_control(state, reference)[source]
Calculate the torque reference.
- Parameters:
state (np.array) – actual state of the environment
reference (np.array) – actual speed references
- Returns:
torque_reference(np.array)
- tune(env, env_id, tune_torque_controller=True, a=4, **kwargs)[source]
Tune the components of the current control stage.
- Parameters:
env (ElectricMotorEnvironment) – The GEM-Environment that the controller shall be created for.
env_id (str) – The corresponding environment-id to specify the concrete environment.
tune_torque_controller (bool) – Flag, if the underlying torque control stage should be tuned.
a (float) – Design parameter of the symmetric optimum for the base controllers
- property anti_windup_stage
Anti windup stage of the speed controller
- property clipping_stage
Clipping stage of the speed controller
- property maximum_reference
- property referenced_states
- property references
- property signal_names
Signal names of the controller
- property signals
Input signals of the controller
- property speed_control_stage: BaseController
Base controller of the speed controller stage
- property stages
Stages of the GEM Controller
- property torque_controller: TorqueController
Subordinated torque controller stage
- property torque_reference: ndarray
Reference values of the torque controller stage