gpioが動かない件
Raspberry Pi 3 model B+ Rev 1.3上でROS Kineticを動作させるために、下記の手順に従ってROS Kineticを動作させるところまでは上手くいった。
Raspberry Pi 3B+(Ubuntu Mate 16.04LTS)にROS kinetic をインストールしてturtlesimを動かす
$ uname -a
Linux ros-desktop 4.14.52-v7+ #1123 SMP Wed Jun 27 17:35:49 BST 2018 armv7l armv7l armv7l GNU/Linux
が、GPIOが上手く動かない。
$ gpio readall
Unable to determine hardware version. I see: Hardware : BCM2835
,
- expecting BCM2708 or BCM2709.
If this is a genuine Raspberry Pi then please report this
to projects@drogon.net. If this is not a Raspberry Pi then you
are on your own as wiringPi is designed to support the
Raspberry Pi ONLY.
ros@ros-desktop:~/ros_ws$ gpio -v
gpio version: 2.32
Copyright (c) 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Unable to determine hardware version. I see: Hardware : BCM2835
,
- expecting BCM2708 or BCM2709.
If this is a genuine Raspberry Pi then please report this
to projects@drogon.net. If this is not a Raspberry Pi then you
are on your own as wiringPi is designed to support the
Raspberry Pi ONLY.
gpio
コマンドはRaspberry PiのGPIOライブラリであるWiringPiを用いているが、どうもUbuntu Mate 16.04LTSのarmhf用aptにはBCM2835に対応した最新版が入っていないようだ。
$ sudo apt search wiringpi
Sorting... Done
Full Text Search... Done
wiringpi/now 2.32 armhf [installed,local]
The wiringPi libraries, headers and gpio command
WiringPiのマニュアルインストール
そこでマニュアルでWiringPiをインストールする。
※この記事を書いた時点では、公式のgitリポジトリ https://git.drogon.net/ がダウンしていたため、githubのミラーを用いた(ただし最新版ではなくv2.46)。
aptでインストールされたWiringPiを削除
$ sudo apt-get purge wiringpi
$ hash -r
githubからソースコードをダウンロード
$ git clone https://github.com/WiringPi/WiringPi.git
$ cd WiringPi/
インストール
$ cd WiringPi/
$ ./build
gpioのバージョン確認
$ gpio -v
gpio version: 2.46
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Raspberry Pi Details:
Type: Pi 3+, Revision: 03, Memory: 1024MB, Maker: Sony
* Device tree is enabled.
*--> Raspberry Pi 3 Model B Plus Rev 1.3
* This Raspberry Pi supports user-level GPIO access.
問題なく動作することを確認
GPIOの5番ピンにボタンを付けて、入力が取れることを確認した。
ボタンを押してない状態
$ gpio -g read 5
0
ボタンを押した状態
$ gpio -g read 5
1