3D LiDAR Mid-360をROS2で動かすために公式が「Livox LiDAR用 ROS および ROS2 用ドライバー livox_ros_driver2」を提供してくれている。けど、公式のlivox_ros_driver2は、colcon buildでビルドできない、ビルド時に中間生成物を全部消すという謎仕様。。。なので、Ericsiiさん(ユーザー)が修正したバージョンの livox_ros_driver2 を利用してみました。
あと、公式に似たような名前で livox_ros_driver、livox_ros2_driver があるけど、それぞれ他機種のROS1用、ROS2用です。。。ややこしい。
ざっくり確認した公式との差分
2024/3/5時点:
- colcon buildコマンドでビルド可能
- x86だけサポート
- ビルド済みLivox SDK2ライブラリを含んでいる
- CHANGELOG.mdを見る限りでは、Ver. 1.1.3 (公式の最新はVer. 1.2.4)
- Ver. 1.2.0で Livox pointcloud2型の中身がちょっと変わっているので注意
ビルド方法
ワークスペースが ~/ros2_ws の場合の例
$ cd ~/ros2_ws/src $ git clone https://github.com/Ericsii/livox_ros_driver2.git $ cd .. $ colcon build --symlink-install
jsonファイルの書き換え
configにLiDARの固定IPアドレスの記述があるので、自分のMid-360の固定IPアドレスに書き換える。
sed -i "s/192.168.1.12/192.168.1.145/g" ~/ros2_ws/src/livox_ros_driver2/config/MID360_config.json
用意されているローンチファイルの種類
Mid-360用として、次の2種類が用意されている
rviz_MID360_launch.py → 点群をPointCloud2形式で配信、およびrviz2で可視化
msg_MID360_launch.py → 点群をカスタム形式で配信
rviz_MID360_launch.py の起動
下記コマンドで、rviz2で点群が表示できる。
$ source ~/ros2_ws/install/local_setup.sh $ ros2 launch livox_ros_driver2 rviz_MID360_launch.py
なんとなくノードも確認
$ ros2 node list /livox_lidar_publisher 省略 $ ros2 node info /livox_lidar_publisher /livox_lidar_publisher 省略 Publishers: /livox/imu: sensor_msgs/msg/Imu /livox/lidar: sensor_msgs/msg/PointCloud2 省略
IMUの配信はデフォルトで200Hz。設定ファイルで変更可。
$ ros2 topic hz /livox/imu average rate: 200.178 min: 0.003s max: 0.007s std dev: 0.00090s window: 201
LiDARの配信はデフォルトで10Hz。設定ファイルで変更可。
$ ros2 topic hz /livox/lidar average rate: 9.989 min: 0.095s max: 0.105s std dev: 0.00263s window: 12
rviz_MID360_launch.py 正常起動時のログ
[INFO] [launch]: All log files can be found below /home/taro/.ros/log/2024-03-03-00-43-59-709487-g-tune-12182 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [livox_ros_driver2_node-1]: process started with pid [12183] [INFO] [rviz2-2]: process started with pid [12185] [livox_ros_driver2_node-1] [INFO] [1709394239.851878810] [livox_lidar_publisher]: Livox Ros Driver2 Version: 1.0.0 [livox_ros_driver2_node-1] [INFO] [1709394239.852404279] [livox_lidar_publisher]: Data Source is raw lidar. [livox_ros_driver2_node-1] [INFO] [1709394239.852433662] [livox_lidar_publisher]: Config file : /home/taro/ros2_ws/install/livox_ros_driver2/share/livox_ros_driver2/launch_ROS2/../config/MID360_config.json [livox_ros_driver2_node-1] LdsLidar *GetInstance [livox_ros_driver2_node-1] config lidar type: 8 [livox_ros_driver2_node-1] successfully parse base config, counts: 1 [livox_ros_driver2_node-1] [INFO] [1709394239.857257375] [livox_lidar_publisher]: Init lds lidar success! [rviz2-2] [INFO] [1709394240.127926227] [rviz2]: Stereo is NOT SUPPORTED [rviz2-2] [INFO] [1709394240.128009658] [rviz2]: OpenGl version: 4.5 (GLSL 4.5) [rviz2-2] [INFO] [1709394240.193630375] [rviz2]: Stereo is NOT SUPPORTED [livox_ros_driver2_node-1] GetFreeIndex key:livox_lidar_2432805056. [livox_ros_driver2_node-1] Init queue, real query size:16. [livox_ros_driver2_node-1] Lidar[0] storage queue size: 10 [livox_ros_driver2_node-1] set pcl data type, handle: 2432805056, data type: 1 [livox_ros_driver2_node-1] set scan pattern, handle: 2432805056, scan pattern: 0 [livox_ros_driver2_node-1] begin to change work mode to 'Normal', handle: 2432805056 [livox_ros_driver2_node-1] successfully set data type, handle: 2432805056, set_bit: 2 [livox_ros_driver2_node-1] successfully set pattern mode, handle: 2432805056, set_bit: 0 [livox_ros_driver2_node-1] successfully set lidar attitude, ip: 192.168.1.145 [livox_ros_driver2_node-1] successfully change work mode, handle: 2432805056 [livox_ros_driver2_node-1] successfully enable Livox Lidar imu, ip: 192.168.1.145 [livox_ros_driver2_node-1] [INFO] [1709394242.862880217] [livox_lidar_publisher]: livox/lidar publish use PointCloud2 format [livox_ros_driver2_node-1] [INFO] [1709394242.863567122] [livox_lidar_publisher]: livox/imu publish use imu format
rviz_MID360_launch.py 起動で問題が起きたときの対処法
点群が表示されず、ログ出力も途中で止まる
ログの内容:
省略 [livox_ros_driver2_node-1] [INFO] [1709471247.677610542] [livox_lidar_publisher]: Config file : /home/taro/ros2_ws/install/livox_ros_driver2/share/livox_ros_driver2/launch_ROS2/../config/MID360_config.json [livox_ros_driver2_node-1] LdsLidar *GetInstance [livox_ros_driver2_node-1] config lidar type: 8 [livox_ros_driver2_node-1] successfully parse base config, counts: 1 [livox_ros_driver2_node-1] bind failed [livox_ros_driver2_node-1] Failed to init livox lidar sdk. [livox_ros_driver2_node-1] [ERROR] [1709471247.678601699] [livox_lidar_publisher]: Init lds lidar fail! [rviz2-2] [INFO] [1709471247.819314364] [rviz2]: Stereo is NOT SUPPORTED [rviz2-2] [INFO] [1709471247.819365085] [rviz2]: OpenGl version: 4.5 (GLSL 4.5) [rviz2-2] [INFO] [1709471247.848675978] [rviz2]: Stereo is NOT SUPPORTED
よくある原因:
- MID360_config.json の Lidar 側のIPアドレス指定が間違っている。
- ~/ros2_ws/src/livox_ros_driver2/config/MID360_config.json の内容を変更したあとに、colcon buildを実行していない。
確認方法:
実行時に読み込む MID360_config.json (/home/taro/ros2_ws/install/livox_ros_driver2/share/livox_ros_driver2/launch_ROS2/../config/MID360_config.json) の内容が正しいかどうか確認する。
リンク
Livox-SDK2
Livox_ros_driver2(公式版)
Livox_ros_driver2(Ericsiiさんによる修正版)
PointCloud2 msgフォーマットの詳細