1
$\begingroup$

Rosanswers logo

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.


Originally posted by flimsypondreed on ROS Answers with karma: 3 on 2021-06-22

Post score: 0

$\endgroup$

1 Answer 1

1
$\begingroup$

Rosanswers logo

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/issues/109#issuecomment-570303536

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


Originally posted by christophebedard with karma: 641 on 2021-06-23

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by flimsypondreed on 2021-06-23:
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.

Comment by christophebedard on 2021-06-24:
I agree. There is an issue/feature request for that here: https://github.com/ros2/launch_ros/issues/60.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.