ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
TwoInertiaSimulators.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 TWOINERTIASIMULATORS
15#define TWOINERTIASIMULATORS
16
17#include <cassert>
18#include <array>
19#include "Matrix.hh"
20#include "TwoInertiaParamDef.hh"
22
23// ARCS組込み用マクロ
24#ifdef ARCS_IN
25 // ARCSに組み込まれる場合
26 #include "ARCSassert.hh"
27 #include "ARCSeventlog.hh"
28#else
29 // ARCSに組み込まれない場合
30 #define arcs_assert(a) (assert(a))
31 #define PassedLog()
32 #define EventLog(a)
33 #define EventLogVar(a)
34#endif
35
36namespace ARCS { // ARCS名前空間
39template <size_t N>
41 public:
45 TwoInertiaSimulators(const std::array<struct TwoInertiaParamDef, N>& Params, const double SmplTime)
46 : PlantSyss()
47 {
48 PassedLog();
49 // 各軸数分の2慣性系パラメータ設定
50 for(size_t i = 0; i < N; ++i){
51 PlantSyss.at(i).SetParameters(Params.at(i), SmplTime);
52 }
53 }
54
58 : PlantSyss(std::move(r.PlantSyss))
59 {
60
61 }
62
67
71 void SetCurrentAndLoadTorque(const std::array<double, N>& Current, const std::array<double, N>& LoadTorque){
72 // 各軸の電流と負荷トルクを設定
73 for(size_t i = 0; i < N; ++i){
74 PlantSyss.at(i).SetCurrentAndLoadTorque(Current.at(i), LoadTorque.at(i));
75 }
76 }
77
81 void SetCurrentAndLoadTorque(const Matrix<1,N>& Current, const Matrix<1,N>& LoadTorque){
82 std::array<double, N> iq, ts;
83 Current.StoreArray(iq);
84 LoadTorque.StoreArray(ts);
86 }
87
92 void GetResponses(std::array<double, N>& LoadSpeed, std::array<double, N>& TorsionAngle, std::array<double, N>& MotorSpeed){
93 // 各軸の応答を計算
94 for(size_t i = 0; i < N; ++i){
95 PlantSyss.at(i).GetResponses(LoadSpeed.at(i), TorsionAngle.at(i), MotorSpeed.at(i));
96 }
97 }
98
103 void GetResponses(Matrix<1,N>& LoadSpeed, Matrix<1,N>& TorsionAngle, Matrix<1,N>& MotorSpeed){
104 std::array<double, N> wl, ths, wm;
105 GetResponses(wl, ths, wm);
106 LoadSpeed.LoadArray(wl);
107 TorsionAngle.LoadArray(ths);
108 MotorSpeed.LoadArray(wm);
109 }
110
114 void GetMotorPosition(std::array<double, N>& MotorPosition){
115 // 各軸の位置を取得
116 for(size_t i = 0; i < N; ++i){
117 MotorPosition.at(i) = PlantSyss.at(i).GetMotorPosition();
118 }
119 }
120
124 void GetMotorPosition(Matrix<1,N>& MotorPosition){
125 std::array<double, N> thm;
126 GetMotorPosition(thm);
127 MotorPosition.LoadArray(thm);
128 }
129
133 void GetLoadPosition(std::array<double, N>& LoadPosition){
134 // 各軸の位置を取得
135 for(size_t i = 0; i < N; ++i){
136 LoadPosition.at(i) = PlantSyss.at(i).GetLoadPosition();
137 }
138 }
139
143 void GetLoadPosition(Matrix<1,N>& LoadPosition){
144 std::array<double, N> thl;
145 GetLoadPosition(thl);
146 LoadPosition.LoadArray(thl);
147 }
148
149 private:
151 const TwoInertiaSimulators& operator=(const TwoInertiaSimulators&) = delete;
152
153 std::array<TwoInertiaSimulator, N> PlantSyss;
154
155};
156}
157
158#endif
159
ARCS イベントログクラス
#define PassedLog()
イベントログ用マクロ(ファイルと行番号のみ記録版)
Definition ARCSeventlog.hh:26
ARCS用ASSERTクラス
2慣性共振系のパラメータ定義ファイル
行列/ベクトル計算クラス(テンプレート版)
2慣性共振系シミュレータV4
行列/ベクトル計算クラス(テンプレート版)
Definition Matrix.hh:44
constexpr void LoadArray(const std::array< TT, MM > &Array)
1次元std::array配列を縦ベクトルとして読み込む関数
Definition Matrix.hh:424
constexpr void StoreArray(std::array< TT, MM > &Array) const
縦ベクトルを1次元std::array配列に書き込む関数
Definition Matrix.hh:432
2慣性共振系シミュレータV2(ベクトル版)
Definition TwoInertiaSimulators.hh:40
TwoInertiaSimulators(const std::array< struct TwoInertiaParamDef, N > &Params, const double SmplTime)
コンストラクタ
Definition TwoInertiaSimulators.hh:45
void GetMotorPosition(std::array< double, N > &MotorPosition)
モータ側位置を取得する関数(std::array版) 注意: GetResponses()を事前に実行しないと位置は反映されない。
Definition TwoInertiaSimulators.hh:114
TwoInertiaSimulators(TwoInertiaSimulators &&r)
ムーブコンストラクタ
Definition TwoInertiaSimulators.hh:57
void GetLoadPosition(Matrix< 1, N > &LoadPosition)
負荷側位置を取得する関数(ベクトル版) 注意: GetResponses()を事前に実行しないと位置は反映されない。
Definition TwoInertiaSimulators.hh:143
void SetCurrentAndLoadTorque(const Matrix< 1, N > &Current, const Matrix< 1, N > &LoadTorque)
予めモータ電流と負荷トルクを設定する関数(ベクトル版)
Definition TwoInertiaSimulators.hh:81
void GetResponses(Matrix< 1, N > &LoadSpeed, Matrix< 1, N > &TorsionAngle, Matrix< 1, N > &MotorSpeed)
予め設定された電流と負荷から負荷側速度&ねじれ角&モータ側速度を計算する関数(ベクトル版)
Definition TwoInertiaSimulators.hh:103
~TwoInertiaSimulators()
デストラクタ
Definition TwoInertiaSimulators.hh:64
void GetLoadPosition(std::array< double, N > &LoadPosition)
負荷側位置を取得する関数(std::array版) 注意: GetResponses()を事前に実行しないと位置は反映されない。
Definition TwoInertiaSimulators.hh:133
void GetMotorPosition(Matrix< 1, N > &MotorPosition)
モータ側位置を取得する関数(ベクトル版) 注意: GetResponses()を事前に実行しないと位置は反映されない。
Definition TwoInertiaSimulators.hh:124
void GetResponses(std::array< double, N > &LoadSpeed, std::array< double, N > &TorsionAngle, std::array< double, N > &MotorSpeed)
予め設定された電流と負荷から負荷側速度&ねじれ角&モータ側速度を計算する関数(std::array版)
Definition TwoInertiaSimulators.hh:92
void SetCurrentAndLoadTorque(const std::array< double, N > &Current, const std::array< double, N > &LoadTorque)
予めモータ電流と負荷トルクを設定する関数(std::array版)
Definition TwoInertiaSimulators.hh:71