Jetson AGX Xavierを用いて、ROS2(Foxy)でYD-LiDARを動かした時のメモ
YDLidar-SDKのインストール
cd ~/
git clone https://github.com/YDLIDAR/YDLidar-SDK
cd YDLidar-SDK
mkdir build
cd 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/
から、使用する機種のyamlを~/ros_ws/src/ydlidar_ros2_driver/params/ydlidar.yaml
にコピー。接続しているUSBポートを修正。frame_id
のlaser_frame
をbase_scan
に修正。
ydlidar_ros2_driver_node:
ros__parameters:
port: /dev/ttyUSB0
frame_id: base_scan
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
cd ~/ros_ws/
colcon build --symlink-install --base-paths src/ydlidar_ros2_driver
source install/setup.bash
ROS2 Nav2連携(Turtlebot3側)
標準LiDARの記述をLaunchファイルでコメントアウト。
robot.launch.py
...
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[ThisLaunchFileDir(), '/turtlebot3_state_publisher.launch.py']),
launch_arguments={'use_sim_time': use_sim_time}.items(),
),
#IncludeLaunchDescription(
# PythonLaunchDescriptionSource([lidar_pkg_dir, '/hlds_laser.launch.py']),
# launch_arguments={'port': '/dev/ttyUSB0', 'frame_id': 'base_scan'}.items(),
#),
Node(
package='turtlebot3_node',
executable='turtlebot3_ros',
parameters=[tb3_param_dir],
arguments=['-i', usb_port],
output='screen'),
])
...
ros2 launch turtlebot3_bringup robot.launch.py
ros2 launch ydlidar_ros2_driver ydlidar_launch.py