diff --git a/aip_x1_launch/launch/lidar.launch.xml b/aip_x1_launch/launch/lidar.launch.xml index cb00eab5..e59b1fa3 100644 --- a/aip_x1_launch/launch/lidar.launch.xml +++ b/aip_x1_launch/launch/lidar.launch.xml @@ -18,7 +18,7 @@ - + diff --git a/aip_xx1_launch/launch/lidar.launch.xml b/aip_xx1_launch/launch/lidar.launch.xml index 8ae4cfeb..a36ad49c 100644 --- a/aip_xx1_launch/launch/lidar.launch.xml +++ b/aip_xx1_launch/launch/lidar.launch.xml @@ -1,9 +1,10 @@ - - - - + + + + + @@ -13,14 +14,15 @@ - - + + - - - - - + + + + + + @@ -28,16 +30,17 @@ - - + + - - - - - - - + + + + + + + + @@ -45,16 +48,17 @@ - - + + - - - - - - - + + + + + + + + @@ -62,16 +66,17 @@ - - + + - - - - - - - + + + + + + + + @@ -97,10 +102,10 @@ --> - - - - + + + + diff --git a/common_sensor_launch/launch/hesai_XT32.launch.xml b/common_sensor_launch/launch/hesai_XT32.launch.xml new file mode 100644 index 00000000..7b1753e2 --- /dev/null +++ b/common_sensor_launch/launch/hesai_XT32.launch.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common_sensor_launch/launch/velodyne_node_container.launch.py b/common_sensor_launch/launch/nebula_node_container.launch.py similarity index 69% rename from common_sensor_launch/launch/velodyne_node_container.launch.py rename to common_sensor_launch/launch/nebula_node_container.launch.py index 55bedf17..903f3b89 100644 --- a/common_sensor_launch/launch/velodyne_node_container.launch.py +++ b/common_sensor_launch/launch/nebula_node_container.launch.py @@ -1,4 +1,4 @@ -# Copyright 2020 Tier IV, Inc. All rights reserved. +# Copyright 2023 Tier IV, Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os +import warnings + +from ament_index_python.packages import get_package_share_directory import launch from launch.actions import DeclareLaunchArgument from launch.actions import OpaqueFunction @@ -25,6 +29,14 @@ import yaml +def get_lidar_make(sensor_name): + if sensor_name[:6].lower() == "pandar": + return "Hesai", ".csv" + elif sensor_name[:3].lower() in ["hdl", "vlp", "vls"]: + return "Velodyne", ".yaml" + return "unrecognized_sensor_model" + + def get_vehicle_info(context): # TODO(TIER IV): Use Parameter Substitution after we drop Galactic support # https://github.com/ros2/launch_ros/blob/master/launch_ros/launch_ros/substitutions/parameter.py @@ -57,33 +69,63 @@ def create_parameter_dict(*args): result[x] = LaunchConfiguration(x) return result + # Model and make + sensor_model = LaunchConfiguration("sensor_model").perform(context) + sensor_make, sensor_extension = get_lidar_make(sensor_model) + nebula_decoders_share_dir = get_package_share_directory("nebula_decoders") + nebula_ros_share_dir = get_package_share_directory("nebula_ros") + + # Config + sensor_params_fp = LaunchConfiguration("config_file").perform(context) + if sensor_params_fp == "": + warnings.warn("No config file provided, using sensor model default", RuntimeWarning) + sensor_params_fp = os.path.join( + nebula_ros_share_dir, "config", sensor_make.lower(), sensor_model + ".yaml" + ) + sensor_calib_fp = os.path.join( + nebula_decoders_share_dir, + "calibration", + sensor_make.lower(), + sensor_model + sensor_extension, + ) + if not os.path.exists(sensor_params_fp): + sensor_params_fp = os.path.join(nebula_ros_share_dir, "config", "BaseParams.yaml") + assert os.path.exists( + sensor_params_fp + ), "Sensor params yaml file under config/ was not found: {}".format(sensor_params_fp) + assert os.path.exists( + sensor_calib_fp + ), "Sensor calib file under calibration/ was not found: {}".format(sensor_calib_fp) + with open(sensor_params_fp, "r") as f: + sensor_params = yaml.safe_load(f)["/**"]["ros__parameters"] + nodes = [] - # turn packets into pointcloud as in - # https://github.com/ros-drivers/velodyne/blob/ros2/velodyne_pointcloud/launch/velodyne_convert_node-VLP16-composed-launch.py nodes.append( ComposableNode( - package="velodyne_pointcloud", - plugin="velodyne_pointcloud::Convert", - name="velodyne_convert_node", + package="nebula_ros", + plugin=sensor_make + "DriverRosWrapper", + name=sensor_make.lower() + "_driver_ros_wrapper_node", parameters=[ + sensor_params, { + "calibration_file": sensor_calib_fp, + "sensor_model": sensor_model, **create_parameter_dict( - "calibration", + "return_mode", "min_range", "max_range", - "num_points_thresholds", - "invalid_intensity", "frame_id", "scan_phase", - "view_direction", - "view_width", + "cloud_min_angle", + "cloud_max_angle", + "dual_return_distance_threshold", ), - } + }, ], remappings=[ - ("velodyne_points", "pointcloud_raw"), - ("velodyne_points_ex", "pointcloud_raw_ex"), + ("aw_points", "pointcloud_raw"), + ("aw_points_ex", "pointcloud_raw_ex"), ], extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}], ) @@ -182,24 +224,25 @@ def create_parameter_dict(*args): ) driver_component = ComposableNode( - package="velodyne_driver", - plugin="velodyne_driver::VelodyneDriver", + package="nebula_ros", + plugin=sensor_make + "HwInterfaceRosWrapper", # node is created in a global context, need to avoid name clash - name="velodyne_driver", + name=sensor_make.lower() + "_hw_interface_ros_wrapper_node", parameters=[ { + "sensor_model": sensor_model, + "calibration_file": sensor_calib_fp, **create_parameter_dict( - "device_ip", - "gps_time", - "read_once", - "read_fast", - "repeat_delay", - "frame_id", - "model", - "rpm", - "port", - "pcap", + "sensor_ip", + "host_ip", "scan_phase", + "return_mode", + "frame_id", + "rotation_speed", + "data_port", + "gnss_port", + "cloud_min_angle", + "cloud_max_angle", ), } ], @@ -229,38 +272,31 @@ def add_launch_arg(name: str, default_value=None, description=None): DeclareLaunchArgument(name, default_value=default_value, description=description) ) - add_launch_arg("model", description="velodyne model name") + add_launch_arg("sensor_model", description="sensor model name") + add_launch_arg("config_file", "", description="sensor configuration file") add_launch_arg("launch_driver", "True", "do launch driver") - add_launch_arg("calibration", description="path to calibration file") - add_launch_arg("device_ip", "192.168.1.201", "device ip address") + add_launch_arg("sensor_ip", "192.168.1.201", "device ip address") + add_launch_arg("host_ip", "255.255.255.255", "host ip address") add_launch_arg("scan_phase", "0.0") add_launch_arg("base_frame", "base_link", "base frame id") - add_launch_arg("container_name", "velodyne_composable_node_container", "container name") - add_launch_arg("min_range", description="minimum view range") - add_launch_arg("max_range", description="maximum view range") - add_launch_arg("pcap", "") - add_launch_arg("port", "2368", description="device port number") - add_launch_arg("read_fast", "False") - add_launch_arg("read_once", "False") - add_launch_arg("repeat_delay", "0.0") - add_launch_arg("rpm", "600.0", "rotational frequency") - add_launch_arg("laserscan_ring", "-1") - add_launch_arg("laserscan_resolution", "0.007") - add_launch_arg("num_points_thresholds", "300") - add_launch_arg("invalid_intensity") - add_launch_arg("frame_id", "velodyne", "velodyne frame id") - add_launch_arg("gps_time", "False") - add_launch_arg("view_direction", description="the center of lidar angle") - add_launch_arg("view_width", description="lidar angle: 0~6.28 [rad]") + add_launch_arg("min_range", "0.3", "minimum view range for Velodyne sensors") + add_launch_arg("max_range", "300.0", "maximum view range for Velodyne sensors") + add_launch_arg("cloud_min_angle", "0", "minimum view angle setting on device") + add_launch_arg("cloud_max_angle", "360", "maximum view angle setting on device") + add_launch_arg("data_port", "2368", "device data port number") + add_launch_arg("gnss_port", "2380", "device gnss port number") + add_launch_arg("rotation_speed", "600.0", "rotational frequency") + add_launch_arg("dual_return_distance_threshold", "0.1", "dual return distance threshold") + add_launch_arg("frame_id", "lidar", "frame id") add_launch_arg("input_frame", LaunchConfiguration("base_frame"), "use for cropbox") add_launch_arg("output_frame", LaunchConfiguration("base_frame"), "use for cropbox") add_launch_arg( "vehicle_mirror_param_file", description="path to the file of vehicle mirror position yaml" ) add_launch_arg("use_multithread", "False", "use multithread") - add_launch_arg("use_intra_process", "False", "use ROS2 component container communication") + add_launch_arg("use_intra_process", "False", "use ROS 2 component container communication") add_launch_arg("use_pointcloud_container", "false") - add_launch_arg("container_name", "velodyne_node_container") + add_launch_arg("container_name", "nebula_node_container") set_container_executable = SetLaunchConfiguration( "container_executable", diff --git a/common_sensor_launch/launch/velodyne_VLP16.launch.xml b/common_sensor_launch/launch/velodyne_VLP16.launch.xml index 5b109c7b..8dfa9f5e 100644 --- a/common_sensor_launch/launch/velodyne_VLP16.launch.xml +++ b/common_sensor_launch/launch/velodyne_VLP16.launch.xml @@ -1,45 +1,40 @@ - + - - - - - + + + + - + + - - - + + + - + - - + + - - - + + + - - - - - + + + + + - - - - - diff --git a/common_sensor_launch/launch/velodyne_VLP32C.launch.xml b/common_sensor_launch/launch/velodyne_VLP32C.launch.xml index 8bb46ca4..656be7c5 100644 --- a/common_sensor_launch/launch/velodyne_VLP32C.launch.xml +++ b/common_sensor_launch/launch/velodyne_VLP32C.launch.xml @@ -1,45 +1,40 @@ - + - - - - - - + + + + + - + + - - - + + + - + - - + + - - - + + + - - - - - + + + + + - - - - - diff --git a/common_sensor_launch/launch/velodyne_VLS128.launch.xml b/common_sensor_launch/launch/velodyne_VLS128.launch.xml index ecb0c66b..e9a16f16 100644 --- a/common_sensor_launch/launch/velodyne_VLS128.launch.xml +++ b/common_sensor_launch/launch/velodyne_VLS128.launch.xml @@ -1,45 +1,40 @@ - + - - - - - + + + + - + + - - - + + + - + - - + + - - - + + + - - - - - + + + + + - - - - - diff --git a/common_sensor_launch/package.xml b/common_sensor_launch/package.xml index 70f77c37..154ecec5 100644 --- a/common_sensor_launch/package.xml +++ b/common_sensor_launch/package.xml @@ -11,9 +11,7 @@ ament_cmake_auto dummy_diag_publisher - velodyne_driver - velodyne_monitor - velodyne_pointcloud + nebula_sensor_driver ament_lint_auto autoware_lint_common