58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
from launch import LaunchDescription
|
|
from launch.actions import GroupAction, DeclareLaunchArgument
|
|
from launch.conditions import IfCondition
|
|
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
|
|
from launch_ros.actions import Node
|
|
from launch_ros.substitutions import FindPackageShare
|
|
|
|
|
|
def generate_launch_description():
|
|
# Declare the RViz argument
|
|
rviz_arg = DeclareLaunchArgument(
|
|
'rviz', default_value='true',
|
|
description='Flag to launch RViz.')
|
|
|
|
# Node parameters, including those from the YAML configuration file
|
|
laser_mapping_params = [
|
|
PathJoinSubstitution([
|
|
FindPackageShare('point_lio'),
|
|
'config', 'mid360.yaml'
|
|
])
|
|
]
|
|
|
|
# Node definition for laserMapping with Point-LIO
|
|
laser_mapping_node = Node(
|
|
package='point_lio',
|
|
executable='pointlio_mapping',
|
|
name='laserMapping',
|
|
output='screen',
|
|
parameters=laser_mapping_params,
|
|
# prefix='gdb -ex run --args'
|
|
)
|
|
|
|
# Conditional RViz node launch
|
|
rviz_node = Node(
|
|
package='rviz2',
|
|
executable='rviz2',
|
|
name='rviz',
|
|
arguments=['-d', PathJoinSubstitution([
|
|
FindPackageShare('point_lio'),
|
|
'rviz_cfg', 'loam_livox.rviz'
|
|
])],
|
|
condition=IfCondition(LaunchConfiguration('rviz')),
|
|
prefix='nice'
|
|
)
|
|
|
|
# Assemble the launch description
|
|
ld = LaunchDescription([
|
|
rviz_arg,
|
|
laser_mapping_node,
|
|
#octomap_server_node,
|
|
GroupAction(
|
|
actions=[rviz_node],
|
|
condition=IfCondition(LaunchConfiguration('rviz'))
|
|
),
|
|
])
|
|
|
|
return ld
|