|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
| 15 | +import re |
| 16 | + |
15 | 17 | from ament_index_python.packages import get_package_share_directory
|
16 | 18 | from launch import LaunchDescription
|
17 | 19 | from launch.actions import DeclareLaunchArgument
|
|
26 | 28 | import yaml
|
27 | 29 |
|
28 | 30 |
|
| 31 | +def replace_pkg_share_path_with_package_name(param_string: str) -> str: |
| 32 | + # replace $(find-pkg-share ...) with the actual path |
| 33 | + # get the package name from the string |
| 34 | + match = re.search(r"\$\(\s*find-pkg-share\s+([a-zA-Z0-9_]+)\s*\)", param_string) |
| 35 | + if match: |
| 36 | + package_name = match.group(1) |
| 37 | + package_path = get_package_share_directory(package_name) |
| 38 | + # Replace the entire $(find-pkg-share ...) expression with the package path |
| 39 | + return param_string.replace(match.group(0), package_path) |
| 40 | + else: |
| 41 | + # If no match is found, return the original string |
| 42 | + return param_string |
| 43 | + |
| 44 | + |
29 | 45 | def launch_setup(context, *args, **kwargs):
|
30 | 46 | # load parameter files
|
31 | 47 | param_file = LaunchConfiguration("param_file").perform(context)
|
32 | 48 | with open(param_file, "r") as f:
|
33 | 49 | laserscan_based_occupancy_grid_map_node_params = yaml.safe_load(f)["/**"]["ros__parameters"]
|
34 |
| - |
35 |
| - updater_param_file = LaunchConfiguration("updater_param_file").perform(context) |
36 |
| - with open(updater_param_file, "r") as f: |
37 |
| - occupancy_grid_map_updater_params = yaml.safe_load(f)["/**"]["ros__parameters"] |
| 50 | + # replace $(find-pkg-share ...) with the actual path |
| 51 | + laserscan_based_occupancy_grid_map_node_params[ |
| 52 | + "updater_param_file" |
| 53 | + ] = replace_pkg_share_path_with_package_name( |
| 54 | + laserscan_based_occupancy_grid_map_node_params["updater_param_file"] |
| 55 | + ) |
38 | 56 |
|
39 | 57 | composable_nodes = [
|
40 | 58 | ComposableNode(
|
@@ -101,13 +119,11 @@ def launch_setup(context, *args, **kwargs):
|
101 | 119 | ],
|
102 | 120 | parameters=[
|
103 | 121 | laserscan_based_occupancy_grid_map_node_params,
|
104 |
| - occupancy_grid_map_updater_params, |
105 | 122 | {
|
106 | 123 | "input_obstacle_pointcloud": LaunchConfiguration("input_obstacle_pointcloud"),
|
107 | 124 | "input_obstacle_and_raw_pointcloud": LaunchConfiguration(
|
108 | 125 | "input_obstacle_and_raw_pointcloud"
|
109 | 126 | ),
|
110 |
| - "updater_type": LaunchConfiguration("updater_type"), |
111 | 127 | },
|
112 | 128 | ],
|
113 | 129 | extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
|
@@ -165,12 +181,6 @@ def add_launch_arg(name: str, default_value=None):
|
165 | 181 | get_package_share_directory("probabilistic_occupancy_grid_map")
|
166 | 182 | + "/config/laserscan_based_occupancy_grid_map.param.yaml",
|
167 | 183 | ),
|
168 |
| - add_launch_arg("updater_type", "binary_bayes_filter"), |
169 |
| - add_launch_arg( |
170 |
| - "updater_param_file", |
171 |
| - get_package_share_directory("probabilistic_occupancy_grid_map") |
172 |
| - + "/config/updater.param.yaml", |
173 |
| - ), |
174 | 184 | add_launch_arg("input_obstacle_pointcloud", "false"),
|
175 | 185 | add_launch_arg("input_obstacle_and_raw_pointcloud", "true"),
|
176 | 186 | add_launch_arg("use_pointcloud_container", "false"),
|
|
0 commit comments