Ask Your Question
5

Selecting log level in ROS2 launch file

asked 2018-12-25 14:30:43 -0600

Teckel gravatar image

updated 2018-12-25 14:31:44 -0600

Nodes defined in launch file have the INFO log level as a default value I would like to know how to change it so that it also logs DEBUG level strings or other types of logging.

launch_ros.actions.Node(package='demo_nodes_cpp', node_executable='talker', output='screen', parameters=[config_file])

Thank you

edit retag flag offensive close merge delete

Comments

Any updates?

yossi_ov gravatar image yossi_ov  ( 2019-11-11 01:38:51 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2020-11-03 09:46:57 -0600

notarobot gravatar image

Hello, I have had the same issue and for me (on Eloquent) the following works:

logger = launch.substitutions.LaunchConfiguration("log_level")
launch.LaunchDescription([
      launch.actions.DeclareLaunchArgument(
            "log_level",
            default_value=["debug"],
            description="Logging level",
      ),
     launch_ros.actions.Node(
         package='demo_nodes_cpp',
         executable='talker',
         output='screen', 
         arguments=['--ros-args', '--log-level', logger]
    )
])

I got this idea from this open issue: https://github.com/ros2/launch/issues... and hopefully a more elegant solution will be available soon.

If anyone has an idea for a better solution in the meantime, please share!

edit flag offensive delete link more
2

answered 2019-11-21 22:27:02 -0600

johnconn gravatar image

I know this question was asked before dashing was released, and that eloquent is being released soon with changed syntax...

But for dashing, you can use the following syntax:

  launch_ros.actions.Node(package='demo_nodes_cpp',
    node_executable='talker',
    output='screen', 
     parameters=[config_file],
    arguments=[('__log_level:=debug')])

This will set the log level to debug for every node being run in this process (rcl, rclcpp, the rmw layer). I don't know how to restrict the log changes to just "talker" node unfortunately. I think logging is still a work in progress.

edit flag offensive delete link more

Comments

Can anyone update on how to do this in Eloquent/Foxy? The direct translation to the new command line format does not work:

launch_ros.actions.Node(
    package='demo_nodes_cpp',
    executable='talker',
    output='screen', 
    arguments=[('--ros-args --log-level debug')]
)
rasmusan- gravatar image rasmusan-  ( 2020-09-10 03:33:34 -0600 )edit
1

The arguments must be given in a list of strings in Foxy as shown below.

launch_ros.actions.Node(
    package='demo_nodes_cpp',
    executable='talker',
    output='screen', 
    arguments=['--ros-args', '--log-level', 'debug']
)

The accepted answer achieves the same result as the above code.

trunc8 gravatar image trunc8  ( 2021-08-15 05:25:04 -0600 )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

4 followers

Stats

Asked: 2018-12-25 14:30:43 -0600

Seen: 2,702 times

Last updated: Sep 10 '20