ros2 / launch_ros

Tools for launching ROS nodes and for writing tests involving ROS nodes.
Apache License 2.0
60 stars 74 forks source link

Environment variables not set for actions inside RosTimer #376

Open tonynajjar opened 1 year ago

tonynajjar commented 1 year ago

Bug report

Required Info:

Steps to reproduce issue

from launch import LaunchDescription
from launch.actions import (
    GroupAction,
    SetEnvironmentVariable,
)
from launch_ros.actions import Node, RosTimer

def generate_launch_description():  # noqa: D103
    ld = LaunchDescription()
    ld.add_action(
        GroupAction(
            actions=[
                SetEnvironmentVariable(name="ROS_DOMAIN_ID", value="2"),
                RosTimer(
                    period=1.0,
                    actions=[
                        # Gets ROS_DOMAIN_ID of 0
                        Node(
                            package="demo_nodes_py",
                            executable="talker",
                            output="screen",
                        ),
                    ],
                ),
                # Gets ROS_DOMAIN_ID of 2
                Node(
                    package="demo_nodes_py",
                    executable="listener",
                    output="screen",
                ),
            ]
        )
    )

    return ld

Expected behavior

Both nodes get the same ROS_DOMAIN_ID of 2

Actual behavior

The node in RosTimer does not get ROS_DOMAIN_ID set

Additional information