This commit is contained in:
Björn Ellensohn 2023-07-28 12:16:18 +02:00
parent ffb72d9151
commit 0ee5880cf5

View File

@ -1,20 +1,70 @@
#!/usr/bin/env python3
import os import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import LogInfo
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node from launch_ros.actions import Node
def generate_launch_description(): def generate_launch_description():
channel_type = LaunchConfiguration('channel_type', default='serial')
serial_port = LaunchConfiguration('serial_port', default='/dev/ttyUSB0')
serial_baudrate = LaunchConfiguration('serial_baudrate', default='115200') #for A1/A2 is 115200
frame_id = LaunchConfiguration('frame_id', default='laser')
inverted = LaunchConfiguration('inverted', default='false')
angle_compensate = LaunchConfiguration('angle_compensate', default='true')
scan_mode = LaunchConfiguration('scan_mode', default='Sensitivity')
return LaunchDescription([ return LaunchDescription([
DeclareLaunchArgument(
'channel_type',
default_value=channel_type,
description='Specifying channel type of lidar'),
DeclareLaunchArgument(
'serial_port',
default_value=serial_port,
description='Specifying usb port to connected lidar'),
DeclareLaunchArgument(
'serial_baudrate',
default_value=serial_baudrate,
description='Specifying usb port baudrate to connected lidar'),
DeclareLaunchArgument(
'frame_id',
default_value=frame_id,
description='Specifying frame_id of lidar'),
DeclareLaunchArgument(
'inverted',
default_value=inverted,
description='Specifying whether or not to invert scan data'),
DeclareLaunchArgument(
'angle_compensate',
default_value=angle_compensate,
description='Specifying whether or not to enable angle_compensate of scan data'),
DeclareLaunchArgument(
'scan_mode',
default_value=scan_mode,
description='Specifying scan mode of lidar'),
Node( Node(
package='sllidar_ros2', package='sllidar_ros2',
executable='view_sllidar_launch', executable='sllidar_node',
output='screen', output='screen',
parameters=[{ parameters=[{
'serial_port': 'usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_3453995662b3af4f81f4a69eba5f3f29-if00-port0', 'serial_port': 'usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_3453995662b3af4f81f4a69eba5f3f29-if00-port0',
'frame_id': 'laser_frame', 'frame_id': 'laser_frame',
'angle_compensate': True, 'scan_mode': 'Sensitivity',
'scan_mode': 'Sensitivity' 'channel_type':channel_type,
'serial_baudrate': serial_baudrate,
'inverted': inverted,
'angle_compensate': angle_compensate
}] }]
) )
]) ])