ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Specify log level on ROS2 node in Launch file

asked 2021-06-22 20:47:47 -0500

flimsypondreed gravatar image

I have been trying to figure out how to get the launch file to specify the logger level of ROS2 Nodes but I have been unsuccessful.

    Node(
        package="...snip...",
        executable="...snip...",
        output="log",
        exec_name='...snip...',
        arguments=["--ros-args --log-level DEBUG --"],
    ),

It does seem to generate a valid command as displayed in the logs when I terminate the launch:

[ERROR] [snip]: process has died [pid 47524, exit code -6, cmd '...snip... --ros-args --log-level DEBUG -- --ros-args -r __node:=...snip... --params-file ...snip....yaml --params-file /tmp/launch_params_nyb586m5'].

Running this on the terminal does show debug messages printed. But when running from the launch file, there are no debug messages to be seen anywhere, on the screen or in the logs.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-06-23 18:56:15 -0500

updated 2021-06-23 18:57:39 -0500

You have to split up the arguments, like this:

arguments=['--ros-args', '--log-level', 'DEBUG'],

This is how it's usually done with anything that interacts with exec*()(which is what launch ultimately calls under the hood). It looks fine and the resulting command string is fine (as you said), but it's not valid. See this comment: https://github.com/ros2/launch_ros/is...

Also, I don't think you need the -- at the end. Works fine for me without it.

edit flag offensive delete link more

Comments

1

Thanks Christophe I really should have tried that. The -- at the end was in case launch adds any arguments afterwards that are not for --ros-args.

It's all a bit clunky. I think launch_ros.Node should maybe have a ros_arguments option.

flimsypondreed gravatar image flimsypondreed  ( 2021-06-23 20:35:50 -0500 )edit

I agree. There is an issue/feature request for that here: https://github.com/ros2/launch_ros/is....

christophebedard gravatar image christophebedard  ( 2021-06-24 07:14:09 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-06-22 20:47:47 -0500

Seen: 1,177 times

Last updated: Jun 23 '21