Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This seems like a bit of a hack, but I can modify my launch file a little like this:

def generate_launch_description():
    node_env = os.environ.copy()
    node_env["PYTHONUNBUFFERED"] = "1"

    launch_description = LaunchDescription([
        Node(package="my_package", node_executable="counter_node", env=node_env),
        RegisterEventHandler(
            OnProcessIO(on_stdout=lambda info: print(info.text))
        )
    ])

According to this documentation it looks like there's supposed to be a SetEnvironmentVariable launch action, but I don't see it here. Maybe it's not implemented yet.

I'm not sure what issues I'll run into with c++ nodes, but I'll cross that bridge when I come to it

This seems like a bit of a hack, but I can modify my launch file a little like this:

def generate_launch_description():
    node_env = os.environ.copy()
    node_env["PYTHONUNBUFFERED"] = "1"

    launch_description = LaunchDescription([
        Node(package="my_package", node_executable="counter_node", env=node_env),
        RegisterEventHandler(
            OnProcessIO(on_stdout=lambda info: print(info.text))
        )
    ])

According to this documentation it looks like there's supposed to be a SetEnvironmentVariable launch action, but I don't see it here. Maybe it's not implemented yet.

I'm not sure what issues I'll run into with c++ nodes, but I'll cross that bridge when I come to it