ros2 / ros2/launch

Unexpected value of launch argument in 'on_exit' clause

Open
#501 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Python
Stars
155
Forks
182
Avg merge
2d 14h
Merged PRs (30d)
6

Description

Bug report

  • Ubuntu 20.04 ROS2 Foxy
  • Installed from package binaries:
Steps to reproduce issue
# test1.launch.py
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource

def generate_launch_description():
    ld = LaunchDescription()
    for r in ['r1', 'r2']:
        ld.add_action(IncludeLaunchDescription(
            PythonLaunchDescriptionSource('test2.launch.py'),
                launch_arguments = {'r' : r}.items()
        ))
    return ld

# test2.launch.py
from launch import LaunchDescription
from launch.actions import ExecuteProcess
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration

def generate_launch_description():
    ld = LaunchDescription()
    ld.add_action(DeclareLaunchArgument('r'))
    ld.add_action(
        ExecuteProcess(
            cmd     = ['echo', 'first', LaunchConfiguration('r')],
            output  = 'screen',
            on_exit = ExecuteProcess(
                cmd     = ['echo', 'second', LaunchConfiguration('r')],
                output  = 'screen'
            )
        )
    )
    return ld


ros2 launch test1.launch.py
Expected behavior

echo commands print:

first r1
first r2
second r1
second r2
Actual behavior
[INFO] [echo-1]: process started with pid [1686]
[INFO] [echo-1]: process has finished cleanly [pid 1686]
[INFO] [echo-2]: process started with pid [1688]
[INFO] [echo-2]: process has finished cleanly [pid 1688]
[echo-1] first r1
[echo-2] first r2
[INFO] [echo-3]: process started with pid [1690]
[INFO] [echo-3]: process has finished cleanly [pid 1690]
[echo-3] second r2
[INFO] [echo-4]: process started with pid [1692]
[INFO] [echo-4]: process has finished cleanly [pid 1692]
[echo-4] second r2
Additional information

Somewhat related to https://github.com/ros/robot_state_publisher/issues/144 I wish to run a robot_state_publisher per robot in a multi robot system where all the robot are identical, and they all get the URDF model from a topic published by the owner of the model, which in this case is a docker container running Gazebo. Since robot_state_publisher does not support receiving a model via topic, my workaround was to have a helper node receive the model and write it to a temporary local file, after which robot_state_publisher could be started.

A launch file is invoked per robot with a different value launch parameter uniquely naming the robot and the temporary file. Using the style of test2.launch.py to achieve this was unsuccessful, because the value of the launch configuration variable 'r' is always 'r2' in the 'on_exit' ExecuteProcess.

I'm quite new to the Python launch system and would welcome any pointers to what I might be doing wrong here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the test1.launch.py and test2.launch.py reproducer and run ros2 launch test1.launch.py on the described ROS 2 setup. Inspect how ExecuteProcess handles its on_exit action and how LaunchConfiguration('r') is resolved for included launch descriptions. Done means the on_exit commands print the matching values, second r1 and second r2, rather than both using r2.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.