Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
Signed-off-by: badai-nguyen <[email protected]>
  • Loading branch information
badai-nguyen committed Sep 24, 2023
1 parent 7641b89 commit 09c3650
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 31 deletions.
11 changes: 11 additions & 0 deletions aip_x2_launch/config/blockage_diagnostics_param_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**:
ros__parameters:
blockage_ratio_threshold: 0.1
blockage_count_threshold: 50
blockage_buffering_frames: 2
blockage_buffering_interval: 1
dust_ratio_threshold: 0.2
dust_count_threshold: 10
dust_kernel_size: 2
dust_buffering_frames: 10
dust_buffering_interval: 1
44 changes: 13 additions & 31 deletions aip_x2_launch/launch/pandar_node_container.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,10 @@
from launch_ros.actions import LoadComposableNodes
from launch_ros.actions import Node
from launch_ros.descriptions import ComposableNode
from launch_ros.substitutions import FindPackageShare
import yaml


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


def get_pandar_monitor_info():
path = os.path.join(
get_package_share_directory("pandar_monitor"),
Expand Down Expand Up @@ -67,14 +61,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 Down Expand Up @@ -129,7 +120,6 @@ def create_parameter_dict(*args):
extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
)

dual_return_filter_info = get_dual_return_filter_info(context)
cropbox_parameters = create_parameter_dict("input_frame", "output_frame")
cropbox_parameters["negative"] = True

Expand All @@ -153,7 +143,7 @@ def create_parameter_dict(*args):
extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
)

mirror_info = get_vehicle_mirror_info(context)
mirror_info = load_composable_node_param("vehicle_mirror_param_file")
right = mirror_info["right"]
cropbox_parameters.update(
min_x=right["min_longitudinal_offset"],
Expand Down Expand Up @@ -238,7 +228,7 @@ def create_parameter_dict(*args):
"max_azimuth_deg": LaunchConfiguration("max_azimuth_deg"),
}
]
+ [dual_return_filter_info],
+ [load_composable_node_param("dual_return_filter_param_file")],
extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
)

Expand All @@ -254,14 +244,11 @@ def create_parameter_dict(*args):
{
"angle_range": LaunchConfiguration("angle_range"),
"horizontal_ring_id": LaunchConfiguration("horizontal_ring_id"),
"blockage_ratio_threshold": LaunchConfiguration("blockage_ratio_threshold"),
"vertical_bins": LaunchConfiguration("vertical_bins"),
"model": LaunchConfiguration("model"),
"blockage_count_threshold": LaunchConfiguration("blockage_count_threshold"),
"buffering_frames": LaunchConfiguration("buffering_frames"),
"buffering_interval": LaunchConfiguration("buffering_interval"),
}
],
]
+ [load_composable_node_param("blockage_diagnostics_param_file")],
extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
)

Expand Down Expand Up @@ -335,20 +322,15 @@ def add_launch_arg(name: str, default_value=None):
add_launch_arg("input_frame", LaunchConfiguration("base_frame"))
add_launch_arg("output_frame", LaunchConfiguration("base_frame"))
add_launch_arg("dual_return_filter_param_file")
add_launch_arg(
"blockage_diagnostics_param_file",
[FindPackageShare("aip_x2_launch"), "/config/blockage_diagnostics_param_file.yaml"],
)
add_launch_arg("vehicle_mirror_param_file")
add_launch_arg("use_multithread", "true")
add_launch_arg("use_intra_process", "true")
add_launch_arg("vertical_bins", "40")
add_launch_arg("blockage_ratio_threshold", "0.1")
add_launch_arg("horizontal_ring_id", "12")
add_launch_arg("blockage_count_threshold", "50")
add_launch_arg("blockage_buffering_frames", "2")
add_launch_arg("blockage_buffering_interval", "1")
add_launch_arg("dust_ratio_threshold", "0.2")
add_launch_arg("dust_count_threshold", "10")
add_launch_arg("dust_kernel_size", "2")
add_launch_arg("dust_buffering_frames", "10")
add_launch_arg("dust_buffering_interval", "1")

add_launch_arg("min_azimuth_deg", "135.0")
add_launch_arg("max_azimuth_deg", "225.0")
Expand Down

0 comments on commit 09c3650

Please sign in to comment.