RaspberryPi pico wでmicro-ROSを動かす(Bluetooth編 その2)
前回までのあらすじ
RaspberryPi pico w側ソフトの通信部をカスタムとしてBluetoothシリアルで実装した
今回のテーマ
PC側で動作するエージェントの準備を行う
エージェントはWSL上で動作するが、ホストOS(Windows側)で既に構築されたシリアルプロファイルだけをWSLにアクセスさせる方法はないため、WSL用にBluetoothアダプタをもう一つ用意する
さらにデフォルトではBluetoothアダプタが有効になっていないため、カーネルの再構築が必要になる
USBIPD-WINプロジェクトをインストール
Windowsパッケージマネージャ(winget)を使ってインストールできる
winget install --interactive --exact dorssel.usbipd-win
USBIPツールとハードウェアデータベースをインストールする
sudo apt install linux-tools-generic hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/*-generic/usbip 20
カーネルの再構築
以下のサイトを参考にした
ビルドツールのインストール
sudo apt install build-essential flex bison libssl-dev libelf-dev
sudo apt install libncurses-dev bc dwarves
現在のカーネルのバージョンを調べる
![](https://assets.st-note.com/img/1709036074602-obZc27IvDm.png)
カーネルソースを入手する
![](https://assets.st-note.com/img/1709036273358-6vhKEByZVQ.png?width=800)
![](https://assets.st-note.com/img/1709036338556-cA11XQZfsL.png?width=800)
![](https://assets.st-note.com/img/1709036392536-SqGFTZXgqn.png?width=800)
![](https://assets.st-note.com/img/1709036544788-ucmG1xQPR1.png)
![](https://assets.st-note.com/img/1707910597129-QYrUxqdKGG.png?width=800)
![](https://assets.st-note.com/img/1708232950099-zc8cx0yXNd.png?width=800)
![](https://assets.st-note.com/img/1707908205070-sXmGe7tG3r.png?width=800)
![](https://assets.st-note.com/img/1707908257114-M9EvCrKuNa.png?width=800)
![](https://assets.st-note.com/img/1706617672124-7ZhdjqOdB1.png?width=800)
もちろん<Yes>を選択
いよいよビルド・・・
sudo make -j$(nproc)
sudo make modules_install
sudo make install -j 16
![](https://assets.st-note.com/img/1709037145204-NBkyIFUuHM.png)
![](https://assets.st-note.com/img/1709037178730-AghL8SOFna.png?width=800)
私はCドライブのルートにしました
![](https://assets.st-note.com/img/1709037197986-TfZTaaBT2X.png)
.wslconfigの編集
![](https://assets.st-note.com/img/1706621499444-wZQGVUw3hp.png)
![](https://assets.st-note.com/img/1706621602769-QERc3But1p.png)
![](https://assets.st-note.com/img/1709037276642-qW0z1uZXzf.png)
ビルドされた日時なら成功
Bluezをインストール
sudo apt install bluez*
WSL用にBluetoothアダプタを引き渡す準備
![](https://assets.st-note.com/img/1706706050425-p9iU8nTI76.png?width=800)
5-3はキーボードやマウスなど通常使用しているアダプタ
attachオプションを使ってwsl側へアタッチしておく
![](https://assets.st-note.com/img/1709120978744-i2ghiA04Pi.png?width=800)
Bluetoothサービスの開始
![](https://assets.st-note.com/img/1709037424505-cJrMKErlJm.png?width=800)
赤いの、黄色いのは気にしない
![](https://assets.st-note.com/img/1706704545973-4ngEMGJPoU.png?width=800)
![](https://assets.st-note.com/img/1709037469954-IQtP0wDGqa.png?width=800)
![](https://assets.st-note.com/img/1709037548855-DDoUUqwJwJ.png?width=800)
trustまでやっておく
![](https://assets.st-note.com/img/1708947251675-iBMq4xpgn3.png)
rfcommを有効にする
sudo modprobe rfcomm
![](https://assets.st-note.com/img/1707135022497-DVY9rNfMb4.png)
![](https://assets.st-note.com/img/1707135053961-PdvWLHZCEM.png?width=800)
これがBluetoothシリアルのアクセス先
Dockerでmicro-rosエージェント(シリアルモード)を起動する
デバイスは/dev/rfcomm0になる
docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged --net=host microros/micro-ros-agent:rolling serial --dev /dev/rfcomm0 -v6
![](https://assets.st-note.com/img/1709121205403-op7jYlCsuV.png?width=800)
この記事が気に入ったらサポートをしてみませんか?