6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

matlabで9軸IMUのWT901のデータを利用して3D表示する

Posted at

 アマゾンで購入できる9軸IMUのWT901ボードをPCにつないで、Quaternion出力を使って3D表示をします。

WT901

 アマゾンで入手しました。

  WITMOTION WT901 高精度 9 アクシス AHRS MPU9250 TTL 加速度 センサー、ジャイロ + 加速度計 + 磁力計(最大 200HZ)電子 コンパス 振動 傾斜計 モジュール Arduino とプロジェクト など 用

 PCとCOMポートで接続するためにUSB-シリアル変換ボードもアマゾンで入手しました。
  HiLetgo 2個セット CP2102 マイクロ USB転UART TTL モジュール 6ピン シリアル コンバーター STC FT232を置換でき 並行輸入品

接続

 上記のボードを接続します。
wt901.png

 TXとRXはクロスします。

クオータニオンの出力を有効にする

 デフォルトでは、ACCELERATION、MAGNETIC FILED(uT)、PRESSURE(Tempratur)、Angleの値が送られています。Windowsのソフト「Standard Software for Windows PC」をダウンロードし、設定を変更します。

  GitHub https://github.com/WITMOTION/WT901
  Googleドライブ https://drive.google.com/drive/folders/1dWvJU2Ug7MpcwTPWoARw2KJI8oYbuVEW

 Contentの設定で、全部のチェックを外し、Quaternionだけにチェックを入れます。
wat101.png

プログラム

clear
close all;
instrreset;
s = serialport('COM3', 9600);

Q=[0 0 0 0];
figure;
while (1)
    Head = read(s,2,'uint8');
    if (Head(1)~=uint8(0x55))
        continue;
    end 
    if (Head(2) == uint8(0x59))
        Q = (read(s,4,'int16')/32768);
        %fprintf("%.4f ",Q);
    
        poseplot(quaternion([Q(4) Q(1) Q(2) Q(3)]), MeshFileName="plane3.stl",scaleFactor=0.3);
        view([50 50 -10]);

        pause(0.1);  
    end
end

 実行中の様子です。3Dの画像は、Windows10の中に入っているのをWebでstl形式に変換したのを使っています。
2021-12-04 (6).png

 この表示には、Sensor Fusion and Tracking ToolboxもしくはNavigation Toolboxが必要です。ホーム・ライセンスではNavigation Toolboxが購入できます。

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?