Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: error when combining/nesting GroupAction, IncludeLaunchDescription and TimerAction with launch arguments #825

Open
M-Schroeder opened this issue Feb 4, 2025 · 0 comments

Comments

@M-Schroeder
Copy link

I have a nested launch structure. In one launch file, I used TimerAction to launch a Node with a time delay. This launch file is included in another launch file using IncludeLaunchDescription. If this IncludeLaunchDescription is used directly, it works. If it is again nested inside a GroupAction, it gives me an error.

Minimal example:

main_launch.py has following content:

from launch.actions import GroupAction
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource



def generate_launch_description():

    nested_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource("./nested_launch.py"),
        launch_arguments={'robot_namespace': "scout_mini"}.items()
    )

    my_group_action = GroupAction(
        actions=[nested_launch]
    )


    ld = LaunchDescription()
    ld.add_action(my_group_action)
    # ld.add_action(nested_launch)
    return ld

nested_launch.py has following content:

from launch.actions import TimerAction
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument, TimerAction



def generate_launch_description():

    robot_namespace = LaunchConfiguration('robot_namespace')
    
    declare_robot_namespace_cmd = DeclareLaunchArgument(
        name='robot_namespace',
        default_value='scout_mini'
    )

    example_timer_action = TimerAction(
        actions=[
            Node(
                package="demo_nodes_py",
                executable="listener",
                namespace=robot_namespace
            )
        ],
        period=2.0
    )


    ld = LaunchDescription()
    ld.add_action(declare_robot_namespace_cmd)
    ld.add_action(example_timer_action)
    return ld

Error

Both launch files are in the same folder, I launch it with ros2 launch ./main_launch.py and get the following error:

[ERROR] [launch_ros.actions.node]: Error while expanding or validating node name or namespace for 'package=demo_nodes_py, executable=listener, name=None, namespace=<launch.substitutions.launch_configuration.LaunchConfiguration object at 0x7c5cff6e60b0>':
[ERROR] [launch]: Caught exception in launch (see debug for traceback): launch configuration 'robot_namespace' does not exist

(Similar behavior can be seen, if the launch files are properly organised in packages.)
Debugging in the upper level launch files was quite confusing, since putting something in a GroupAction shouldn't change its behavior much (from my understanding).

How it works

It works, if the main_launch.py instead ends with

    ld = LaunchDescription()
    # ld.add_action(my_group_action)
    ld.add_action(nested_launch)
    return ld

It also works, if alternatively you don't use TimerAction in nested_launch.py or if you have everything within one launch file. It seems to be a problem with this combination.

System

Ubuntu 22.04.5 LTS
ROS2 humble

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

No branches or pull requests

1 participant