Skip to content

Declare the namespace launch argument in state publisher launch - #1150

Open
mmporong wants to merge 1 commit into
ROBOTIS-GIT:mainfrom
mmporong:fix/state-publisher-namespace-arg
Open

Declare the namespace launch argument in state publisher launch#1150
mmporong wants to merge 1 commit into
ROBOTIS-GIT:mainfrom
mmporong:fix/state-publisher-namespace-arg

Conversation

@mmporong

Copy link
Copy Markdown

Issue: Fixes #1149. turtlebot3_state_publisher.launch.py cannot be launched
directly because it reads LaunchConfiguration('namespace') without declaring it or
giving it a default, so it only works when included from robot.launch.py.

Fix: Give namespace a default value and declare it, mirroring what
d81e95a already did for robot.launch.py. The two launch files are now consistent.

-    namespace = LaunchConfiguration('namespace')
+    namespace = LaunchConfiguration('namespace', default='')

     return LaunchDescription([
+        DeclareLaunchArgument(
+            'namespace',
+            default_value='',
+            description='Namespace for nodes'),
         DeclareLaunchArgument(
             'use_sim_time',

Verification: tested against ros-humble-turtlebot3-bringup 2.3.6 with
TURTLEBOT3_MODEL=burger.

check before after
ros2 launch turtlebot3_bringup turtlebot3_state_publisher.launch.py launch configuration 'namespace' does not exist starts, got segment base_footprint
same with namespace:=tb1 same error got segment tb1/base_footprint
ros2 launch turtlebot3_bringup robot.launch.py 3 nodes start 3 nodes start (unchanged)
... --show-args namespace not listed namespace listed
flake8 --max-line-length 99 clean clean

Multi-robot behaviour is unchanged: omitting the argument keeps the namespace empty,
which is what robot.launch.py passes today.

The file is byte-identical on main, jazzy and humble, so the same patch applies
to the other branches if a backport is wanted.

turtlebot3_state_publisher.launch.py reads LaunchConfiguration('namespace')
but never declares it and gives it no default, so the file only works when it
is included from robot.launch.py, which passes the argument explicitly.

Launching it directly fails:

    $ ros2 launch turtlebot3_bringup turtlebot3_state_publisher.launch.py
    [ERROR] [launch]: Caught exception in launch (see debug for traceback):
    launch configuration 'namespace' does not exist

This was introduced in d81e95a ("Add namespace argument for multi robot
control in turtlebot3 bringup launch"). That commit added both the
LaunchConfiguration and a matching DeclareLaunchArgument to robot.launch.py,
but only the LaunchConfiguration to turtlebot3_state_publisher.launch.py.
This change applies the same pattern to the latter file.

The multi robot behaviour is unchanged: with no argument the namespace stays
empty, and 'namespace:=tb1' still prefixes the frames as before.

Signed-off-by: mmporong <mmporong@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

turtlebot3_state_publisher.launch.py cannot be launched directly: undeclared 'namespace' argument

1 participant