Raspberry Piの専用カメラモジュールを使ってみたかったけど、どうやらカメラモジュールのドライバがarmhf(32bit)にしか対応していないらしい。
ROS2を32bit環境で動かそうとすると、32bit環境に対応していないソフトウェアが出てくるので色々とめんどくさいことになった。
仕方がないのでUSBカメラで我慢することにした。
また、Raspberry Pi3でビルドすると、「out of memory:kill process」というエラーが頻発したのでRaspberry Pi4(4GB RAM)を導入した。
環境
Hardware : Raspberry Pi 4
Middleware : ROS2 Dashing
OS : Releases · TheRemote/Ubuntu-Server-raspi4-unofficial · GitHub
(Unofficialは初めからGUIが使える)
USBカメラ: Logicool C310
ビルド
GitHub - klintan/ros2_usb_camera: ROS2 USB Camera node
ブランチのROS2を選択します。
$ cd ~/ros2_ws/src $ git clone -b ros2 https://github.com/ros-perception/vision_opencv $ cd ~/ros2_ws $ colcon build
...依存関係のエラーが出たので追加します。
$ cd ~/ros2_ws/src $ git clone -b ros2 https://github.com/ros-perception/image_transport_plugin
...あれ、まだエラーが出る。さらに追加
$ git clone -b ros2 https://github.com/ros-perception/vision_opencv $ git clone -b ros2 https://github.com/ros-perception/image_common
ビルド
$ cd ~/ros2_ws $ colcon build
注) colcon buildは自動でリンクしてビルドしてくれません。
~/ros2_ws/srcは大元の依存関係のソースだけを残し、一つずつビルドして、下記のようにリンクしてビルドを繰り返してください。
$ source ~/ros2_ws/install/local_setup.sh $ colcon build
実行
$ ros2 run usb_camera usb_camera __ns:=/<your namespace> __params:=config.yaml
...だとエラーが出ます。
正しいパッケージ名と実行ファイル名を入力してください。
パッケージ名はソースのpacage.xmlのnameの項目。
実行ファイル名はinstall/usb_camera_driver/lib/の実行ファイルを見ればわかります。
修正して再度実行
$ ros2 run usb_camera_driver usb_camera_driver_node __ns:=/hoge
(なぜか2回目に実行したときの方が軽い)
その他依存関係
$ sudo apt install libboost-all-dev