Skip to content

Commit

Permalink
feat: add use_pointcloud_container option (#118)
Browse files Browse the repository at this point in the history
* feat: add use_pointcloud_container option

Signed-off-by: tomoya.kimura <tomoya.kimura@tier4.jp>

* feat: add options to lidar.launch

Signed-off-by: tomoya.kimura <tomoya.kimura@tier4.jp>

---------

Signed-off-by: tomoya.kimura <tomoya.kimura@tier4.jp>
  • Loading branch information
tkimura4 authored Apr 11, 2023
1 parent 0bd0ec1 commit db479d6
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 8 deletions.
2 changes: 2 additions & 0 deletions aip_x1_launch/launch/lidar.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<arg name="scan_phase" value="180.0" />
<arg name="launch_driver" value="$(var launch_driver)" />
<arg name="vehicle_mirror_param_file" value="$(var vehicle_mirror_param_file)" />
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)" />
<arg name="container_name" value="$(var pointcloud_container_name)"/>
</include>
</group>

Expand Down
8 changes: 8 additions & 0 deletions aip_xx1_launch/launch/lidar.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<arg name="scan_phase" value="300.0" />
<arg name="launch_driver" value="$(var launch_driver)" />
<arg name="vehicle_mirror_param_file" value="$(var vehicle_mirror_param_file)" />
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)" />
<arg name="container_name" value="$(var pointcloud_container_name)"/>
</include>
</group>

Expand All @@ -33,6 +35,8 @@
<arg name="scan_phase" value="180.0" />
<arg name="launch_driver" value="$(var launch_driver)" />
<arg name="vehicle_mirror_param_file" value="$(var vehicle_mirror_param_file)" />
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)" />
<arg name="container_name" value="$(var pointcloud_container_name)"/>
</include>
</group>

Expand All @@ -46,6 +50,8 @@
<arg name="scan_phase" value="180.0" />
<arg name="launch_driver" value="$(var launch_driver)" />
<arg name="vehicle_mirror_param_file" value="$(var vehicle_mirror_param_file)" />
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)" />
<arg name="container_name" value="$(var pointcloud_container_name)"/>
</include>
</group>

Expand All @@ -59,6 +65,8 @@
<arg name="scan_phase" value="180.0" />
<arg name="launch_driver" value="$(var launch_driver)" />
<arg name="vehicle_mirror_param_file" value="$(var vehicle_mirror_param_file)" />
<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 common_sensor_launch/launch/velodyne_VLP16.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<arg name="view_direction" default="0.0" />
<arg name="view_width" default="6.28" />
<arg name="vehicle_mirror_param_file" />
<arg name="use_pointcloud_container" default="false"/>
<arg name="container_name" default="velodyne_node_container"/>

<include file="$(find-pkg-share common_sensor_launch)/launch/velodyne_node_container.launch.py">
<arg name="launch_driver" value="$(var launch_driver)"/>
Expand All @@ -32,6 +34,8 @@
<arg name="vehicle_mirror_param_file" value="$(var vehicle_mirror_param_file)" />
<arg name="use_intra_process" value="true" />
<arg name="use_multithread" value="false" />
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)"/>
<arg name="container_name" value="$(var container_name)"/>
</include>

<!-- Velodyne Monitor -->
Expand Down
4 changes: 4 additions & 0 deletions common_sensor_launch/launch/velodyne_VLP32C.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<arg name="view_direction" default="0.0" />
<arg name="view_width" default="6.28" />
<arg name="vehicle_mirror_param_file" />
<arg name="use_pointcloud_container" default="false"/>
<arg name="container_name" default="velodyne_node_container"/>

<include file="$(find-pkg-share common_sensor_launch)/launch/velodyne_node_container.launch.py">
<arg name="launch_driver" value="$(var launch_driver)"/>
Expand All @@ -32,6 +34,8 @@
<arg name="vehicle_mirror_param_file" value="$(var vehicle_mirror_param_file)" />
<arg name="use_intra_process" value="false" />
<arg name="use_multithread" value="false" />
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)"/>
<arg name="container_name" value="$(var container_name)"/>
</include>

<!-- Velodyne Monitor -->
Expand Down
4 changes: 4 additions & 0 deletions common_sensor_launch/launch/velodyne_VLS128.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<arg name="view_direction" default="0.0" />
<arg name="view_width" default="6.28" />
<arg name="vehicle_mirror_param_file" />
<arg name="use_pointcloud_container" default="false"/>
<arg name="container_name" default="velodyne_node_container"/>

<include file="$(find-pkg-share common_sensor_launch)/launch/velodyne_node_container.launch.py">
<arg name="launch_driver" value="$(var launch_driver)"/>
Expand All @@ -32,6 +34,8 @@
<arg name="vehicle_mirror_param_file" value="$(var vehicle_mirror_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 container_name)"/>
</include>

<!-- Velodyne Monitor -->
Expand Down
29 changes: 21 additions & 8 deletions common_sensor_launch/launch/velodyne_node_container.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,19 @@ def create_parameter_dict(*args):

# set container to run all required components in the same process
container = ComposableNodeContainer(
# need unique name, otherwise all processes in same container and the node names then clash
name="velodyne_node_container",
name=LaunchConfiguration("container_name"),
namespace="pointcloud_preprocessor",
package="rclcpp_components",
executable=LaunchConfiguration("container_executable"),
composable_node_descriptions=nodes,
condition=UnlessCondition(LaunchConfiguration("use_pointcloud_container")),
output="screen",
)

component_loader = LoadComposableNodes(
composable_node_descriptions=nodes,
target_container=LaunchConfiguration("container_name"),
condition=IfCondition(LaunchConfiguration("use_pointcloud_container")),
)

driver_component = ComposableNode(
Expand All @@ -198,15 +205,19 @@ def create_parameter_dict(*args):
],
)

# one way to add a ComposableNode conditional on a launch argument to a
# container. The `ComposableNode` itself doesn't accept a condition
loader = LoadComposableNodes(
target_container = (
container
if UnlessCondition(LaunchConfiguration("use_pointcloud_container")).evaluate(context)
else LaunchConfiguration("container_name")
)

driver_component_loader = LoadComposableNodes(
composable_node_descriptions=[driver_component],
target_container=container,
condition=launch.conditions.IfCondition(LaunchConfiguration("launch_driver")),
target_container=target_container,
condition=IfCondition(LaunchConfiguration("launch_driver")),
)

return [container, loader]
return [container, component_loader, driver_component_loader]


def generate_launch_description():
Expand Down Expand Up @@ -248,6 +259,8 @@ def add_launch_arg(name: str, default_value=None, description=None):
)
add_launch_arg("use_multithread", "False", "use multithread")
add_launch_arg("use_intra_process", "False", "use ROS2 component container communication")
add_launch_arg("use_pointcloud_container", "false")
add_launch_arg("container_name", "velodyne_node_container")

set_container_executable = SetLaunchConfiguration(
"container_executable",
Expand Down

0 comments on commit db479d6

Please sign in to comment.