diff --git a/launch_ROS2/msg_HAP_launch.py b/launch_ROS2/msg_HAP_launch.py index 2ff3d66a..877e681e 100644 --- a/launch_ROS2/msg_HAP_launch.py +++ b/launch_ROS2/msg_HAP_launch.py @@ -3,6 +3,8 @@ from launch import LaunchDescription from launch_ros.actions import Node import launch +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare ################### user configure parameters for ros2 start ################### xfer_format = 1 # 0-Pointcloud2(PointXYZRTL), 1-customized pointcloud format @@ -14,10 +16,16 @@ 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, 'livox_lidar.rviz') -user_config_path = os.path.join(cur_config_path, 'HAP_config.json') +rviz_config_path = PathJoinSubstitution([ + FindPackageShare('livox_ros_driver2'), + "config", + "livox_lidar.rviz" + ]) +user_config_path = PathJoinSubstitution([ + FindPackageShare('livox_ros_driver2'), + "config", + "HAP_config.json" + ]) ################### user configure parameters for ros2 end ##################### livox_ros2_params = [ diff --git a/launch_ROS2/msg_MID360_launch.py b/launch_ROS2/msg_MID360_launch.py index 8492c495..0161f003 100644 --- a/launch_ROS2/msg_MID360_launch.py +++ b/launch_ROS2/msg_MID360_launch.py @@ -3,6 +3,8 @@ from launch import LaunchDescription from launch_ros.actions import Node import launch +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare ################### user configure parameters for ros2 start ################### xfer_format = 1 # 0-Pointcloud2(PointXYZRTL), 1-customized pointcloud format @@ -14,9 +16,11 @@ 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' -user_config_path = os.path.join(cur_config_path, 'MID360_config.json') +user_config_path = PathJoinSubstitution([ + FindPackageShare('livox_ros_driver2'), + "config", + "MID360_config.json" + ]) ################### user configure parameters for ros2 end ##################### livox_ros2_params = [ diff --git a/launch_ROS2/rviz_HAP_launch.py b/launch_ROS2/rviz_HAP_launch.py index 834a5452..96b85cce 100644 --- a/launch_ROS2/rviz_HAP_launch.py +++ b/launch_ROS2/rviz_HAP_launch.py @@ -3,6 +3,8 @@ from launch import LaunchDescription from launch_ros.actions import Node import launch +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare ################### user configure parameters for ros2 start ################### xfer_format = 0 # 0-Pointcloud2(PointXYZRTL), 1-customized pointcloud format @@ -14,10 +16,16 @@ 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, 'HAP_config.json') +rviz_config_path = PathJoinSubstitution([ + FindPackageShare('livox_ros_driver2'), + "config", + "display_point_cloud_ROS2.rviz" + ]) +user_config_path = PathJoinSubstitution([ + FindPackageShare('livox_ros_driver2'), + "config", + "HAP_config.json" + ]) ################### user configure parameters for ros2 end ##################### livox_ros2_params = [ diff --git a/launch_ROS2/rviz_MID360_launch.py b/launch_ROS2/rviz_MID360_launch.py index 31d3480b..f8361047 100644 --- a/launch_ROS2/rviz_MID360_launch.py +++ b/launch_ROS2/rviz_MID360_launch.py @@ -3,6 +3,8 @@ from launch import LaunchDescription from launch_ros.actions import Node import launch +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare ################### user configure parameters for ros2 start ################### xfer_format = 0 # 0-Pointcloud2(PointXYZRTL), 1-customized pointcloud format @@ -14,10 +16,17 @@ 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') +rviz_config_path = PathJoinSubstitution([ + FindPackageShare('livox_ros_driver2'), + "config", + "display_point_cloud_ROS2.rviz" + ]) +user_config_path = PathJoinSubstitution([ + FindPackageShare('livox_ros_driver2'), + "config", + "MID360_config.json" + ]) + ################### user configure parameters for ros2 end ##################### livox_ros2_params = [ diff --git a/launch_ROS2/rviz_mixed.py b/launch_ROS2/rviz_mixed.py index 46a39c79..aacf188d 100644 --- a/launch_ROS2/rviz_mixed.py +++ b/launch_ROS2/rviz_mixed.py @@ -3,6 +3,8 @@ from launch import LaunchDescription from launch_ros.actions import Node import launch +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare ################### user configure parameters for ros2 start ################### xfer_format = 0 # 0-Pointcloud2(PointXYZRTL), 1-customized pointcloud format @@ -14,10 +16,16 @@ 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, 'mixed_HAP_MID360_config.json') +rviz_config_path = PathJoinSubstitution([ + FindPackageShare('livox_ros_driver2'), + "config", + "display_point_cloud_ROS2.rviz" + ]) +user_config_path = PathJoinSubstitution([ + FindPackageShare('livox_ros_driver2'), + "config", + "mixed_HAP_MID360_config.json" + ]) ################### user configure parameters for ros2 end ##################### livox_ros2_params = [