ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
P-Dcontrollers.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 P_DCONTROLLERS
15#define P_DCONTROLLERS
16
17#include <cassert>
18#include <array>
19#include "Matrix.hh"
20#include "P-Dcontroller.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名前空間
39template <size_t N, size_t W = 4>
41 public:
44 : P_Dcon()
45 {
46 PassedLog();
47 }
48
52 P_Dcontrollers(const std::array<double, N>& Pgain, const std::array<double, N>& Dgain)
53 : P_Dcon()
54 {
55 SetPgain(Pgain);
56 SetDgain(Dgain);
57 PassedLog();
58 }
59
63 P_Dcontrollers(const Matrix<1,N>& Pgain, const Matrix<1,N>& Dgain)
64 : P_Dcon()
65 {
66 SetPgain(Pgain);
67 SetDgain(Dgain);
68 PassedLog();
69 }
70
74 : P_Dcon(r.P_Dcon)
75 {
76
77 }
78
83
90 void GetSignal(const Matrix<1,N>& ref, const Matrix<1,N>& res, const double time, Matrix<1,N>& out){
91 for(size_t i = 1; i <= N; ++i){
92 out[i] = P_Dcon.at(i-1).GetSignal(ref[i], res[i], time);
93 }
94 }
95
102 Matrix<1,N> GetSignal(const Matrix<1,N>& ref, const Matrix<1,N>& res, const double time){
103 Matrix<1,N> ret;
104 GetSignal(ref, res, time, ret);
105 return ret;
106 }
107
110 void SetPgain(const std::array<double, N>& Pgain){
111 for(size_t i = 0; i < N; ++i) P_Dcon.at(i).SetPgain(Pgain.at(i)); // 各々のPゲインに設定
112 }
113
116 void SetDgain(const std::array<double, N>& Dgain){
117 for(size_t i = 0; i < N; ++i) P_Dcon.at(i).SetDgain(Dgain.at(i)); // 各々のDゲインに設定
118 }
119
122 void SetPgain(const Matrix<1,N>& Pgain){
123 for(size_t i = 1; i <= N; ++i) P_Dcon.at(i - 1).SetPgain(Pgain[i]); // 各々のPゲインに設定
124 }
125
128 void SetDgain(const Matrix<1,N>& Dgain){
129 for(size_t i = 1; i <= N; ++i) P_Dcon.at(i - 1).SetDgain(Dgain[i]); // 各々のDゲインに設定
130 }
131
135 void SetPDgain(const std::array<double, N>& Pgain, const std::array<double, N>& Dgain){
136 for(size_t i = 0; i < N; ++i) P_Dcon.at(i).SetPDgain(Pgain.at(i), Dgain.at(i)); // 各々のPDゲインに設定
137 }
138
142 void SetPDgain(const Matrix<1,N>& Pgain, const Matrix<1,N>& Dgain){
143 for(size_t i = 1; i <= N; ++i) P_Dcon.at(i - 1).SetPDgain(Pgain[i], Dgain[i]); // 各々のPDゲインに設定
144 }
145
146 private:
147 P_Dcontrollers(const P_Dcontrollers&) = delete;
148 const P_Dcontrollers& operator=(const P_Dcontrollers&) = delete;
149 std::array<P_Dcontroller<W>, N> P_Dcon;
150};
151}
152
153#endif
154
ARCS イベントログクラス
#define PassedLog()
イベントログ用マクロ(ファイルと行番号のみ記録版)
Definition ARCSeventlog.hh:26
ARCS用ASSERTクラス
行列/ベクトル計算クラス(テンプレート版)
行列/ベクトル計算クラス(テンプレート版)
Definition Matrix.hh:44
P-D制御器クラス(微分先行型)
Definition P-Dcontrollers.hh:40
void SetPDgain(const Matrix< 1, N > &Pgain, const Matrix< 1, N > &Dgain)
PDゲインを設定する関数(Matrix版)
Definition P-Dcontrollers.hh:142
P_Dcontrollers(const std::array< double, N > &Pgain, const std::array< double, N > &Dgain)
コンストラクタ(std::array版)
Definition P-Dcontrollers.hh:52
~P_Dcontrollers()
デストラクタ
Definition P-Dcontrollers.hh:80
P_Dcontrollers(void)
空コンストラクタ
Definition P-Dcontrollers.hh:43
void GetSignal(const Matrix< 1, N > &ref, const Matrix< 1, N > &res, const double time, Matrix< 1, N > &out)
P-D制御器の出力信号を取得する関数(引数で返す版) out = (ref - res)*Kp - d(res)/d(time)*Kd
Definition P-Dcontrollers.hh:90
P_Dcontrollers(const Matrix< 1, N > &Pgain, const Matrix< 1, N > &Dgain)
コンストラクタ(Matrix版)
Definition P-Dcontrollers.hh:63
Matrix< 1, N > GetSignal(const Matrix< 1, N > &ref, const Matrix< 1, N > &res, const double time)
P-D制御器の出力信号を取得する関数(返り値で返す版) out = (ref - res)*Kp - d(res)/d(time)*Kd
Definition P-Dcontrollers.hh:102
P_Dcontrollers(P_Dcontrollers &&r)
ムーブコンストラクタ
Definition P-Dcontrollers.hh:73
void SetPgain(const Matrix< 1, N > &Pgain)
Pゲインを設定する関数(Matrix版)
Definition P-Dcontrollers.hh:122
void SetPgain(const std::array< double, N > &Pgain)
Pゲインを設定する関数(std::array版)
Definition P-Dcontrollers.hh:110
void SetPDgain(const std::array< double, N > &Pgain, const std::array< double, N > &Dgain)
PDゲインを設定する関数(std::array版)
Definition P-Dcontrollers.hh:135
void SetDgain(const Matrix< 1, N > &Dgain)
Dゲインを設定する関数(Matrix版)
Definition P-Dcontrollers.hh:128
void SetDgain(const std::array< double, N > &Dgain)
Dゲインを設定する関数(std::array版)
Definition P-Dcontrollers.hh:116