ros2 / launch_ros

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

Can't use launch argument for node output #46

Open ryanewel opened 5 years ago

ryanewel commented 5 years ago

Bug report

Required Info:

Steps to reproduce issue

Using a launch file like:

import launch
import launch_ros.actions

#Argument names
NODE_NAME = "node_name"
OUTPUT = "output"

def generate_launch_description():
  ld = launch.LaunchDescription([
    launch.actions.DeclareLaunchArgument(
      NODE_NAME,
      default_value="node_name",
    ),
    launch.actions.DeclareLaunchArgument(
      OUTPUT,
      default_value="screen"
    ),
 ])
  node = launch_ros.actions.Node(
      package="package_name",
      node_executable="executable_name",
      output=launch.substitutions.LaunchConfiguration(OUTPUT),
      node_name=launch.substitutions.LaunchConfiguration(NODE_NAME),
  )
  ld.add_action(node)
  return ld

Then run:

ros2 launch example_launch.py

Expected behavior

I would expect the output to default to 'screen', but be settable from the cli with output:=log or from another launch file that includes this one.

Actual behavior

Launch fails with message

[ERROR] [launch]: Caught exception in launch (see debug for traceback): <launch.substitutions.launch_configuration.LaunchConfiguration object at 0x7f5f04242ac8> is not a valid output configuration

Additional information


Feature request

Feature description

Implementation considerations

tobiasneumann commented 4 years ago

I can reproduce this (with an existing package_name and executable_name).

hidmic commented 4 years ago

Indeed. Currently we do not support substitutions as launch.actions.ExecuteProcess' output argument (see constructor).

I don't see why we couldn't though, a launch context is available when that output configuration is first used (see here).

@ryanewel @tobiasneumann would you be willing to contribute a patch?

tobiasneumann commented 4 years ago

I'm sorry, I can not contribute since my experience and knowledge of python is minimal.

Parv-Maheshwari commented 3 years ago

@hidmic Are there any plans to include substitutions in the launch description. In my case, I made the namespace , a parameter dependent on the launch argument "robot" which can take vaues like 0,1,2,,,,, . And my namespace is accordingly = "robot"+"robot" i.e. robot0, robot1, etc.

But instead of this behaviour, I am receiving this error - rclpy.exceptions.InvalidNamespaceException: Invalid namespace: namespace must not contain characters other than alphanumerics, '_', or '/': '/robot<launch.substitutions.launch_configuration.LaunchConfiguration object at 0x7fc6c9b48a30>'

Please ;et me know in case my use case and example is not clear.

Violin9906 commented 2 months ago

Any updates on this topic? It seems to still exist in ROS Galactic.