ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
TwoInertiaStateDistObsrv.hh
[詳解]
1
9//
10// Copyright (C) 2011-2020 Yokokura, Yuki
11// This program is free software;
12// you can redistribute it and/or modify it under the terms of the FreeBSD License.
13// For details, see the License.txt file.
14
15#ifndef TWOINERTIASTATEDISTOBSRV
16#define TWOINERTIASTATEDISTOBSRV
17
18#include <cassert>
19#include <tuple>
20#include <Matrix.hh>
21#include <Discret.hh>
22#include "TwoInertiaParamDef.hh"
23#include "Observer.hh"
24
25// ARCS組込み用マクロ
26#ifdef ARCS_IN
27 // ARCSに組み込まれる場合
28 #include "ARCSassert.hh"
29 #include "ARCSeventlog.hh"
30#else
31 // ARCSに組み込まれない場合
32 #define arcs_assert(a) (assert(a))
33 #define PassedLog()
34 #define EventLog(a)
35 #define EventLogVar(a)
36#endif
37
38namespace ARCS { // ARCS名前空間
40template <size_t N = 1>
42 public:
47 TwoInertiaStateDistObsrv(const struct TwoInertiaParamDef& Params, const double Bandwidth, const double SmplTime)
48 : Kt(Params.Kt),
49 Jm(Params.Jm),
50 Dm(Params.Dm),
51 Jl(Params.Jl),
52 Dl(Params.Dl),
53 Ks(Params.Ks),
54 Rg(Params.Rg),
55 g(Bandwidth),
56 Ts(SmplTime),
57 A(),
58 b(),
59 c(),
60 k(),
61 StateDistObsrv()
62 {
63 CalcPlantStateModel(); // プラント状態空間モデルの計算
64 CalcObserverGain(); // オブザーバゲインの計算
65 StateDistObsrv.SetPlantModelAndGain(A, b, c, k, Ts); // オブザーバの状態空間モデルの計算
66 PassedLog();
67 }
68
72 : Kt(r.Kt),
73 Jm(r.Jm),
74 Dm(r.Dm),
75 Jl(r.Jl),
76 Dl(r.Dl),
77 Ks(r.Ks),
78 Rg(r.Rg),
79 g(r.g),
80 Ts(r.Ts),
81 A(r.A),
82 b(r.b),
83 c(r.c),
84 k(r.k),
85 StateDistObsrv(std::move(r.StateDistObsrv))
86 {
87
88 }
89
94
99 void GetEstimatedVect(const double Current, const double Velocity, Matrix<1,4>& xhat){
100 const Matrix<1,2> u = {Current, Velocity};
101 StateDistObsrv.Estimate(u, xhat);
102 }
103
108 Matrix<1,4> GetEstimatedVect(const double Current, const double Velocity){
109 const Matrix<1,2> u = {Current, Velocity};
110 return StateDistObsrv.Estimate(u);
111 }
112
117 std::tuple<double,double,double,double> GetEstimatedVars(const double Current, const double Velocity){
118 const Matrix<1,2> u = {Current, Velocity};
119 Matrix<1,4> xhat = StateDistObsrv.Estimate(u);
120 return std::forward_as_tuple(xhat[1], xhat[2], xhat[3], xhat[4]);
121 }
122
128 void GetEstimatedVect(const double Current, const double Velocity, Matrix<1,3>& xhat, double& LoadDisturbance){
129 const Matrix<1,2> u = {Current, Velocity};
130 Matrix<1,4> xhat_dis;
131 StateDistObsrv.Estimate(u, xhat_dis);
132 xhat[1] = xhat_dis[1];
133 xhat[2] = xhat_dis[2];
134 xhat[3] = xhat_dis[3];
135 LoadDisturbance = xhat_dis[4];
136 }
137
138 private:
140 const TwoInertiaStateDistObsrv& operator=(const TwoInertiaStateDistObsrv&) = delete;
141 double Kt;
142 double Jm;
143 double Dm;
144 double Jl;
145 double Dl;
146 double Ks;
147 double Rg;
148 double g;
149 double Ts;
150 Matrix<4,4> A;
151 Matrix<1,4> b;
152 Matrix<4,1> c;
153 Matrix<1,4> k;
154 Observer<4> StateDistObsrv;
155
157 void CalcPlantStateModel(void){
158 // プラントの状態方程式 (x = [ωl θs ωm τl]^T, u = iqref, y = ωm)
159 A.Set(
160 -Dl/Jl, Ks/Jl , 0 , -1.0/Jl,
161 -1 , 0 , 1.0/Rg , 0 ,
162 0 , -Ks/(Jm*Rg) , -Dm/Jm , 0 ,
163 0 , 0 , 0 , 0
164 );
165 b.Set(
166 0,
167 0,
168 Kt/Jm,
169 0
170 );
171 c.Set(0, 0, 1, 0);
172 }
173
175 void CalcObserverGain(void){
176 // 推定帯域gで重根配置されるオブザーバゲインを計算
177 const double k1 = -(Jm*Rg*(Dl - 2.0*Jl*g)*(Dl*Dl - 2.0*Dl*Jl*g + 2.0*Jl*Jl*g*g - 2.0*Ks*Jl))/(Jl*Jl*Jl*Ks);
178 const double k2 = (- Jm*Dl*Dl*Rg*Rg + 4.0*Jm*Dl*Jl*Rg*Rg*g - 6.0*Jm*Jl*Jl*Rg*Rg*g*g + Ks*Jl*Jl + Jm*Ks*Jl*Rg*Rg)/(Jl*Jl*Ks*Rg);
179 const double k3 = -(Dl*Jm + Dm*Jl - 4.0*Jl*Jm*g)/(Jl*Jm);
180 const double k4 = -(Jl*Jm*Rg*g*g*g*g)/Ks;
181
182 // オブザーバゲインベクトルにセット
183 k.Set(
184 k1,
185 k2,
186 k3,
187 k4
188 );
189 }
190};
191}
192
193#endif
194
ARCS イベントログクラス
#define PassedLog()
イベントログ用マクロ(ファイルと行番号のみ記録版)
Definition ARCSeventlog.hh:26
ARCS用ASSERTクラス
2慣性共振系のパラメータ定義ファイル
一般形のオブザーバクラス(とりあえずSISO版)
行列/ベクトル計算クラス(テンプレート版)
離散化クラス(テンプレート版) !!!注意喚起:このクラスは将来的に廃止予定です。代わりに、ArcsControlDiscretizeを使用して下さい。
行列/ベクトル計算クラス(テンプレート版)
Definition Matrix.hh:44
constexpr void Set(const T1 &u1, const T2 &... u2)
行列要素に値を設定する関数
Definition Matrix.hh:385
一般形のオブザーバクラス
Definition Observer.hh:39
void Estimate(const Matrix< 1, 2 > &u, Matrix< 1, N > &xhat)
状態推定の計算をして状態ベクトルを返す関数(普通版)
Definition Observer.hh:88
void SetPlantModelAndGain(const Matrix< N, N > &A, const Matrix< 1, N > &b, const Matrix< N, 1 > &c, const Matrix< 1, N > &k, const double Ts)
対象のプラントモデルとゲインを設定する関数
Definition Observer.hh:76
2慣性共振系のパラメータ構造体(Ds無し版)
Definition TwoInertiaParamDef.hh:18
2慣性系状態外乱オブザーバクラス
Definition TwoInertiaStateDistObsrv.hh:41
std::tuple< double, double, double, double > GetEstimatedVars(const double Current, const double Velocity)
各々の推定状態変数を取得する関数(タプル版)
Definition TwoInertiaStateDistObsrv.hh:117
Matrix< 1, 4 > GetEstimatedVect(const double Current, const double Velocity)
推定状態ベクトルを取得する関数(ベクトルで返す版)
Definition TwoInertiaStateDistObsrv.hh:108
void GetEstimatedVect(const double Current, const double Velocity, Matrix< 1, 4 > &xhat)
推定状態ベクトルを取得する関数(普通版)
Definition TwoInertiaStateDistObsrv.hh:99
void GetEstimatedVect(const double Current, const double Velocity, Matrix< 1, 3 > &xhat, double &LoadDisturbance)
推定状態ベクトルと負荷側外乱を分けて取得する関数(普通版)
Definition TwoInertiaStateDistObsrv.hh:128
TwoInertiaStateDistObsrv(const struct TwoInertiaParamDef &Params, const double Bandwidth, const double SmplTime)
コンストラクタ
Definition TwoInertiaStateDistObsrv.hh:47
~TwoInertiaStateDistObsrv()
デストラクタ
Definition TwoInertiaStateDistObsrv.hh:91
TwoInertiaStateDistObsrv(TwoInertiaStateDistObsrv &&r)
ムーブコンストラクタ
Definition TwoInertiaStateDistObsrv.hh:71