ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
Observer.hh
[詳解]
1
8//
9// Copyright (C) 2011-2022 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 OBSERVER
15#define OBSERVER
16
17#include <cassert>
18#include <complex>
19#include "Matrix.hh"
20#include "StateSpaceSystem.hh"
21
22// ARCS組込み用マクロ
23#ifdef ARCS_IN
24 // ARCSに組み込まれる場合
25 #include "ARCSassert.hh"
26 #include "ARCSeventlog.hh"
27#else
28 // ARCSに組み込まれない場合
29 #define arcs_assert(a) (assert(a))
30 #define PassedLog()
31 #define EventLog(a)
32 #define EventLogVar(a)
33#endif
34
35namespace ARCS { // ARCS名前空間
38template <size_t N>
39class Observer {
40 public:
43 : ObsrvSys()
44 {
45 PassedLog();
46 }
47
49 Observer(const Matrix<N,N>& A, const Matrix<1,N>& b, const Matrix<N,1>& c)
50 : ObsrvSys()
51 {
52 Matrix<1,N,std::complex<double>> lambda = eigen(A);
53 PrintMat(tp(lambda));
54 PassedLog();
55 }
56
60 : ObsrvSys(std::move(r.ObsrvSys))
61 {
62
63 }
64
67 PassedLog();
68 }
69
76 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){
77 const Matrix<N,N> Ao = A - k*c; // オブザーバの連続系A行列
78 Matrix<2,N> Bo; // オブザーバの連続系B行列
79 setcolumn(Bo, b, 1); // オブザーバの連続系B行列1列目
80 setcolumn(Bo, k, 2); // オブザーバの連続系B行列2列目
81 const auto Co = Matrix<N,N>::eye(); // オブザーバの出力行列
82 ObsrvSys.SetContinuous(Ao, Bo, Co, Ts); // オブザーバの状態空間モデルを設定
83 }
84
88 void Estimate(const Matrix<1,2>& u, Matrix<1,N>& xhat){
89 ObsrvSys.GetResponses(u, xhat); // 推定演算
90 }
91
96 return ObsrvSys.GetResponses(u); // 推定演算
97 }
98
99 private:
100 Observer(const Observer&) = delete;
101 const Observer& operator=(const Observer&) = delete;
102 StateSpaceSystem<N,2,N> ObsrvSys;
103};
104}
105
106#endif
107
ARCS イベントログクラス
#define PassedLog()
イベントログ用マクロ(ファイルと行番号のみ記録版)
Definition ARCSeventlog.hh:26
ARCS用ASSERTクラス
行列/ベクトル計算クラス(テンプレート版)
#define PrintMat(a)
行列要素表示マクロ(フォーマット指定なし版)
Definition Matrix.hh:36
状態空間表現によるシステムクラス
行列/ベクトル計算クラス(テンプレート版)
Definition Matrix.hh:44
static constexpr Matrix< NN, NN, TT > eye(void)
n行n列の単位行列を返す関数 (identのエイリアス)
Definition Matrix.hh:678
一般形のオブザーバクラス
Definition Observer.hh:39
~Observer()
デストラクタ
Definition Observer.hh:66
void Estimate(const Matrix< 1, 2 > &u, Matrix< 1, N > &xhat)
状態推定の計算をして状態ベクトルを返す関数(普通版)
Definition Observer.hh:88
Matrix< 1, N > Estimate(const Matrix< 1, 2 > &u)
状態推定の計算をして状態ベクトルを返す関数(ベクトルを返す版)
Definition Observer.hh:95
Observer(void)
空コンストラクタ
Definition Observer.hh:42
Observer(const Matrix< N, N > &A, const Matrix< 1, N > &b, const Matrix< N, 1 > &c)
コンストラクタ
Definition Observer.hh:49
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
Observer(Observer &&r)
ムーブコンストラクタ
Definition Observer.hh:59
状態空間表現によるシステムクラス
Definition StateSpaceSystem.hh:40
void SetContinuous(const Matrix< N, N > &A, const Matrix< I, N > &B, const Matrix< N, O > &C, const double Ts)
連続系のA行列,B行列,C行列を設定して離散化する関数
Definition StateSpaceSystem.hh:92
void GetResponses(const Matrix< 1, I > &uin, Matrix< 1, O > &yout)
状態空間モデルの応答を計算して取得する関数(引数で返す版)
Definition StateSpaceSystem.hh:221