Ask Your Question

[ros2] Prefix in launch file

asked 2020-02-05 02:22:42 -0600

hdino gravatar image

ROS 1 launch files allowed to run nodes in a debugger, e.g. using launch_prefix="gdb --args". I tried to use it with ROS 2 by adding this parameter to launch_ros.actions.Node, but it just caused parsing errors. Is there still a way to specify such a prefix in ROS 2 launch files?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-02-05 10:45:50 -0600

sloretz gravatar image

updated 2020-09-03 17:02:46 -0600


There is new discussion about this answer not being able to interact with GDB because launch doesn't allow a process to access stdin. That discussion is on an issue in the launch_ros repo.

One workaround is to add xterm -e to the start of the prefix to open an new xterm window with the process. In this case, use the prefix xterm -e gdb -ex=r --args.

There's another very similar question and answer in #q267261

Original answer

launch_ros.actions.Node inherits from launch.actions.ExecuteProcess, and it passes extra arguments given to __init__ to it. I think you're looking for prefix.

Save this file as

from launch import LaunchDescription
from launch import LaunchService

import launch_ros.actions

def generate_launch_description():
    """Run demo nodes via launch."""
    ld = LaunchDescription([
            package='demo_nodes_cpp', node_executable='talker', output='screen',
            remappings=[('chatter', 'my_chatter')],
            prefix=['gdb -ex=r --args'],
    return ld

And run with

ros2 launch
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-02-05 02:22:42 -0600

Seen: 1,233 times

Last updated: Sep 03 '20