バックナンバーはこちら。
https://www.simulationroom999.com/blog/model-based-of-minimum-2-backnumber/
はじめに
OpenModelicaから無事FMUをexportできた。
念のためFMUを解凍し、modelDescription.xmlを確認。
追加したOutputブロックと同名のパラメータは存在しており、
valueReferenceが同値のパラメータも確認したところ、
同一信号線に繋がってるものであることも確認がとれ、期待されるモデルになっているようである。
今回は、FMILibraryで実際にexportしたFMUを読み込んでみる。
登場人物
博識フクロウのフクさん

イラストACにて公開の「kino_k」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=iKciwKA9&area=1
エンジニア歴8年の太郎くん

イラストACにて公開の「しのみ」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=uCKphAW2&area=1
FMILibraryで実際にexportしたFMUを読み込んでみる

じゃー、とりあえず、FMILibraryでexportしたFMUを読み込んでみよう。
使用するのは変数リストを列挙するヤツだな。

あ、確かここで使ったヤツだね。

そうそう。

じゃー、FMUとテンポラリディレクトリのPATHを指定して実行!
処理結果(抜粋)
Version returned from FMU: 2.0
Platform type returned: default
GUID: {a0fc21cc-cc37-466f-a812-cf044bde7fd3}
==============================
Variable name: target
Description: (null)
VR: 93
Variability: continuous : 4
Causality: output : 3
Initial: calculated : 2
base_type: Real : 0
==============================
Variable name: voltage
Description: (null)
VR: 94
Variability: continuous : 4
Causality: output : 3
Initial: calculated : 2
base_type: Real : 0
==============================
Variable name: current
Description: (null)
VR: 13
Variability: continuous : 4
Causality: output : 3
Initial: exact : 0
base_type: Real : 0
==============================
Variable name: speed
Description: (null)
VR: 91
Variability: continuous : 4
Causality: output : 3
Initial: calculated : 2
base_type: Real : 0
==============================
Variable name: pid.addD.u1
Description: Connector of Real input signal 1
VR: 93
Variability: continuous : 4
Causality: local : 4
Initial: calculated : 2
base_type: Real : 0
==============================
Variable name: pid.addSat.u1
Description: Connector of Real input signal 1
VR: 94
Variability: continuous : 4
Causality: local : 4
Initial: calculated : 2
base_type: Real : 0
==============================
Variable name: signalVoltage.n.i
Description: Current flowing into the pin
VR: 13
Variability: continuous : 4
Causality: local : 4
Initial: calculated : 2
base_type: Real : 0
==============================
Variable name: speedSensor.w
Description: Absolute angular velocity of flange as output signal
VR: 91
Variability: continuous : 4
Causality: local : 4
Initial: calculated : 2
base_type: Real : 0
==============================
処理結果について

おー!
これはバッチリ取れてる感じだねー。
valueReferenceも前回確認したものと一致してるし。

うむ。
ちょっとコードを弄るだけで動きそうだな。

え?
コード弄るの?

うん。
といっても必要な材料はすべてそろっていて、
シミュレーションループのところに上手く必要なvalueReferenceが渡るように修正するだけだろう。

(また、何か新技が必要なのかと思った・・・。)

まぁ次回までにそこらへんの調整はやっておこう。
まとめ

まとめだよ。
- OpenModelicaからexportしたFMUをFMILibraryで読み込んでみた。
- 無事読み込み成功。
- 変数リストによる列挙もできた。
- 必要なパラメータの情報は問題無く取得出来ている。
- シミュレーションをするために若干の改造が必要。
- シミュレーションループにvalueReferenceが渡るように修正。
バックナンバーはこちら。
コメント