forked from guilda-dev/guilda_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgovernor.py
More file actions
42 lines (34 loc) · 1.05 KB
/
governor.py
File metadata and controls
42 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from control import StateSpace as SS
import numpy as np
class Governor():
def __init__(self):
self.P = None
# ここではgovernorのダイナミクスを考慮しない
A = np.array([])
B = np.array([]).reshape(-1, 1)
C = np.array([]).reshape(1, -1)
D = np.identity(2)
sys = SS(A, B, C, D)
SS.set_inputs(sys, ['omega_governor', 'u_governor'])
SS.set_outputs(sys, ['omega_governor', 'Pmech'])
self.sys = sys
def initialize(self, P):
self.P = P
# governorに状態はない
x = np.array([]).reshape(-1, 1)
return x
def get_nx(self):
return 0
def get_P(self, u, x_gov=None, omega=None):
P = self.P + u
dx = np.array([])
return [dx, P]
def get_sys(self):
sys = self.sys
return sys
def get_state_name(self):
nx = self.get_nx()
name_tag = []
if nx != 0:
name_tag = ['state_governor' + str(i+1) for i in range(nx)]
return name_tag