Skip to content

Commit

Permalink
feature/use common pointcloud container (autowarefoundation#147)
Browse files Browse the repository at this point in the history
* add container argument

* load composable node to pointcloud_container

* fix autoware_launch

* enable multi-thread

* improve readability
  • Loading branch information
satoshi-ota authored Dec 6, 2021
1 parent eaba97f commit 1102582
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 12 deletions.
12 changes: 12 additions & 0 deletions autoware_launch/launch/autoware.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<arg name="map_path" description="point cloud and lanelet2 map directory path"/>
<arg name="vehicle_model" description="vehicle model name"/>
<arg name="sensor_model" description="sensor model name"/>
<arg name="use_pointcloud_container" default="true" description="launch pointcloud container"/>
<arg name="pointcloud_container_name" default="pointcloud_container"/>
<!-- Optional parameters -->
<arg name="rviz" default="true" description="launch rviz"/>
<arg name="lanelet2_map_file" default="lanelet2_map.osm" description="lanelet2 map file name"/>
Expand All @@ -14,6 +16,12 @@
<arg name="vehicle_model" value="$(var vehicle_model)"/>
</include>

<!-- Pointcloud container -->
<include file="$(find-pkg-share autoware_launch)/launch/pointcloud_container.launch.py" if="$(var use_pointcloud_container)">
<arg name="use_multithread" value="true" />
<arg name="container_name" value="$(var pointcloud_container_name)"/>
</include>

<!-- Vehicle -->
<include file="$(find-pkg-share vehicle_launch)/launch/vehicle.launch.xml">
<arg name="vehicle_model" value="$(var vehicle_model)"/>
Expand All @@ -38,6 +46,8 @@
<arg name="sensor_model" value="$(var sensor_model)"/>
<arg name="vehicle_param_file" value="$(find-pkg-share $(var vehicle_model)_description)/config/vehicle_info.param.yaml"/>
<arg name="vehicle_mirror_param_file" value="$(find-pkg-share $(var vehicle_model)_description)/config/mirror.param.yaml"/>
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)" />
<arg name="pointcloud_container_name" value="$(var pointcloud_container_name)"/>
</include>

<!-- Localization -->
Expand All @@ -49,6 +59,8 @@
<!-- options for mode: camera_lidar_fusion, lidar, camera -->
<arg name="mode" value="camera_lidar_fusion" />
<arg name="vehicle_param_file" value="$(find-pkg-share $(var vehicle_model)_description)/config/vehicle_info.param.yaml"/>
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)" />
<arg name="pointcloud_container_name" value="$(var pointcloud_container_name)"/>
</include>

<!-- Planning -->
Expand Down
12 changes: 12 additions & 0 deletions autoware_launch/launch/logging_simulator.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<arg name="lanelet2_map_file" default="lanelet2_map.osm" description="lanelet2 map file name"/>
<arg name="pointcloud_map_file" default="pointcloud_map.pcd" description="pointcloud map file name"/>
<arg name="vehicle_simulation" default="false" description="use vehicle simulation"/>
<arg name="use_pointcloud_container" default="true" description="launch pointcloud container"/>
<arg name="pointcloud_container_name" default="pointcloud_container"/>
<!-- Optional parameters for scenario simulation -->
<arg name="scenario_simulation" default="false" description="use scenario simulation"/>

Expand All @@ -29,6 +31,12 @@
<arg name="vehicle_model" value="$(var vehicle_model)"/>
</include>

<!-- Pointcloud container -->
<include file="$(find-pkg-share autoware_launch)/launch/pointcloud_container.launch.py" if="$(var use_pointcloud_container)">
<arg name="use_multithread" value="true" />
<arg name="container_name" value="$(var pointcloud_container_name)"/>
</include>

<!-- Vehicle -->
<group>
<include file="$(find-pkg-share vehicle_launch)/launch/vehicle.launch.xml" if="$(var vehicle)">
Expand Down Expand Up @@ -62,6 +70,8 @@
<arg name="sensor_model" value="$(var sensor_model)"/>
<arg name="vehicle_param_file" value="$(find-pkg-share $(var vehicle_model)_description)/config/vehicle_info.param.yaml"/>
<arg name="vehicle_mirror_param_file" value="$(find-pkg-share $(var vehicle_model)_description)/config/mirror.param.yaml"/>
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)" />
<arg name="pointcloud_container_name" value="$(var pointcloud_container_name)"/>
</include>
</group>

