Skip to content

Commit

Permalink
feat: modify the nebula_node_container based on tier4 internal common…
Browse files Browse the repository at this point in the history
…_sensor_launch

Signed-off-by: vividf <[email protected]>
  • Loading branch information
vividf committed Jun 27, 2024
1 parent 070cb9c commit e8b7db0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
1 change: 1 addition & 0 deletions common_sensor_launch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ endif()

ament_auto_package(INSTALL_TO_SHARE
launch
config
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**:
ros__parameters:
base_frame: base_link
use_imu: true
use_3d_distortion_correction: false
42 changes: 13 additions & 29 deletions common_sensor_launch/launch/nebula_node_container.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from launch_ros.actions import ComposableNodeContainer
from launch_ros.actions import LoadComposableNodes
from launch_ros.descriptions import ComposableNode
from launch_ros.parameter_descriptions import ParameterFile
from launch_ros.substitutions import FindPackageShare
import yaml


Expand Down Expand Up @@ -55,14 +55,11 @@ def get_vehicle_info(context):
return p


def get_vehicle_mirror_info(context):
path = LaunchConfiguration("vehicle_mirror_param_file").perform(context)
with open(path, "r") as f:
p = yaml.safe_load(f)["/**"]["ros__parameters"]
return p


def launch_setup(context, *args, **kwargs):
def load_composable_node_param(param_path):
with open(LaunchConfiguration(param_path).perform(context), "r") as f:
return yaml.safe_load(f)["/**"]["ros__parameters"]

def create_parameter_dict(*args):
result = {}
for x in args:
Expand All @@ -85,12 +82,6 @@ def create_parameter_dict(*args):
sensor_calib_fp
), "Sensor calib file under calibration/ was not found: {}".format(sensor_calib_fp)

# Pointcloud preprocessor parameters
distortion_corrector_node_param = ParameterFile(
param_file=LaunchConfiguration("distortion_correction_node_param_path").perform(context),
allow_substs=True,
)

nodes = []

nodes.append(
Expand Down Expand Up @@ -158,7 +149,7 @@ def create_parameter_dict(*args):
)
)

mirror_info = get_vehicle_mirror_info(context)
mirror_info = load_composable_node_param("vehicle_mirror_param_file")
cropbox_parameters["min_x"] = mirror_info["min_longitudinal_offset"]
cropbox_parameters["max_x"] = mirror_info["max_longitudinal_offset"]
cropbox_parameters["min_y"] = mirror_info["min_lateral_offset"]
Expand Down Expand Up @@ -191,7 +182,7 @@ def create_parameter_dict(*args):
("~/input/pointcloud", "mirror_cropped/pointcloud_ex"),
("~/output/pointcloud", "rectified/pointcloud_ex"),
],
parameters=[distortion_corrector_node_param],
parameters=[load_composable_node_param("distortion_corrector_node_param_file")],
extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
)
)
Expand Down Expand Up @@ -273,8 +264,6 @@ def add_launch_arg(name: str, default_value=None, description=None):
DeclareLaunchArgument(name, default_value=default_value, description=description)
)

pointcloud_preprocessor_share_dir = get_package_share_directory("pointcloud_preprocessor")

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")
Expand All @@ -295,22 +284,17 @@ def add_launch_arg(name: str, default_value=None, description=None):
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("use_multithread", "False", "use multithread")
add_launch_arg("use_intra_process", "False", "use ROS 2 component container communication")
add_launch_arg("lidar_container_name", "nebula_node_container")
add_launch_arg("output_as_sensor_frame", "True", "output final pointcloud in sensor frame")
add_launch_arg(
"vehicle_mirror_param_file", description="path to the file of vehicle mirror position yaml"
)
add_launch_arg(
"distortion_correction_node_param_path",
os.path.join(
pointcloud_preprocessor_share_dir,
"config",
"distortion_corrector_node.param.yaml",
),
description="path to parameter file of distortion correction node",
"distortion_corrector_node_param_file",
[FindPackageShare("common_sensor_launch"), "/config/distortion_corrector_node.param.yaml"],
)
add_launch_arg("use_multithread", "False", "use multithread")
add_launch_arg("use_intra_process", "False", "use ROS 2 component container communication")
add_launch_arg("lidar_container_name", "nebula_node_container")
add_launch_arg("output_as_sensor_frame", "True", "output final pointcloud in sensor frame")

set_container_executable = SetLaunchConfiguration(
"container_executable",
Expand Down

0 comments on commit e8b7db0

Please sign in to comment.