Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pointcloud_preprocessor): fix launch error #4431

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 33 additions & 32 deletions sensing/pointcloud_preprocessor/launch/preprocessor.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,25 @@
import launch
from launch.actions import DeclareLaunchArgument
from launch.actions import LogInfo
from launch.actions import OpaqueFunction
from launch.substitutions import LaunchConfiguration
from launch.substitutions import PythonExpression
from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode


def generate_launch_description():
def launch_setup(context, *args, **kwargs):
ns = "pointcloud_preprocessor"
pkg = "pointcloud_preprocessor"

# declare launch arguments
input_points_raw_list_param = DeclareLaunchArgument(
"input_points_raw_list",
default_value="['/points_raw']",
description="Input pointcloud topic_name list as a string_array. "
"To subscribe multiple topics, write as: \"['/points_raw0', '/points_raw1', ...]\"",
)

output_points_raw_param = DeclareLaunchArgument(
"output_points_raw", default_value="/points_raw/cropbox/filtered"
)

tf_output_frame_param = DeclareLaunchArgument("tf_output_frame", default_value="base_link")

# set concat filter as a component
separate_concatenate_node_and_timesync_node_str = DeclareLaunchArgument(
"separate_concatenate_node_and_timesync_node",
default_value="false",
description="Set True to separate concatenate node and timesync node. which will cause to larger memory usage.",
)
separate_concatenate_node_and_timesync_node = (
separate_concatenate_node_and_timesync_node_str.lower() == "true"
separate_concatenate_node_and_timesync_node = LaunchConfiguration(
"separate_concatenate_node_and_timesync_node"
).perform(context)
is_separate_concatenate_node_and_timesync_node = (
separate_concatenate_node_and_timesync_node.lower() == "true"
)

if not separate_concatenate_node_and_timesync_node:
if not is_separate_concatenate_node_and_timesync_node:
sync_and_concat_component = ComposableNode(
package=pkg,
plugin="pointcloud_preprocessor::PointCloudConcatenateDataSynchronizerComponent",
Expand Down Expand Up @@ -150,13 +134,30 @@ def generate_launch_description():
]
)
)
return [container, log_info]

return launch.LaunchDescription(
[
input_points_raw_list_param,
output_points_raw_param,
tf_output_frame_param,
container,
log_info,
]

def generate_launch_description():
launch_arguments = []

def add_launch_arg(name: str, default_value=None, description=None):
# a default_value of None is equivalent to not passing that kwarg at all
launch_arguments.append(
DeclareLaunchArgument(name, default_value=default_value, description=description)
)

add_launch_arg(
"input_points_raw_list",
["/points_raw"],
"Input pointcloud topic_name list as a string_array. "
"To subscribe multiple topics, write as: \"['/points_raw0', '/points_raw1', ...]\"",
)
add_launch_arg("output_points_raw", "/points_raw/cropbox/filtered")
add_launch_arg("tf_output_frame", "base_link")
add_launch_arg(
"separate_concatenate_node_and_timesync_node",
"true",
"Set True to separate concatenate node and timesync node. which will cause to larger memory usage.",
)

return launch.LaunchDescription(launch_arguments + [OpaqueFunction(function=launch_setup)])