ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
TwoInertiaStateObsrv.hh
[詳解]
1
8//
9// Copyright (C) 2011-2020 Yokokura, Yuki
10// This program is free software;
11// you can redistribute it and/or modify it under the terms of the FreeBSD License.
12// For details, see the License.txt file.
13
14#ifndef TWOINERTIASTATEOBSRV
15#define TWOINERTIASTATEOBSRV
16
17#include <cassert>
18#include <tuple>
19#include <Matrix.hh>
20#include <Discret.hh>
21#include "TwoInertiaParamDef.hh"
22#include "Observer.hh"
23
24// ARCS組込み用マクロ
25#ifdef ARCS_IN
26 // ARCSに組み込まれる場合
27 #include "ARCSassert.hh"
28 #include "ARCSeventlog.hh"
29#else
30 // ARCSに組み込まれない場合
31 #define arcs_assert(a) (assert(a))
32 #define PassedLog()
33 #define EventLog(a)
34 #define EventLogVar(a)
35#endif
36
37namespace ARCS { // ARCS名前空間
39template <size_t N = 1>
41 public:
46 TwoInertiaStateObsrv(const struct TwoInertiaParamDef& Params, const double Bandwidth, const double SmplTime)
47 : Kt(Params.Kt),
48 Jm(Params.Jm),
49 Dm(Params.Dm),
50 Jl(Params.Jl),
51 Dl(Params.Dl),
52 Ks(Params.Ks),
53 Rg(Params.Rg),
54 g(Bandwidth),
55 Ts(SmplTime),
56 A(),
57 b(),
58 c(),
59 k(),
60 StateObsrv()
61 {
62 CalcPlantStateModel(); // プラント状態空間モデルの計算
63 CalcObserverGain(); // オブザーバゲインの計算
64 StateObsrv.SetPlantModelAndGain(A, b, c, k, Ts); // オブザーバの状態空間モデルの計算
65 PassedLog();
66 }
67
71 : Kt(r.Kt),
72 Jm(r.Jm),
73 Dm(r.Dm),
74 Jl(r.Jl),
75 Dl(r.Dl),
76 Ks(r.Ks),
77 Rg(r.Rg),
78 g(r.g),
79 Ts(r.Ts),
80 A(r.A),
81 b(r.b),
82 c(r.c),
83 k(r.k),
84 StateObsrv(std::move(r.StateObsrv))
85 {
86
87 }
88
93
98 void GetEstimatedVect(const double Current, const double Velocity, Matrix<1,3>& xhat){
99 const Matrix<1,2> u = {Current, Velocity};
100 return StateObsrv.Estimate(u, xhat);
101 }
102
107 Matrix<1,3> GetEstimatedVect(const double Current, const double Velocity){
108 const Matrix<1,2> u = {Current, Velocity};
109 return StateObsrv.Estimate(u);
110 }
111
116 std::tuple<double,double,double> GetEstimatedVars(const double Current, const double Velocity){
117 const Matrix<1,2> u = {Current, Velocity};
118 Matrix<1,3> xhat = StateObsrv.Estimate(u);
119 return std::forward_as_tuple(xhat[1], xhat[2], xhat[3]);
120 }
121
122 private:
124 const TwoInertiaStateObsrv& operator=(const TwoInertiaStateObsrv&) = delete;
125 double Kt;
126 double Jm;
127 double Dm;
128 double Jl;
129 double Dl;
130 double Ks;
131 double Rg;
132 double g;
133 double Ts;
134 Matrix<3,3> A;
135 Matrix<1,3> b;
136 Matrix<3,1> c;
137 Matrix<1,3> k;
138 Observer<3> StateObsrv;
139
141 void CalcPlantStateModel(void){
142 // プラントの状態方程式 (x = [ωl θs ωm]^T, u = iqref, y = ωm)
143 A.Set(
144 -Dl/Jl, Ks/Jl , 0 ,
145 -1 , 0 , 1.0/Rg ,
146 0 , -Ks/(Jm*Rg) , -Dm/Jm
147 );
148 b.Set(
149 0,
150 0,
151 Kt/Jm
152 );
153 c.Set(0, 0, 1);
154 }
155
157 void CalcObserverGain(void){
158 // 推定帯域gで重根配置されるオブザーバゲインを計算
159 const double k1 = -(Jm*Rg*(Dl*Dl*Dl - 3.0*Dl*Dl*Jl*g + 3.0*Dl*Jl*Jl*g*g - 2.0*Ks*Dl*Jl - Jl*Jl*Jl*g*g*g + 3.0*Ks*Jl*Jl*g))/(Jl*Jl*Jl*Ks); // オブザーバゲイン1
160 const double k2 = (- Jm*Dl*Dl*Rg*Rg + 3.0*Jm*Dl*Jl*Rg*Rg*g - 3.0*Jm*Jl*Jl*Rg*Rg*g*g + Ks*Jl*Jl + Jm*Ks*Jl*Rg*Rg)/(Jl*Jl*Ks*Rg); // オブザーバゲイン2
161 const double k3 = -(Dl*Jm + Dm*Jl - 3.0*Jl*Jm*g)/(Jl*Jm); // オブザーバゲイン3
162
163 // オブザーバゲインベクトルにセット
164 k.Set(
165 k1,
166 k2,
167 k3
168 );
169 }
170};
171}
172
173#endif
174
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 TwoInertiaStateObsrv.hh:40
std::tuple< double, double, double > GetEstimatedVars(const double Current, const double Velocity)
各々の推定状態変数を取得する関数(タプル版)
Definition TwoInertiaStateObsrv.hh:116
TwoInertiaStateObsrv(TwoInertiaStateObsrv &&r)
ムーブコンストラクタ
Definition TwoInertiaStateObsrv.hh:70
TwoInertiaStateObsrv(const struct TwoInertiaParamDef &Params, const double Bandwidth, const double SmplTime)
コンストラクタ
Definition TwoInertiaStateObsrv.hh:46
~TwoInertiaStateObsrv()
デストラクタ
Definition TwoInertiaStateObsrv.hh:90
Matrix< 1, 3 > GetEstimatedVect(const double Current, const double Velocity)
推定状態ベクトルを取得する関数(ベクトルで返す版)
Definition TwoInertiaStateObsrv.hh:107
void GetEstimatedVect(const double Current, const double Velocity, Matrix< 1, 3 > &xhat)
推定状態ベクトルを取得する関数(普通版)
Definition TwoInertiaStateObsrv.hh:98