fix(agv_pro_bringup): add launch with RViz condition
This commit is contained in:
@@ -99,7 +99,7 @@ def generate_launch_description():
|
|||||||
|
|
||||||
lidar_launchs = [
|
lidar_launchs = [
|
||||||
include_lidar('lslidar_driver', 'lsn10p_launch.py', enable_lidar, lidar_type, 'n10p'),
|
include_lidar('lslidar_driver', 'lsn10p_launch.py', enable_lidar, lidar_type, 'n10p'),
|
||||||
include_lidar('livox_ros_driver2', 'msg_MID360_launch.py',enable_lidar, lidar_type, 'mid360'),
|
include_lidar('livox_ros_driver2', 'MID360_launch.py',enable_lidar, lidar_type, 'mid360'),
|
||||||
include_lidar('unitree_lidar_ros2', 'launch.py', enable_lidar, lidar_type, 'l2'),
|
include_lidar('unitree_lidar_ros2', 'launch.py', enable_lidar, lidar_type, 'l2'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
import os
|
||||||
|
from ament_index_python.packages import get_package_share_directory
|
||||||
|
from launch import LaunchDescription
|
||||||
|
from launch.actions import DeclareLaunchArgument
|
||||||
|
from launch.conditions import IfCondition
|
||||||
|
from launch.substitutions import LaunchConfiguration, PythonExpression
|
||||||
|
from launch_ros.actions import Node
|
||||||
|
|
||||||
|
################### user configure parameters for ros2 start ###################
|
||||||
|
# xfer_format = 0 # 0-Pointcloud2(PointXYZRTL), 1-customized pointcloud format
|
||||||
|
multi_topic = 0 # 0-All LiDARs share the same topic, 1-One LiDAR one topic
|
||||||
|
data_src = 0 # 0-lidar, others-Invalid data src
|
||||||
|
# publish_freq = 10.0 # freqency of publish, 5.0, 10.0, 20.0, 50.0, etc.
|
||||||
|
output_type = 0
|
||||||
|
frame_id = 'laser_link'
|
||||||
|
lvx_file_path = '/home/livox/livox_test.lvx'
|
||||||
|
cmdline_bd_code = 'livox0000000001'
|
||||||
|
|
||||||
|
cur_path = os.path.split(os.path.realpath(__file__))[0] + '/'
|
||||||
|
cur_config_path = cur_path + '../config'
|
||||||
|
rviz_config_path = os.path.join(cur_config_path, 'display_point_cloud_ROS2.rviz')
|
||||||
|
user_config_path = os.path.join(cur_config_path, 'MID360_config.json')
|
||||||
|
################### user configure parameters for ros2 end #####################
|
||||||
|
|
||||||
|
def generate_launch_description():
|
||||||
|
|
||||||
|
use_mid360_rviz = LaunchConfiguration('use_mid360_rviz')
|
||||||
|
xfer_format = LaunchConfiguration('xfer_format')
|
||||||
|
publish_freq = LaunchConfiguration('publish_freq')
|
||||||
|
|
||||||
|
declare_rviz_arg = DeclareLaunchArgument(
|
||||||
|
'use_mid360_rviz',
|
||||||
|
default_value='false',
|
||||||
|
description='Enable RViz for MID360 LiDAR visualization'
|
||||||
|
)
|
||||||
|
|
||||||
|
declare_xfer_format_arg = DeclareLaunchArgument(
|
||||||
|
'xfer_format',
|
||||||
|
default_value='0',
|
||||||
|
description='MID360 format: 0=Pointcloud2(PointXYZRTL), 1=customized pointcloud format'
|
||||||
|
)
|
||||||
|
|
||||||
|
declare_publish_freq_arg = DeclareLaunchArgument(
|
||||||
|
'publish_freq',
|
||||||
|
default_value='10.0',
|
||||||
|
description='MID360 LiDAR publish frequency in Hz (e.g., 5.0, 10.0, 20.0, 50.0)'
|
||||||
|
)
|
||||||
|
|
||||||
|
livox_ros2_params = [
|
||||||
|
{"xfer_format": xfer_format},
|
||||||
|
{"multi_topic": multi_topic},
|
||||||
|
{"data_src": data_src},
|
||||||
|
{"publish_freq": publish_freq},
|
||||||
|
{"output_data_type": output_type},
|
||||||
|
{"frame_id": frame_id},
|
||||||
|
{"lvx_file_path": lvx_file_path},
|
||||||
|
{"user_config_path": user_config_path},
|
||||||
|
{"cmdline_input_bd_code": cmdline_bd_code}
|
||||||
|
]
|
||||||
|
|
||||||
|
livox_driver = Node(
|
||||||
|
package='livox_ros_driver2',
|
||||||
|
executable='livox_ros_driver2_node',
|
||||||
|
name='livox_lidar_publisher',
|
||||||
|
output='screen',
|
||||||
|
parameters=livox_ros2_params
|
||||||
|
)
|
||||||
|
|
||||||
|
livox_rviz = Node(
|
||||||
|
package='rviz2',
|
||||||
|
executable='rviz2',
|
||||||
|
name='mid360_lidar_rviz',
|
||||||
|
output='screen',
|
||||||
|
arguments=['--display-config', rviz_config_path],
|
||||||
|
condition=IfCondition(
|
||||||
|
PythonExpression([
|
||||||
|
"'", use_mid360_rviz, "' == 'true' and '",
|
||||||
|
xfer_format, "' == '0'"
|
||||||
|
])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return LaunchDescription([
|
||||||
|
declare_rviz_arg,
|
||||||
|
declare_xfer_format_arg,
|
||||||
|
declare_publish_freq_arg,
|
||||||
|
livox_driver,
|
||||||
|
livox_rviz,
|
||||||
|
])
|
||||||
@@ -9,12 +9,12 @@ from ament_index_python.packages import get_package_share_directory
|
|||||||
|
|
||||||
def generate_launch_description():
|
def generate_launch_description():
|
||||||
|
|
||||||
use_rviz = LaunchConfiguration('use_rviz')
|
use_l2_rviz = LaunchConfiguration('use_rviz')
|
||||||
|
|
||||||
declare_use_rviz = DeclareLaunchArgument(
|
declare_rviz_arg = DeclareLaunchArgument(
|
||||||
'use_rviz',
|
'use_l2_rviz',
|
||||||
default_value='false',
|
default_value='false',
|
||||||
description='Whether to start RViz'
|
description='Whether to launch RViz for Unitree L2 LiDAR visualization'
|
||||||
)
|
)
|
||||||
|
|
||||||
pkg_share = get_package_share_directory('unitree_lidar_ros2')
|
pkg_share = get_package_share_directory('unitree_lidar_ros2')
|
||||||
@@ -57,12 +57,12 @@ def generate_launch_description():
|
|||||||
executable='rviz2',
|
executable='rviz2',
|
||||||
name='rviz2',
|
name='rviz2',
|
||||||
arguments=['-d', rviz_config_file],
|
arguments=['-d', rviz_config_file],
|
||||||
condition=IfCondition(use_rviz),
|
condition=IfCondition(use_l2_rviz),
|
||||||
output='log'
|
output='log'
|
||||||
)
|
)
|
||||||
return LaunchDescription(
|
return LaunchDescription(
|
||||||
[
|
[
|
||||||
declare_use_rviz,
|
declare_rviz_arg,
|
||||||
node1,
|
node1,
|
||||||
rviz_node,
|
rviz_node,
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user