ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

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.

        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

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:

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

edit flag offensive delete link more



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:

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

Your Answer

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

Add Answer

Question Tools

1 follower


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

Seen: 598 times

Last updated: Jun 23 '21