16
14

More than 3 years have passed since last update.

ARMのUbuntu Server 18.04でBluetoothを使う(for Raspberry Pi)

Last updated at Posted at 2019-06-20

モチベーション

ROSロボット愛好家には欠かせない、ARM版 Ubuntu Server 18.04。
一工夫しないとBluetoothが使えなかったので他の人が困らないように記録しておく。
(今回の実験対象はARM64版です。確認していませんが、ARMHF(32bit)でも同じ問題が起きているはずです。)

Raspberry Pi用のUbuntu 18.04

ARM/RaspberryPi - Ubuntu Wiki
SDカードイメージは、上記Ubuntu公式サイトよりダウンロード可能です。
なお、Ubuntu MateであればBluetoothの問題は発生しません。
ただ、Mateは重たいので、
ロボットに乗せるだけならば、「Ubuntu Server」の方がいいよね!ということです。

また、GUIが欲しくなったら、「xubuntu」「lubuntu」「kubuntu」が使えます。
最高ですね。

オプショナルパッケージのインストール

$ sudo add-apt-repository ppa:ubuntu-raspi2/ppa
$ sudo apt update
$ sudo apt install libraspberrypi-bin libraspberrypi-dev

Ubuntu PiフレーバーメーカーPPAの追加

  • 有志が、Raspberry Pi用のUbuntuイメージに対して、公式イメージであるRaspbianにある各種パッケージをUbuntu用に提供してくださっています。
  • Raspberry PiのBluetoothを動かす上で必要なpi-bluetoothを追加するために必要です。
$ sudo add-apt-repository ppa:ubuntu-pi-flavour-makers/ppa
$ sudo apt update
$ sudo groupadd -f --system gpio
$ sudo groupadd -f --system i2c
$ sudo groupadd -f --system input
$ sudo groupadd -f --system spi

必要なパッケージのインストール

  • pi-bluetoothに加えて、bluetoothパッケージと、CLIからbluetoothctlコマンドの実行を可能にするためにbluezパッケージをインストール。
  • 私の場合はこの時点では、Bluetoothデバイスが認識してくれなかったので再起動が必要でした。
$ sudo apt install pi-bluetooth bluetooth bluez 
$ sudo reboot

動作確認

$ sudo bluetoothctl 
[NEW] Controller xx:xx:xx:xx:xx:xx test01 [default]
[bluetooth]# list
Controller xx:xx:xx:xx:xx:xx test01 [default]

最後に

ROSやるならRaspbianよりUbuntuですね。
(最近はDockerばかり使ってますですが。)

16
14
1

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
16
14