|
19 | 19 | from launch.actions import DeclareLaunchArgument, GroupAction, SetEnvironmentVariable
|
20 | 20 | from launch.conditions import IfCondition
|
21 | 21 | from launch.substitutions import LaunchConfiguration, PythonExpression
|
22 |
| -from launch_ros.actions import LoadComposableNodes, Node, SetParameter |
| 22 | +from launch_ros.actions import LoadComposableNodes, Node, PushROSNamespace, SetParameter |
23 | 23 | from launch_ros.descriptions import ComposableNode, ParameterFile
|
24 | 24 | from nav2_common.launch import LaunchConfigAsBool, RewrittenYaml
|
25 | 25 |
|
@@ -65,6 +65,14 @@ def generate_launch_description() -> LaunchDescription:
|
65 | 65 | 'SPEED_ZONE_ENABLED': use_speed_zones,
|
66 | 66 | }
|
67 | 67 |
|
| 68 | + # RewrittenYaml: Adds namespace to the parameters file as a root key |
| 69 | + # Note: Make sure that all frames are correctly namespaced in the parameters file |
| 70 | + # Do not add namespace to topics in the parameters file, as they will be remapped |
| 71 | + # by the root key only if they are not prefixed with a forward slash. |
| 72 | + # e.g. 'map' will be remapped to '/<namespace>/map', but '/map' will not be remapped. |
| 73 | + # IMPORTANT: to make your yaml file dynamic you can refer to humble branch under |
| 74 | + # nav2_bringup/launch/bringup_launch.py to see how the parameters file is configured |
| 75 | + # using ReplaceString <robot_namespace> |
68 | 76 | configured_params = ParameterFile(
|
69 | 77 | RewrittenYaml(
|
70 | 78 | source_file=params_file,
|
@@ -143,6 +151,7 @@ def generate_launch_description() -> LaunchDescription:
|
143 | 151 | condition=IfCondition(PythonExpression(['not ', use_composition])),
|
144 | 152 | actions=[
|
145 | 153 | SetParameter('use_sim_time', use_sim_time),
|
| 154 | + PushROSNamespace(namespace=namespace), |
146 | 155 | Node(
|
147 | 156 | package='nav2_controller',
|
148 | 157 | executable='controller_server',
|
@@ -267,6 +276,7 @@ def generate_launch_description() -> LaunchDescription:
|
267 | 276 | condition=IfCondition(use_composition),
|
268 | 277 | actions=[
|
269 | 278 | SetParameter('use_sim_time', use_sim_time),
|
| 279 | + PushROSNamespace(namespace=namespace), |
270 | 280 | LoadComposableNodes(
|
271 | 281 | target_container=container_name_full,
|
272 | 282 | composable_node_descriptions=[
|
|
0 commit comments