Expand All @@ -77,6 +87,8 @@
<!-- options for mode: camera_lidar_fusion, lidar, camera -->
<arg name="mode" value="camera_lidar_fusion" />
<arg name="vehicle_param_file" value="$(find-pkg-share $(var vehicle_model)_description)/config/vehicle_info.param.yaml"/>
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)" />
<arg name="pointcloud_container_name" value="$(var pointcloud_container_name)"/>
</include>
</group>

Expand Down
57 changes: 57 additions & 0 deletions autoware_launch/launch/pointcloud_container.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2021 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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import SetLaunchConfiguration
from launch.conditions import IfCondition
from launch.conditions import UnlessCondition
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import ComposableNodeContainer


def generate_launch_description():
def add_launch_arg(name: str, default_value=None):
return DeclareLaunchArgument(name, default_value=default_value)

set_container_executable = SetLaunchConfiguration(
"container_executable",
"component_container",
condition=UnlessCondition(LaunchConfiguration("use_multithread")),
)

set_container_mt_executable = SetLaunchConfiguration(
"container_executable",
"component_container_mt",
condition=IfCondition(LaunchConfiguration("use_multithread")),
)

pointcloud_container = ComposableNodeContainer(
name=LaunchConfiguration("container_name"),
namespace="/",
package="rclcpp_components",
executable=LaunchConfiguration("container_executable"),
composable_node_descriptions=[],
output="screen",
)

