From 1b48f328dc318ad749f81222262b5e9eea3657aa Mon Sep 17 00:00:00 2001 From: detlefarend Date: Tue, 3 Dec 2024 14:43:54 +0100 Subject: [PATCH] BF: Basics of closed-loop control #1046 --- src/mlpro/bf/control/controllers/hunter.py | 5 +++-- src/mlpro/bf/control/operators/comparator.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mlpro/bf/control/controllers/hunter.py b/src/mlpro/bf/control/controllers/hunter.py index 826f843c0..3eb185343 100644 --- a/src/mlpro/bf/control/controllers/hunter.py +++ b/src/mlpro/bf/control/controllers/hunter.py @@ -6,10 +6,11 @@ ## -- History : ## -- yyyy-mm-dd Ver. Auth. Description ## -- 2024-10-10 0.1.0 DA Initial implementation +## -- 2024-12-03 0.1.1 DA Bugfix ## ------------------------------------------------------------------------------------------------- """ -Ver. 0.1.0 (2024-10-10) +Ver. 0.1.1 (2024-12-03) This module provides a simple demo system that just cumulates a percentage part of the incoming action to the inner state. @@ -33,4 +34,4 @@ class Hunter (Controller): ## ------------------------------------------------------------------------------------------------- def _compute_output(self, p_ctrl_error : ControlError, p_ctrl_var : ControlVariable ): - p_ctrl_var.values = np.array(p_ctrl_error.values) * (-1) + p_ctrl_var.values = np.array(p_ctrl_error.values) diff --git a/src/mlpro/bf/control/operators/comparator.py b/src/mlpro/bf/control/operators/comparator.py index b14388819..870059477 100644 --- a/src/mlpro/bf/control/operators/comparator.py +++ b/src/mlpro/bf/control/operators/comparator.py @@ -12,10 +12,11 @@ ## -- 2024-11-10 0.5.0 DA Refactoring ## -- 2024-11-26 0.6.0 DA Method Comparator._run(): creation of ControlError only if ## -- both SetPoint and ControlledVariable are detected +## -- 2024-12-03 0.6.1 DA Bugfix in method Comparator.get_control_error() ## ------------------------------------------------------------------------------------------------- """ -Ver. 0.6.0 (2024-11-26) +Ver. 0.6.1 (2024-12-03) This module provides an implementation of a comparator that determins the control error based on setpoint and controlled variable (system state). @@ -84,5 +85,5 @@ def get_control_error(self, p_setpoint: SetPoint, p_ctrlled_var: ControlledVaria return ControlError( p_id = self.get_so().get_next_inst_id(), p_value_space = p_ctrlled_var.value_space, - p_values = np.subtract( np.array(p_ctrlled_var.values), np.array(p_setpoint.values) ), + p_values = np.subtract( np.array(p_setpoint.values), np.array(p_ctrlled_var.values) ), p_tstamp = self.get_so().get_tstamp() )