79 lines
2.5 KiB
Python
79 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
from ament_index_python.packages import get_package_share_directory
|
|
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
|
|
|
|
|
|
def generate_launch_description():
|
|
channel_type = LaunchConfiguration('channel_type', default='tcp')
|
|
tcp_ip = LaunchConfiguration('tcp_ip', default='192.168.0.7')
|
|
tcp_port = LaunchConfiguration('tcp_port', default='20108')
|
|
frame_id = LaunchConfiguration('frame_id', default='laser')
|
|
inverted = LaunchConfiguration('inverted', default='false')
|
|
angle_compensate = LaunchConfiguration('angle_compensate', default='true')
|
|
|
|
rviz_config_dir = os.path.join(
|
|
get_package_share_directory('sllidar_ros2'),
|
|
'rviz',
|
|
'sllidar_ros2.rviz')
|
|
|
|
return LaunchDescription([
|
|
|
|
DeclareLaunchArgument(
|
|
'channel_type',
|
|
default_value=channel_type,
|
|
description='Specifying channel type of lidar'),
|
|
|
|
DeclareLaunchArgument(
|
|
'tcp_ip',
|
|
default_value=tcp_ip,
|
|
description='Specifying tcp ip to connected lidar'),
|
|
|
|
DeclareLaunchArgument(
|
|
'tcp_port',
|
|
default_value=tcp_port,
|
|
description='Specifying tcp port 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'),
|
|
|
|
Node(
|
|
package='sllidar_ros2',
|
|
executable='sllidar_node',
|
|
name='sllidar_node',
|
|
parameters=[{'channel_type': channel_type,
|
|
'tcp_ip': tcp_ip,
|
|
'tcp_port': tcp_port,
|
|
'frame_id': frame_id,
|
|
'inverted': inverted,
|
|
'angle_compensate': angle_compensate}],
|
|
output='screen'),
|
|
|
|
Node(
|
|
package='rviz2',
|
|
executable='rviz2',
|
|
name='rviz2',
|
|
arguments=['-d', rviz_config_dir],
|
|
output='screen'),
|
|
])
|
|
|
|
|