Skip to content

Commit

Permalink
modify util.launch in localization_launch autowarefoundation#396
Browse files Browse the repository at this point in the history
  • Loading branch information
h-ohta authored Sep 27, 2021
1 parent ff36c12 commit 1ccc970
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**:
ros__parameters:
input_frame: "base_link"
output_frame: "base_link"
min_x: -60.0
max_x: 60.0
min_y: -60.0
max_y: 60.0
min_z: -30.0
max_z: 50.0
negative: False
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/**:
ros__parameters:
sample_num: 1500
5 changes: 5 additions & 0 deletions localization_launch/config/voxel_grid_filter.param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**:
ros__parameters:
voxel_size_x: 3.0
voxel_size_y: 3.0
voxel_size_z: 3.0
106 changes: 85 additions & 21 deletions localization_launch/launch/util/util.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@
# limitations under the License.

import launch
from launch.actions import DeclareLaunchArgument
from launch.actions import OpaqueFunction
from launch.conditions import LaunchConfigurationNotEquals
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import LoadComposableNodes
from launch_ros.descriptions import ComposableNode
from launch_ros.substitutions import FindPackageShare
import yaml


def generate_launch_description():
def launch_setup(context, *args, **kwargs):
# https://github.com/ros2/launch_ros/issues/156
def load_composable_node_param(param_path):
with open(LaunchConfiguration(param_path).perform(context), 'r') as f:
return yaml.safe_load(f)['/**']['ros__parameters']

crop_box_component = ComposableNode(
package='pointcloud_preprocessor',
plugin='pointcloud_preprocessor::CropBoxFilterComponent',
Expand All @@ -29,17 +38,9 @@ def generate_launch_description():
('output',
LaunchConfiguration('output_measurement_range_sensor_points_topic')),
],
parameters=[{
'input_frame': LaunchConfiguration('base_frame'),
'output_frame': LaunchConfiguration('base_frame'),
'min_x': -60.0,
'max_x': 60.0,
'min_y': -60.0,
'max_y': 60.0,
'min_z': -30.0,
'max_z': 50.0,
'negative': False,
}],
parameters=[
load_composable_node_param('crop_box_filter_measurement_range_param_path'),
],
extra_arguments=[{
'use_intra_process_comms': LaunchConfiguration('use_intra_process')
}],
Expand All @@ -54,11 +55,7 @@ def generate_launch_description():
('output',
LaunchConfiguration('output_voxel_grid_downsample_sensor_points_topic')),
],
parameters=[{
'voxel_size_x': 3.0,
'voxel_size_y': 3.0,
'voxel_size_z': 3.0,
}],
parameters=[load_composable_node_param('voxel_grid_downsample_filter_param_path')],
extra_arguments=[{
'use_intra_process_comms': LaunchConfiguration('use_intra_process')
}],
Expand All @@ -73,9 +70,9 @@ def generate_launch_description():
('output',
LaunchConfiguration('output_downsample_sensor_points_topic')),
],
parameters=[{
'sample_num': 1500,
}],
parameters=[
load_composable_node_param('random_downsample_filter_param_path')
],
extra_arguments=[{
'use_intra_process_comms': LaunchConfiguration('use_intra_process')
}],
Expand All @@ -90,4 +87,71 @@ def generate_launch_description():
composable_node_descriptions=composable_nodes,
target_container=LaunchConfiguration('container'),
)
return launch.LaunchDescription([load_composable_nodes])

return [load_composable_nodes]


def generate_launch_description():
launch_arguments = []

def add_launch_arg(name: str, default_value=None, description=None):
arg = DeclareLaunchArgument(name, default_value=default_value, description=description)
launch_arguments.append(arg)

add_launch_arg(
'crop_box_filter_measurement_range_param_path',
[
FindPackageShare('localization_launch'),
'/config/crop_box_filter_measurement_range.param.yaml'
],
'path to the parameter file of crop_box_filter_measurement_range'
)
add_launch_arg(
'voxel_grid_downsample_filter_param_path',
[
FindPackageShare('localization_launch'),
'/config/voxel_grid_filter.param.yaml'
],
'path to the parameter file of voxel_grid_downsample_filter'
)
add_launch_arg(
'random_downsample_filter_param_path',
[
FindPackageShare('localization_launch'),
'/config/random_downsample_filter.param.yaml'
],
'path to the parameter file of random_downsample_filter'
)
add_launch_arg('use_intra_process', 'true', 'use ROS2 component container communication')
add_launch_arg(
'container',
'/sensing/lidar/top/pointcloud_preprocessor/velodyne_node_container',
'container name'
)
add_launch_arg(
'input_sensor_points_topic',
'/sensing/lidar/top/rectified/pointcloud',
'input topic name for raw pointcloud'
)
add_launch_arg(
'output_measurement_range_sensor_points_topic',
'measurement_range/pointcloud',
'output topic name for crop box filter'
)
add_launch_arg(
'output_voxel_grid_downsample_sensor_points_topic',
'voxel_grid_downsample/pointcloud',
'output topic name for voxel grid downsample filter'
)
add_launch_arg(
'output_downsample_sensor_points_topic',
'downsample/pointcloud',
'output topic name for downsample filter. this is final output'
)

return launch.LaunchDescription(
launch_arguments +
[
OpaqueFunction(function=launch_setup)
]
)
3 changes: 0 additions & 3 deletions localization_launch/launch/util/util.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
<arg name="output_voxel_grid_downsample_sensor_points_topic" default="voxel_grid_downsample/pointcloud" description="output topic name for voxel grid downsample filter"/>
<arg name="output_downsample_sensor_points_topic" default="downsample/pointcloud" description="output topic name for downsample filter. this is final output"/>

<!-- frame_ids -->
<arg name="base_frame" default="base_link" description="Vehicle reference frame, for processing crop_box" />

<!-- container -->
<arg name="container" default="/sensing/lidar/top/pointcloud_preprocessor/velodyne_node_container" description="container name"/>

Expand Down

0 comments on commit 1ccc970

Please sign in to comment.