- PID: introduced INIT State

- refactored
This commit is contained in:
jens
2021-10-12 16:47:05 +02:00
parent 55315e268e
commit bf7ec2beaf
3 changed files with 22 additions and 23 deletions
+6 -11
View File
@@ -1,16 +1,9 @@
from components.plant.pot import Pot
from matplotlib.pyplot import plot, figure, subplot, grid, show, legend
from components.pid import Pid, Kalman
from components import APid
import numpy as np
from enum import Enum
from components.pid import Pid, Kalman
from components.pid.tc_constants import *
class States(Enum):
IDLE = 0,
HEAT = 1,
HOLD = 2
import numpy as np
class TempController(APid):
@@ -28,7 +21,7 @@ class TempController(APid):
self.params = params
self.kalman = Kalman(dt, params['Kalman'])
self.y = -1
self.state = States.IDLE
self.state = States.INIT
self.use_kalman = True
self.pid_hold.set_params(params['Hold'])
self.pid_rate.set_params(params['Heat'])
@@ -93,7 +86,9 @@ class TempController(APid):
def process_fsm(self, diff):
# Process state
state_next = self.state
if self.state == States.IDLE:
if self.state == States.INIT:
state_next = States.IDLE
elif self.state == States.IDLE:
if diff >= THRESH_IDLE_HEAT:
state_next = States.HEAT
self.pid_rate.reset()