Skip to content

Commit 5a0ebe0

Browse files
authored
refactor(autoware_pointcloud_preprocessor/launch): use launch substitution instead of get_package_share_directory (#12395)
refactor: use launch substitution instead of get_package_share_directory Signed-off-by: Taeseung Sohn <taeseung.sohn@tier4.jp>
1 parent 8b0719b commit 5a0ebe0

File tree

3 files changed

+41
-33
lines changed

3 files changed

+41
-33
lines changed

sensing/autoware_pointcloud_preprocessor/launch/pointcloud_densifier.launch.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,25 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
16-
17-
from ament_index_python.packages import get_package_share_directory
1815
import launch
1916
from launch.actions import DeclareLaunchArgument
2017
from launch.substitutions import LaunchConfiguration
18+
from launch.substitutions import PathJoinSubstitution
2119
from launch_ros.actions import ComposableNodeContainer
2220
from launch_ros.descriptions import ComposableNode
21+
from launch_ros.parameter_descriptions import ParameterFile
22+
from launch_ros.substitutions import FindPackageShare
2323

2424

2525
def generate_launch_description():
2626
"""Launch the pointcloud densifier node."""
27-
pkg_prefix = get_package_share_directory("autoware_pointcloud_preprocessor")
28-
config_file = os.path.join(pkg_prefix, "config/pointcloud_densifier.param.yaml")
27+
config_file = PathJoinSubstitution(
28+
[
29+
FindPackageShare("autoware_pointcloud_preprocessor"),
30+
"config",
31+
"pointcloud_densifier.param.yaml",
32+
]
33+
)
2934

3035
input_topic = DeclareLaunchArgument(
3136
"input_topic",
@@ -48,7 +53,7 @@ def generate_launch_description():
4853
("input", LaunchConfiguration("input_topic")),
4954
("output", LaunchConfiguration("output_topic")),
5055
],
51-
parameters=[config_file],
56+
parameters=[ParameterFile(config_file)],
5257
)
5358

5459
# Create container

sensing/autoware_pointcloud_preprocessor/launch/polygon_remover.launch.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,20 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
16-
17-
from ament_index_python.packages import get_package_share_directory
1815
import launch
16+
from launch.substitutions import PathJoinSubstitution
1917
from launch_ros.actions import ComposableNodeContainer
2018
from launch_ros.descriptions import ComposableNode
2119
from launch_ros.parameter_descriptions import ParameterFile
20+
from launch_ros.substitutions import FindPackageShare
2221

2322

2423
def generate_launch_description():
2524
ns = "pointcloud_preprocessor"
2625
pkg = "autoware_pointcloud_preprocessor"
2726

28-
param_file = os.path.join(
29-
get_package_share_directory("autoware_vehicle_info_utils"), "config/polygon_remover.yaml"
27+
param_file = PathJoinSubstitution(
28+
[FindPackageShare("autoware_vehicle_info_utils"), "config", "polygon_remover.yaml"]
3029
)
3130

3231
my_component = ComposableNode(

sensing/autoware_pointcloud_preprocessor/launch/preprocessor.launch.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
16-
17-
from ament_index_python.packages import get_package_share_directory
1815
import launch
1916
from launch.actions import DeclareLaunchArgument
2017
from launch.actions import LogInfo
2118
from launch.actions import OpaqueFunction
2219
from launch.substitutions import LaunchConfiguration
20+
from launch.substitutions import PathJoinSubstitution
2321
from launch.substitutions import PythonExpression
2422
from launch_ros.actions import ComposableNodeContainer
2523
from launch_ros.descriptions import ComposableNode
2624
from launch_ros.parameter_descriptions import ParameterFile
25+
from launch_ros.substitutions import FindPackageShare
2726

2827

2928
def launch_setup(context, *args, **kwargs):
@@ -165,9 +164,6 @@ def launch_setup(context, *args, **kwargs):
165164

166165
def generate_launch_description():
167166
launch_arguments = []
168-
autoware_pointcloud_preprocessor_share_dir = get_package_share_directory(
169-
"autoware_pointcloud_preprocessor"
170-
)
171167

172168
def add_launch_arg(name: str, default_value=None, description=None):
173169
# a default_value of None is equivalent to not passing that kwarg at all
@@ -185,37 +181,45 @@ def add_launch_arg(name: str, default_value=None, description=None):
185181
add_launch_arg("tf_output_frame", "base_link")
186182
add_launch_arg(
187183
"concatenate_and_time_sync_node_param_path",
188-
os.path.join(
189-
autoware_pointcloud_preprocessor_share_dir,
190-
"config",
191-
"concatenate_and_time_sync_node.param.yaml",
184+
PathJoinSubstitution(
185+
[
186+
FindPackageShare("autoware_pointcloud_preprocessor"),
187+
"config",
188+
"concatenate_and_time_sync_node.param.yaml",
189+
]
192190
),
193191
description="path to parameter file of concatenate and time sync node",
194192
)
195193
add_launch_arg(
196194
"concatenate_pointclouds_node_param_path",
197-
os.path.join(
198-
autoware_pointcloud_preprocessor_share_dir,
199-
"config",
200-
"concatenate_pointclouds.param.yaml",
195+
PathJoinSubstitution(
196+
[
197+
FindPackageShare("autoware_pointcloud_preprocessor"),
198+
"config",
199+
"concatenate_pointclouds.param.yaml",
200+
]
201201
),
202202
description="path to parameter file of concatenate pointclouds node",
203203
)
204204
add_launch_arg(
205205
"time_synchronizer_node_param_path",
206-
os.path.join(
207-
autoware_pointcloud_preprocessor_share_dir,
208-
"config",
209-
"time_synchronizer_node.param.yaml",
206+
PathJoinSubstitution(
207+
[
208+
FindPackageShare("autoware_pointcloud_preprocessor"),
209+
"config",
210+
"time_synchronizer_node.param.yaml",
211+
]
210212
),
211213
description="path to parameter file of time synchronizer node",
212214
)
213215
add_launch_arg(
214216
"crop_box_filter_node_param_path",
215-
os.path.join(
216-
autoware_pointcloud_preprocessor_share_dir,
217-
"config",
218-
"crop_box_filter_node.param.yaml",
217+
PathJoinSubstitution(
218+
[
219+
FindPackageShare("autoware_pointcloud_preprocessor"),
220+
"config",
221+
"crop_box_filter_node.param.yaml",
222+
]
219223
),
220224
description="path to parameter file of crop box filter node",
221225
)

0 commit comments

Comments
 (0)