$30 off During Our Annual Pro Sale. View Details »

M5Stack with Unity

M5Stack with Unity

I Connect M5Stack-Gray and Unity(Windows10) by Bluetooth.

Yosuke Nakano

June 25, 2019
Tweet

More Decks by Yosuke Nakano

Other Decks in Technology

Transcript

  1. 無線ジャイロコントローラ
    を自前でUnityに実装
    中野洋輔 @naninuneno_y
    2019.6.25
    Roppongi.unity #3 in メルカリ@六本木ヒルズ

    View Slide

  2. 自己紹介
    • Moffのエンジニア
    • Unity2年くらい
    • Qiitaに記事書いてます
    https://twitter.com/naninuneno_y

    View Slide

  3. 弊社紹介

    View Slide

  4. M5Stack
    • ESP32を備えた開発モジュール
    • Bluetooth/Wi-fi
    • カラーLCDとボタン3つ搭載
    • 5.4cm x 5.4cm x 1.7cm
    • Grayモデルには 9軸センサ搭載
    • 加速度/角速度/地磁気
    • ¥4,860
    • 専用リスバンド拡張あり
    • ¥1,782
    • https://www.switch-science.com/catalog/3648/
    • https://www.switch-science.com/catalog/3730/

    View Slide

  5. やったこと
    1. .9軸センサ読み取りとBluetoothでデータを送る
    m5Stackのファームウェア作成
    2. 1.のBluetoothのデータをwindows10で受け取る
    クラスライブラリ(.dll)を作成
    3. 2.のクラスライブラリを含んだUnityプラグインを
    作成

    View Slide

  6. 成果
    • https://github.com/naninunenoy/GrayBlue

    View Slide

  7. さらに
    4. Unity Editorでも実行できるよう、Bluetoothで受け
    取ったデータをJsonに変換してWebScoketでやりと
    りできるProxy作成

    View Slide

  8. 成果
    • https://github.com/naninunenoy/GrayBlue_WinProxy

    View Slide

  9. IMU Button I/O
    Bluetooth 4.0 Bluetooth 4.0
    .dll
    GATT: Byte[]
    クラスライブラリ
    ファームウェア
    WSA(.Net)
    Editor
    UWPアプリ
    .exe
    Unity
    Unity Editor
    Proxy
    WebSocket
    センサの値
    センサの値
    センサの値

    View Slide

  10. UWP Application
    Unity Game(WSA)
    Unity Editor(mono)
    M5Stack Gray Windows 10 PC
    Peripheral Central
    Firmware
    MPU-9250
    UWP Class
    Library(.dll)
    Win RT API
    PlatformIO
    C/C++
    Visual Studio
    C#
    Unity
    C#
    naninunenoy/
    GrayBlue
    naninunenoy/
    GrayBlue_UWP
    naninunenoy/
    GrayBlue_Unity
    Visual Studio
    C#
    naninunenoy/
    GrayBlue_WinProxy
    WebSocket

    View Slide

  11. 作ってみた感想
    • Bluetoothのプログラムは受信+送信を両方書く必要があり、
    敷居が高い
    • かなり頑張った
    • Githubにあるので、参考にしてください
    • 全プラットフォーム対応させるにはそれぞれのための
    Bluetoothドライバプログラムを自作させる必要がある(辛い)
    • windows/macOS/iOS/Android/Web Bluetooth
    • 多接続ができない(用途が限られる)
    • Surface Book(2015)でBTマウスをつないだ状態だと動作しない
    • LANでつないでWebSocketとかRPCで処理った方がよくない?

    View Slide

  12. View Slide

  13. 以上です

    View Slide