ROS2(Foxy)でYD-LiDARを動かす(Jetson AGX Xavier)


Jetson AGX Xavierを用いて、ROS2(Foxy)でYD-LiDARを動かした時のメモ

YDLidar-SDKのインストール

cd ~/
git clone https://github.com/YDLIDAR/YDLidar-SDK
cd YDLidar-SDK/build
cmake ..
make
sudo make install

YDLiDAR ROS2のインストール

cd ~/ros_ws/src
git clone https://github.com/YDLIDAR/ydlidar_ros2_driver

~/ros_ws/src/ydlidar_ros2_driver/params/ydlidar.yamlを修正

ydlidar_ros2_driver_node:
  ros__parameters:
    port: /dev/ttyUSB0
    frame_id: laser_frame
    ignore_array: ""
    baudrate: 128000
    lidar_type: 1
    device_type: 0
    sample_rate: 5
    abnormal_check_count: 4
    resolution_fixed: true
    reversion: true
    inverted: true
    auto_reconnect: true
    isSingleChannel: false
    intensity: false
    support_motor_dtr: true
    angle_max: 180.0
    angle_min: -180.0
    range_max: 64.0
    range_min: 0.01
    frequency: 10.0
    invalid_range_is_inf: false

~/ros_ws/src/ydlidar_ros2_driver/launch/ydlidar_launch_view.pyを修正
node_namespace='/',をコメントアウトする。

    driver_node = LifecycleNode(package='ydlidar_ros2_driver',
                               node_executable='ydlidar_ros2_driver_node',
                                node_name='ydlidar_ros2_driver_node',
                                output='screen',
                                emulate_tty=True,
                                parameters=[parameter_file],
                                #node_namespace='/',
                                )
cd ~/ros_ws/
colcon build --symlink-install --base-paths src/ydlidar_ros2_driver
source install/setup.bash

Rviz2に表示

chmod 777 /dev/ttyUSB0
ros2 launch ydlidar_ros2_driver ydlidar_launch_view.py