return LaunchDescription(
[
add_launch_arg("use_multithread", "false"),
add_launch_arg("container_name", "pointcloud_container"),
set_container_executable,
set_container_mt_executable,
pointcloud_container,
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -319,20 +319,36 @@ def launch_setup(context, *args, **kwargs):

# set container to run all required components in the same process
container = ComposableNodeContainer(
name="perception_pipeline_container",
name=LaunchConfiguration("container_name"),
namespace="",
package="rclcpp_components",
executable=LaunchConfiguration("container_executable"),
composable_node_descriptions=[
crop_box_filter_component,
ground_filter_component,
],
condition=UnlessCondition(LaunchConfiguration("use_pointcloud_container")),
output="screen",
)

composable_nodes_loader = LoadComposableNodes(
composable_node_descriptions=[
crop_box_filter_component,
ground_filter_component,
],
target_container=LaunchConfiguration("container_name"),
condition=IfCondition(LaunchConfiguration("use_pointcloud_container")),
)

target_container = (
container
if UnlessCondition(LaunchConfiguration("use_pointcloud_container")).evaluate(context)
else LaunchConfiguration("container_name")
)

additional_pipeline_loader = LoadComposableNodes(
composable_node_descriptions=additional_pipeline_components,
target_container=container,
target_container=target_container,
condition=IfCondition(
LaunchConfiguration(
"use_additional_pipeline",
Expand All @@ -343,7 +359,7 @@ def launch_setup(context, *args, **kwargs):

concat_data_component_loader = LoadComposableNodes(
composable_node_descriptions=[concat_data_component],
target_container=container,
target_container=target_container,
condition=IfCondition(
LaunchConfiguration(
"use_additional_pipeline",
Expand All @@ -354,7 +370,7 @@ def launch_setup(context, *args, **kwargs):

compare_map_component_loader = LoadComposableNodes(
composable_node_descriptions=create_elevation_map_filter_pipeline(),
target_container=container,
target_container=target_container,
condition=IfCondition(
LaunchConfiguration(
"use_compare_map_pipeline",
Expand All @@ -365,7 +381,7 @@ def launch_setup(context, *args, **kwargs):

occupancy_grid_outlier_filter_component_loader = LoadComposableNodes(
composable_node_descriptions=[occupancy_outlier_filter_component],
target_container=container,
target_container=target_container,
condition=UnlessCondition(
LaunchConfiguration(
"use_compare_map_pipeline",
Expand All @@ -376,6 +392,7 @@ def launch_setup(context, *args, **kwargs):

return [
container,
composable_nodes_loader,
additional_pipeline_loader,
compare_map_component_loader,
concat_data_component_loader,
Expand All @@ -394,6 +411,8 @@ def add_launch_arg(name: str, default_value=None):
add_launch_arg("vehicle_param_file")
add_launch_arg("use_multithread", "False")
add_launch_arg("use_intra_process", "True")
add_launch_arg("use_pointcloud_container", "False")
add_launch_arg("container_name", "perception_pipeline_container")

set_container_executable = SetLaunchConfiguration(
"container_executable",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
from launch.actions import DeclareLaunchArgument
from launch.actions import SetLaunchConfiguration
from launch.conditions import IfCondition
from launch.conditions import LaunchConfigurationEquals
from launch.conditions import LaunchConfigurationNotEquals
from launch.conditions import UnlessCondition
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import ComposableNodeContainer
Expand Down Expand Up @@ -102,24 +100,23 @@ def add_launch_arg(name: str, default_value=None):
]

occupancy_grid_map_container = ComposableNodeContainer(
condition=LaunchConfigurationEquals("container", ""),
name="occupancy_grid_map_container",
name=LaunchConfiguration("container_name"),
namespace="",
package="rclcpp_components",
executable=LaunchConfiguration("container_executable"),
composable_node_descriptions=composable_nodes,
condition=UnlessCondition(LaunchConfiguration("use_pointcloud_container")),
output="screen",
)

load_composable_nodes = LoadComposableNodes(
condition=LaunchConfigurationNotEquals("container", ""),
composable_node_descriptions=composable_nodes,
target_container=LaunchConfiguration("container"),
target_container=LaunchConfiguration("container_name"),
condition=IfCondition(LaunchConfiguration("use_pointcloud_container")),
)

return LaunchDescription(
[
add_launch_arg("container", ""),
add_launch_arg("use_multithread", "false"),
add_launch_arg("use_intra_process", "false"),
add_launch_arg("input/obstacle_pointcloud", "no_ground/oneshot/pointcloud"),
Expand All @@ -131,6 +128,8 @@ def add_launch_arg(name: str, default_value=None):
add_launch_arg("output/stixel", "virtual_scan/stixel"),
add_launch_arg("input_obstacle_pointcloud", "false"),
add_launch_arg("input_obstacle_and_raw_pointcloud", "true"),
add_launch_arg("use_pointcloud_container", "False"),
add_launch_arg("container_name", "occupancy_grid_map_container"),
set_container_executable,
set_container_mt_executable,
occupancy_grid_map_container,
Expand Down
8 changes: 8 additions & 0 deletions perception_launch/launch/perception.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<arg name="image_number" default="6" description="choose image raw number(0-7)"/>
<arg name="use_vector_map" default="true" description="use vector map in prediction"/>
<arg name="use_empty_dynamic_object_publisher" default="false" description="if use_empty_dynamic_object_publisher:=true, /perception/object_recognition/objects topic has an empty DynamicObjectArray"/>
<arg name="use_pointcloud_container" default="false" description="launch pointcloud container"/>
<arg name="pointcloud_container_name" default="pointcloud_container"/>

<!-- perception module -->
<group>
Expand All @@ -39,6 +41,8 @@
<arg name="vehicle_param_file" value="$(var vehicle_param_file)" />
<arg name="use_intra_process" value="true" />
<arg name="use_multithread" value="true" />
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)" />
<arg name="container_name" value="$(var pointcloud_container_name)"/>
</include>
</group>
</group>
Expand All @@ -50,6 +54,10 @@
<arg name="input/obstacle_pointcloud" value="/perception/obstacle_segmentation/ground_segmentation/no_ground/pointcloud" />
<arg name="input/raw_pointcloud" value="/sensing/lidar/concatenated/pointcloud" />
<arg name="output" value="/perception/occupancy_grid_map/map" />
<arg name="use_intra_process" value="true" />
<arg name="use_multithread" value="true" />
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)" />
<arg name="container_name" value="$(var pointcloud_container_name)"/>
</include>
</group>

Expand Down
4 changes: 4 additions & 0 deletions sensing_launch/launch/sensing.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<arg name="sensor_model" description="sensor model name"/>
<arg name="vehicle_param_file" description="path to the file of vehicle info yaml"/>
<arg name="vehicle_mirror_param_file" description="path to the file of vehicle mirror position yaml"/>
<arg name="use_pointcloud_container" default="false" description="launch pointcloud container"/>
<arg name="pointcloud_container_name" default="pointcloud_container"/>

<let name="sensor_launch_pkg" value="$(find-pkg-share $(var sensor_model)_launch)"/>

Expand All @@ -15,6 +17,8 @@
<arg name="launch_driver" value="$(var launch_driver)" />
<arg name="vehicle_param_file" value="$(var vehicle_param_file)" />
<arg name="vehicle_mirror_param_file" value="$(var vehicle_mirror_param_file)" />
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)" />
<arg name="pointcloud_container_name" value="$(var pointcloud_container_name)"/>
</include>

</group>
Expand Down

0 comments on commit 1102582

Please sign in to comment.