cps_rmp220_support/launch/robot_lidar.launch.py

71 lines
2.5 KiB
Python
Raw Normal View History

2023-07-28 10:16:18 +00:00
#!/usr/bin/env python3
import os
2023-07-28 10:16:18 +00:00
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
2023-07-28 10:16:18 +00:00
from launch.actions import DeclareLaunchArgument
from launch.actions import LogInfo
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
def generate_launch_description():
2023-07-28 10:16:18 +00:00
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([
2023-07-28 10:16:18 +00:00
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(
2023-07-28 09:07:50 +00:00
package='sllidar_ros2',
2023-07-28 10:16:18 +00:00
executable='sllidar_node',
output='screen',
parameters=[{
2023-07-28 10:18:27 +00:00
'serial_port': serial_port,
'frame_id': 'laser_frame',
2023-07-28 10:16:18 +00:00
'scan_mode': 'Sensitivity',
'channel_type':channel_type,
'serial_baudrate': serial_baudrate,
'inverted': inverted,
'angle_compensate': angle_compensate
}]
)
])