Ask Your Question

Types of input for get_logger in ros2 RCLCPP_INFO

asked 2022-04-14 10:29:11 -0500

Flash gravatar image

updated 2022-04-14 10:38:07 -0500

I was trying to find what types of input can be provided for

RCLCPP_INFO(get_logger(), "data: %*", data)

I had used %s for string kind of output but was wondering if it can take any other types of data. While looking over some codes I saw the use of %g not sure what it represents.
Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-04-14 20:08:54 -0500

aprotyas gravatar image

The second argument in the logging macros is a format specification, i.e. a pointer to a null-terminated multibyte string specifying how to interpret the data. As such, you can use any standard format specifier accepted by printf. Here's a small reference list:

Also, from the same link: %g converts floating-point number to decimal or decimal exponent notation depending on the value and the precision.

edit flag offensive delete link more


Can I know which second argument you are talking about?

Flash gravatar image Flash  ( 2022-04-15 10:18:11 -0500 )edit

In RCLCPP_INFO(get_logger(), "data: %s", "message") the "data: %s" const character buffer would correspond to the second argument.

aprotyas gravatar image aprotyas  ( 2022-04-15 11:01:04 -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: 2022-04-14 10:29:11 -0500

Seen: 50 times

Last updated: Apr 14